summaryrefslogtreecommitdiff
path: root/tests/test_export.py
diff options
context:
space:
mode:
authorDylan Araps <dylanaraps@users.noreply.github.com>2017-07-23 15:37:14 +1000
committerGitHub <noreply@github.com>2017-07-23 15:37:14 +1000
commit0c1d76e2b3611b541316dc8d7eb67f18cec5e7f2 (patch)
treeaaf8141c62789dcfc4f72af24ae96df71459a084 /tests/test_export.py
parent9c871ec567504c2566c4ce9f3d382f544cb62b57 (diff)
parent07b8ad8e0d97f54277c2e744f745ba3e47d0e53c (diff)
Merge pull request #52 from dylanaraps/api
api: Start work on a proper api.
Diffstat (limited to 'tests/test_export.py')
-rwxr-xr-xtests/test_export.py32
1 files changed, 20 insertions, 12 deletions
diff --git a/tests/test_export.py b/tests/test_export.py
index 167d3ed..ebf5740 100755
--- a/tests/test_export.py
+++ b/tests/test_export.py
@@ -8,28 +8,36 @@ from pywal import util
# Import colors.
COLORS = util.read_file_json("tests/test_files/test_file.json")
+COLORS["colors"].update(COLORS["special"])
+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"])
+ export.every(COLORS, OUTPUT_DIR)
+
+ result = pathlib.Path("/tmp/wal/colors.sh").is_file()
+ self.assertTrue(result)
+
+ content = pathlib.Path("/tmp/wal/colors.sh").read_text()
+ content = content.split("\n")[6]
+ self.assertEqual(content, "foreground='#F5F1F4'")
- output_dir = pathlib.Path("/tmp")
- template_dir = pathlib.Path("tests/test_files/templates")
- export.export_all_templates(COLORS, template_dir, output_dir)
+ def test_css_template(self):
+ """> Test substitutions in template file (css)."""
+ export.color(COLORS, "css", OUTPUT_DIR / "test.css")
- result = pathlib.Path("/tmp/test_template").is_file()
+ result = pathlib.Path("/tmp/wal/test.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/wal/test.css").read_text()
+ content = content.split("\n")[6]
+ self.assertEqual(content, " --background: #1F211E;")
if __name__ == "__main__":