From d8376eecc90b659f7b087ddd2ec0f29200ae6141 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sun, 23 Jul 2017 11:50:46 +1000 Subject: tests: Update tests. --- tests/test_export.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ tests/test_image.py | 2 +- tests/test_template.py | 44 -------------------------------------------- 3 files changed, 45 insertions(+), 45 deletions(-) create mode 100755 tests/test_export.py delete mode 100755 tests/test_template.py (limited to 'tests') diff --git a/tests/test_export.py b/tests/test_export.py new file mode 100755 index 0000000..ebf5740 --- /dev/null +++ b/tests/test_export.py @@ -0,0 +1,44 @@ +"""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") +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_all_templates(self): + """> Test substitutions in template file.""" + 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'") + + def test_css_template(self): + """> Test substitutions in template file (css).""" + export.color(COLORS, "css", OUTPUT_DIR / "test.css") + + result = pathlib.Path("/tmp/wal/test.css").is_file() + self.assertTrue(result) + + content = pathlib.Path("/tmp/wal/test.css").read_text() + content = content.split("\n")[6] + self.assertEqual(content, " --background: #1F211E;") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_image.py b/tests/test_image.py index da557a7..e0b7902 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -14,7 +14,7 @@ class TestImage(unittest.TestCase): def test_get_img_dir(self): """> Validate image directory.""" result = image.get("tests/test_files") - self.assertEqual(result, "tests/test_files/test2.jpg") + self.assertEqual(result.endswith(".jpg"), True) if __name__ == "__main__": diff --git a/tests/test_template.py b/tests/test_template.py deleted file mode 100755 index 14b1124..0000000 --- a/tests/test_template.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Test export functions.""" -import unittest -import pathlib - -from pywal import template -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_all_templates(self): - """> Test substitutions in template file.""" - template.export_all(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'") - - def test_css_template(self): - """> Test substitutions in template file (css).""" - template.export(COLORS, "colors.css", OUTPUT_DIR) - - result = pathlib.Path("/tmp/wal/colors.css").is_file() - self.assertTrue(result) - - content = pathlib.Path("/tmp/wal/colors.css").read_text() - content = content.split("\n")[6] - self.assertEqual(content, " --background: #1F211E;") - - -if __name__ == "__main__": - unittest.main() -- cgit v1.2.3