summaryrefslogtreecommitdiff
path: root/tests/test_export.py
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2017-06-30 09:54:10 +1000
committerDylan Araps <dylan.araps@gmail.com>2017-06-30 09:54:10 +1000
commit615321de942ac4d75af72ba126ac5b69da203a72 (patch)
treefd13cb143ac508fb36bdbbb14729e0dc8be9d014 /tests/test_export.py
parent453d0cfa39e3b02ab6be6131b37050b3e6eca539 (diff)
general: Rename export_colors to export.
Diffstat (limited to 'tests/test_export.py')
-rwxr-xr-xtests/test_export.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_export.py b/tests/test_export.py
new file mode 100755
index 0000000..7204f48
--- /dev/null
+++ b/tests/test_export.py
@@ -0,0 +1,36 @@
+"""Test export functions."""
+import unittest
+import pathlib
+
+from pywal import export
+from pywal import util
+
+
+# Import colors.
+COLORS = util.read_file_json("tests/test_files/test_file.json")
+
+
+class TestExportColors(unittest.TestCase):
+ """Test the export functions."""
+
+ def test_template(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")
+ export.export_all_templates(COLORS, template_dir, output_dir)
+
+ result = pathlib.Path("/tmp/test_template").is_file()
+ self.assertTrue(result)
+
+ content = pathlib.Path("/tmp/test_template").read_text()
+ self.assertEqual(content, '\n'.join(["test1 #3A5130",
+ "test2 #3A5130",
+ "test3 58,81,48", ""]))
+
+
+if __name__ == "__main__":
+ unittest.main()