diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-07-22 23:48:47 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-07-22 23:48:47 +1000 |
| commit | 676f5325e11cfc12d6080f6cdb27be2e697a88a8 (patch) | |
| tree | e455173a8ccdf1c412b59885f82478907b0bca76 /tests | |
| parent | d1c2b8023de2585befc5b68e69ed6d0f3ee5d27e (diff) | |
tests: Add new template test.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_files/templates/test_template | 3 | ||||
| -rwxr-xr-x | tests/test_template.py | 33 |
2 files changed, 24 insertions, 12 deletions
diff --git a/tests/test_files/templates/test_template b/tests/test_files/templates/test_template deleted file mode 100644 index af40ce7..0000000 --- a/tests/test_files/templates/test_template +++ /dev/null @@ -1,3 +0,0 @@ -test1 {color0} -test2 {background} -test3 {background.rgb} diff --git a/tests/test_template.py b/tests/test_template.py index ef71b8b..9b9870d 100755 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -8,28 +8,43 @@ from pywal import util # Import colors. COLORS = util.read_file_json("tests/test_files/test_file.json") +OUTPUT_DIR = pathlib.Path("/tmp/wal") + +util.create_dir("/tmp/wal") class TestExportColors(unittest.TestCase): """Test the export functions.""" - def test_template(self): + def test_all_templates(self): """> Test substitutions in template file.""" # Merge both dicts so we can access their # values simpler. COLORS["colors"].update(COLORS["special"]) - output_dir = pathlib.Path("/tmp") - template_dir = pathlib.Path("tests/test_files/templates") - template.export_all(COLORS, output_dir, template_dir) + template.export_all(COLORS, OUTPUT_DIR) + + result = pathlib.Path("/tmp/colors.sh").is_file() + self.assertTrue(result) + + content = pathlib.Path("/tmp/colors.sh").read_text() + content = content.split("\n")[6] + self.assertEqual(content, "foreground='#F5F1F4'") + + def test_css_template(self): + """> Test substitutions in template file (css).""" + # Merge both dicts so we can access their + # values simpler. + COLORS["colors"].update(COLORS["special"]) + + template.export(COLORS, "colors.css", OUTPUT_DIR) - result = pathlib.Path("/tmp/test_template").is_file() + result = pathlib.Path("/tmp/colors.css").is_file() self.assertTrue(result) - content = pathlib.Path("/tmp/test_template").read_text() - self.assertEqual(content, '\n'.join(["test1 #1F211E", - "test2 #1F211E", - "test3 31,33,30", ""])) + content = pathlib.Path("/tmp/colors.css").read_text() + content = content.split("\n")[6] + self.assertEqual(content, " --background: #1F211E;") if __name__ == "__main__": |
