diff options
| author | Dylan Araps <dylanaraps@users.noreply.github.com> | 2017-07-23 15:37:14 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-23 15:37:14 +1000 |
| commit | 0c1d76e2b3611b541316dc8d7eb67f18cec5e7f2 (patch) | |
| tree | aaf8141c62789dcfc4f72af24ae96df71459a084 /tests | |
| parent | 9c871ec567504c2566c4ce9f3d382f544cb62b57 (diff) | |
| parent | 07b8ad8e0d97f54277c2e744f745ba3e47d0e53c (diff) | |
Merge pull request #52 from dylanaraps/api
api: Start work on a proper api.
Diffstat (limited to 'tests')
| -rwxr-xr-x[-rw-r--r--] | tests/test_colors.py | 20 | ||||
| -rwxr-xr-x | tests/test_export.py | 32 | ||||
| -rw-r--r-- | tests/test_files/templates/test_template | 3 | ||||
| l--------- | tests/test_files/test2.jpg | 1 | ||||
| -rw-r--r-- | tests/test_image.py | 21 | ||||
| -rwxr-xr-x | tests/test_magic.py | 17 |
6 files changed, 50 insertions, 44 deletions
diff --git a/tests/test_colors.py b/tests/test_colors.py index 077600e..e83c54d 100644..100755 --- a/tests/test_colors.py +++ b/tests/test_colors.py @@ -1,20 +1,16 @@ -"""Test image functions.""" +"""Test imagemagick functions.""" import unittest -from pywal import image +from pywal import colors -class TestImage(unittest.TestCase): - """Test image functions.""" - def test_get_img(self): - """> Validate image file.""" - result = image.get_image("tests/test_files/test.jpg") - self.assertEqual(result, "tests/test_files/test.jpg") +class TestGenColors(unittest.TestCase): + """Test the gen_colors functions.""" - def test_get_img_dir(self): - """> Validate image directory.""" - result = image.get_image("tests/test_files") - self.assertEqual(result, "tests/test_files/test.jpg") + def test_gen_colors(self): + """> Generate a colorscheme.""" + result = colors.get("tests/test_files/test.jpg") + self.assertEqual(result["colors"]["color0"], "#0F191A") if __name__ == "__main__": 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__": 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_files/test2.jpg b/tests/test_files/test2.jpg new file mode 120000 index 0000000..0e8c5b6 --- /dev/null +++ b/tests/test_files/test2.jpg @@ -0,0 +1 @@ +test.jpg
\ No newline at end of file diff --git a/tests/test_image.py b/tests/test_image.py new file mode 100644 index 0000000..e0b7902 --- /dev/null +++ b/tests/test_image.py @@ -0,0 +1,21 @@ +"""Test image functions.""" +import unittest + +from pywal import image + + +class TestImage(unittest.TestCase): + """Test image functions.""" + def test_get_img(self): + """> Validate image file.""" + result = image.get("tests/test_files/test.jpg") + self.assertEqual(result, "tests/test_files/test.jpg") + + def test_get_img_dir(self): + """> Validate image directory.""" + result = image.get("tests/test_files") + self.assertEqual(result.endswith(".jpg"), True) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_magic.py b/tests/test_magic.py deleted file mode 100755 index 673420c..0000000 --- a/tests/test_magic.py +++ /dev/null @@ -1,17 +0,0 @@ -"""Test imagemagick functions.""" -import unittest - -from pywal import magic - - -class TestGenColors(unittest.TestCase): - """Test the gen_colors functions.""" - - def test_gen_colors(self): - """> Generate a colorscheme.""" - result = magic.gen_colors("tests/test_files/test.jpg") - self.assertEqual(result[0], "#0F191A") - - -if __name__ == "__main__": - unittest.main() |
