summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2017-06-29 19:52:43 +1000
committerDylan Araps <dylan.araps@gmail.com>2017-06-29 19:52:43 +1000
commit5e5908a01360ba36bd1c7ab3223dfef3dfedd02a (patch)
tree142f53d798ad123707acc564cb05e373be33ea60 /tests
parent4ec8c16d0afce5ae9245eec25ca234ba11841df1 (diff)
export: Make function more general for the test.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_export_colors.py17
-rw-r--r--tests/test_files/test_template2
-rwxr-xr-xtests/test_format_colors.py47
3 files changed, 14 insertions, 52 deletions
diff --git a/tests/test_export_colors.py b/tests/test_export_colors.py
index 7cee594..90af273 100755
--- a/tests/test_export_colors.py
+++ b/tests/test_export_colors.py
@@ -13,11 +13,18 @@ COLORS = util.read_file_json("tests/test_files/test_file.json")
class TestExportColors(unittest.TestCase):
"""Test the export_colors functions."""
- def test_save_colors(self):
- """> Export colors to a file."""
- tmp_file = pathlib.Path("/tmp/test_file.json")
- export_colors.save_colors(COLORS, tmp_file, "plain colors")
- result = tmp_file.is_file()
+ def test_template(self):
+ """> Test substitutions in template file."""
+ # Merge both dicts so we can access their
+ # values simpler.
+ COLORS["colors"].update(COLORS["special"])
+
+ # Dirs to use.
+ tmp_dir = pathlib.Path("/tmp")
+ test_template = pathlib.Path("tests/test_files/test_template")
+ export_colors.template(COLORS["colors"], test_template, tmp_dir)
+
+ result = pathlib.Path("/tmp/test_template").is_file()
self.assertTrue(result)
diff --git a/tests/test_files/test_template b/tests/test_files/test_template
new file mode 100644
index 0000000..167e17b
--- /dev/null
+++ b/tests/test_files/test_template
@@ -0,0 +1,2 @@
+test {color0}
+test {background}
diff --git a/tests/test_format_colors.py b/tests/test_format_colors.py
deleted file mode 100755
index 732f67b..0000000
--- a/tests/test_format_colors.py
+++ /dev/null
@@ -1,47 +0,0 @@
-"""Test format functions."""
-import unittest
-
-from pywal import format_colors
-from pywal import util
-
-
-# Import colors.
-COLORS = util.read_file_json("tests/test_files/test_file.json")
-
-
-class TestFormatColors(unittest.TestCase):
- """Test the format_colors functions."""
-
- def test_plain(self):
- """> Convert colors to plain."""
- result = format_colors.plain(COLORS)
- self.assertEqual(result[0], "#3A5130\n")
-
- def test_shell(self):
- """> Convert colors to shell variables."""
- result = format_colors.shell(COLORS)
- self.assertEqual(result[0], "color0='#3A5130'\n")
-
- def test_css(self):
- """> Convert colors to css variables."""
- result = format_colors.css(COLORS)
- self.assertEqual(result[1], "\t--color0: #3A5130;\n")
-
- def test_scss(self):
- """> Convert colors to scss variables."""
- result = format_colors.scss(COLORS)
- self.assertEqual(result[0], "$color0: #3A5130;\n")
-
- def test_putty(self):
- """> Convert colors to putty theme."""
- result = format_colors.putty(COLORS)
- self.assertEqual(result[2], "\"colour0\"=\"58,81,48\"\n")
-
- def test_xrdb(self):
- """> Convert colors to putty theme."""
- result = format_colors.xrdb(COLORS)
- self.assertEqual(result[6], "*.color0: #3A5130\n*color0: #3A5130\n")
-
-
-if __name__ == "__main__":
- unittest.main()