From 4fd592b7d0a5fcf6674d07f34e6d92051634fc6c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 20 Jul 2017 23:39:19 +1000 Subject: tests: Fix tests. --- tests/test_colors.py | 21 --------------------- tests/test_image.py | 21 +++++++++++++++++++++ tests/test_magic.py | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 tests/test_colors.py create mode 100644 tests/test_image.py (limited to 'tests') diff --git a/tests/test_colors.py b/tests/test_colors.py deleted file mode 100644 index 077600e..0000000 --- a/tests/test_colors.py +++ /dev/null @@ -1,21 +0,0 @@ -"""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_image("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_image("tests/test_files") - self.assertEqual(result, "tests/test_files/test.jpg") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_image.py b/tests/test_image.py new file mode 100644 index 0000000..7dacecb --- /dev/null +++ b/tests/test_image.py @@ -0,0 +1,21 @@ +"""Test image functions.""" +import unittest + +from pywal import wal + + +class TestImage(unittest.TestCase): + """Test image functions.""" + def test_get_img(self): + """> Validate image file.""" + result = wal.get_image("tests/test_files/test.jpg") + self.assertEqual(result, "tests/test_files/test.jpg") + + def test_get_img_dir(self): + """> Validate image directory.""" + result = wal.get_image("tests/test_files") + self.assertEqual(result, "tests/test_files/test.jpg") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_magic.py b/tests/test_magic.py index 673420c..852f8b3 100755 --- a/tests/test_magic.py +++ b/tests/test_magic.py @@ -1,7 +1,7 @@ """Test imagemagick functions.""" import unittest -from pywal import magic +from pywal import wal class TestGenColors(unittest.TestCase): @@ -9,7 +9,7 @@ class TestGenColors(unittest.TestCase): def test_gen_colors(self): """> Generate a colorscheme.""" - result = magic.gen_colors("tests/test_files/test.jpg") + result = wal.create_palette("tests/test_files/test.jpg") self.assertEqual(result[0], "#0F191A") -- cgit v1.2.3 From c8dd8f4d03fc79b5594e8d873e0aba77e360796a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 10:01:14 +1000 Subject: general: Fixes. --- tests/test_export.py | 36 ------------------------------------ tests/test_files/test2.jpg | 1 + tests/test_image.py | 2 +- tests/test_magic.py | 2 +- tests/test_template.py | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 38 deletions(-) delete mode 100755 tests/test_export.py create mode 120000 tests/test_files/test2.jpg create mode 100755 tests/test_template.py (limited to 'tests') diff --git a/tests/test_export.py b/tests/test_export.py deleted file mode 100755 index 167d3ed..0000000 --- a/tests/test_export.py +++ /dev/null @@ -1,36 +0,0 @@ -"""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 #1F211E", - "test2 #1F211E", - "test3 31,33,30", ""])) - - -if __name__ == "__main__": - unittest.main() 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 index 7dacecb..bcf3b4d 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 = wal.get_image("tests/test_files") - self.assertEqual(result, "tests/test_files/test.jpg") + self.assertEqual(result, "tests/test_files/test2.jpg") if __name__ == "__main__": diff --git a/tests/test_magic.py b/tests/test_magic.py index 852f8b3..a3434df 100755 --- a/tests/test_magic.py +++ b/tests/test_magic.py @@ -10,7 +10,7 @@ class TestGenColors(unittest.TestCase): def test_gen_colors(self): """> Generate a colorscheme.""" result = wal.create_palette("tests/test_files/test.jpg") - self.assertEqual(result[0], "#0F191A") + self.assertEqual(result["colors"]["color0"], "#0F191A") if __name__ == "__main__": diff --git a/tests/test_template.py b/tests/test_template.py new file mode 100755 index 0000000..9040348 --- /dev/null +++ b/tests/test_template.py @@ -0,0 +1,36 @@ +"""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") + + +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") + template.export_all_templates(COLORS, output_dir, template_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 #1F211E", + "test2 #1F211E", + "test3 31,33,30", ""])) + + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3 From ccad5150e621067ef637104f9a20371bb4533ce8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 10:10:05 +1000 Subject: tests: Use wal functions. --- tests/test_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_template.py b/tests/test_template.py index 9040348..992c9c0 100755 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -2,7 +2,7 @@ import unittest import pathlib -from pywal import template +from pywal import wal from pywal import util @@ -21,7 +21,7 @@ class TestExportColors(unittest.TestCase): output_dir = pathlib.Path("/tmp") template_dir = pathlib.Path("tests/test_files/templates") - template.export_all_templates(COLORS, output_dir, template_dir) + wal.export_all_templates(COLORS, output_dir, template_dir) result = pathlib.Path("/tmp/test_template").is_file() self.assertTrue(result) -- cgit v1.2.3 From 3dd1fc9039822e4426d5dc8c3f807dd5f6f2d295 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 10:26:36 +1000 Subject: tests: Fix tests --- tests/test_files/test2.jpg | 1 - tests/test_image.py | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) delete mode 120000 tests/test_files/test2.jpg (limited to 'tests') diff --git a/tests/test_files/test2.jpg b/tests/test_files/test2.jpg deleted file mode 120000 index 0e8c5b6..0000000 --- a/tests/test_files/test2.jpg +++ /dev/null @@ -1 +0,0 @@ -test.jpg \ No newline at end of file diff --git a/tests/test_image.py b/tests/test_image.py index bcf3b4d..b9099f9 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -1,20 +1,24 @@ """Test image functions.""" +import pathlib import unittest from pywal import wal +DEVNULL = pathlib.Path("/dev/null") + + class TestImage(unittest.TestCase): """Test image functions.""" def test_get_img(self): """> Validate image file.""" - result = wal.get_image("tests/test_files/test.jpg") + result = wal.get_image("tests/test_files/test.jpg", DEVNULL) self.assertEqual(result, "tests/test_files/test.jpg") def test_get_img_dir(self): """> Validate image directory.""" - result = wal.get_image("tests/test_files") - self.assertEqual(result, "tests/test_files/test2.jpg") + result = wal.get_image("tests/test_files", DEVNULL) + self.assertEqual(result, "tests/test_files/test.jpg") if __name__ == "__main__": -- cgit v1.2.3 From 09f5d26e78e0a7ee89c778786d03c6120cbd2708 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 11:21:39 +1000 Subject: tests: Cover random image. --- tests/test_files/test2.jpg | 1 + tests/test_image.py | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 120000 tests/test_files/test2.jpg (limited to 'tests') 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 index b9099f9..95a357e 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -5,20 +5,20 @@ import unittest from pywal import wal -DEVNULL = pathlib.Path("/dev/null") +CACHE_DIR = pathlib.Path("/tmp/wal") class TestImage(unittest.TestCase): """Test image functions.""" def test_get_img(self): """> Validate image file.""" - result = wal.get_image("tests/test_files/test.jpg", DEVNULL) + result = wal.get_image("tests/test_files/test.jpg", CACHE_DIR) self.assertEqual(result, "tests/test_files/test.jpg") def test_get_img_dir(self): """> Validate image directory.""" - result = wal.get_image("tests/test_files", DEVNULL) - self.assertEqual(result, "tests/test_files/test.jpg") + result = wal.get_image("tests/test_files", CACHE_DIR) + self.assertEqual(result, "tests/test_files/test2.jpg") if __name__ == "__main__": -- cgit v1.2.3 From de47c1beaaa77ee6f50235daba735ccc98ad608c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 22:26:49 +1000 Subject: api: Remove wal.py --- tests/test_colors.py | 17 +++++++++++++++++ tests/test_image.py | 10 +++------- tests/test_magic.py | 17 ----------------- tests/test_template.py | 4 ++-- 4 files changed, 22 insertions(+), 26 deletions(-) create mode 100755 tests/test_colors.py delete mode 100755 tests/test_magic.py (limited to 'tests') diff --git a/tests/test_colors.py b/tests/test_colors.py new file mode 100755 index 0000000..e83c54d --- /dev/null +++ b/tests/test_colors.py @@ -0,0 +1,17 @@ +"""Test imagemagick functions.""" +import unittest + +from pywal import colors + + +class TestGenColors(unittest.TestCase): + """Test the gen_colors functions.""" + + 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__": + unittest.main() diff --git a/tests/test_image.py b/tests/test_image.py index 95a357e..da557a7 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -1,23 +1,19 @@ """Test image functions.""" -import pathlib import unittest -from pywal import wal - - -CACHE_DIR = pathlib.Path("/tmp/wal") +from pywal import image class TestImage(unittest.TestCase): """Test image functions.""" def test_get_img(self): """> Validate image file.""" - result = wal.get_image("tests/test_files/test.jpg", CACHE_DIR) + 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 = wal.get_image("tests/test_files", CACHE_DIR) + result = image.get("tests/test_files") self.assertEqual(result, "tests/test_files/test2.jpg") diff --git a/tests/test_magic.py b/tests/test_magic.py deleted file mode 100755 index a3434df..0000000 --- a/tests/test_magic.py +++ /dev/null @@ -1,17 +0,0 @@ -"""Test imagemagick functions.""" -import unittest - -from pywal import wal - - -class TestGenColors(unittest.TestCase): - """Test the gen_colors functions.""" - - def test_gen_colors(self): - """> Generate a colorscheme.""" - result = wal.create_palette("tests/test_files/test.jpg") - self.assertEqual(result["colors"]["color0"], "#0F191A") - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/test_template.py b/tests/test_template.py index 992c9c0..ef71b8b 100755 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -2,7 +2,7 @@ import unittest import pathlib -from pywal import wal +from pywal import template from pywal import util @@ -21,7 +21,7 @@ class TestExportColors(unittest.TestCase): output_dir = pathlib.Path("/tmp") template_dir = pathlib.Path("tests/test_files/templates") - wal.export_all_templates(COLORS, output_dir, template_dir) + template.export_all(COLORS, output_dir, template_dir) result = pathlib.Path("/tmp/test_template").is_file() self.assertTrue(result) -- cgit v1.2.3 From 676f5325e11cfc12d6080f6cdb27be2e697a88a8 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 23:48:47 +1000 Subject: tests: Add new template test. --- tests/test_files/templates/test_template | 3 --- tests/test_template.py | 33 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-) delete mode 100644 tests/test_files/templates/test_template (limited to 'tests') 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_template.py b/tests/test_template.py index ef71b8b..9b9870d 100755 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -8,28 +8,43 @@ from pywal import util # Import colors. COLORS = util.read_file_json("tests/test_files/test_file.json") +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"]) - output_dir = pathlib.Path("/tmp") - template_dir = pathlib.Path("tests/test_files/templates") - template.export_all(COLORS, output_dir, template_dir) + template.export_all(COLORS, OUTPUT_DIR) + + result = pathlib.Path("/tmp/colors.sh").is_file() + self.assertTrue(result) + + content = pathlib.Path("/tmp/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).""" + # Merge both dicts so we can access their + # values simpler. + COLORS["colors"].update(COLORS["special"]) + + template.export(COLORS, "colors.css", OUTPUT_DIR) - result = pathlib.Path("/tmp/test_template").is_file() + result = pathlib.Path("/tmp/colors.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/colors.css").read_text() + content = content.split("\n")[6] + self.assertEqual(content, " --background: #1F211E;") if __name__ == "__main__": -- cgit v1.2.3 From 7566104c85f0f0f277d917ccb7a14682b5d3630f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 23:50:40 +1000 Subject: tests: Add new template test. --- tests/test_template.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/test_template.py b/tests/test_template.py index 9b9870d..f1b7dc5 100755 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -8,6 +8,7 @@ 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") @@ -18,10 +19,6 @@ class TestExportColors(unittest.TestCase): 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"]) - template.export_all(COLORS, OUTPUT_DIR) result = pathlib.Path("/tmp/colors.sh").is_file() @@ -33,10 +30,6 @@ class TestExportColors(unittest.TestCase): def test_css_template(self): """> Test substitutions in template file (css).""" - # Merge both dicts so we can access their - # values simpler. - COLORS["colors"].update(COLORS["special"]) - template.export(COLORS, "colors.css", OUTPUT_DIR) result = pathlib.Path("/tmp/colors.css").is_file() -- cgit v1.2.3 From bd5611e35cba2cfa0a57f3f854ed157638da3c95 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 22 Jul 2017 23:57:18 +1000 Subject: tests: Fix tests --- tests/test_template.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test_template.py b/tests/test_template.py index f1b7dc5..14b1124 100755 --- a/tests/test_template.py +++ b/tests/test_template.py @@ -21,10 +21,10 @@ class TestExportColors(unittest.TestCase): """> Test substitutions in template file.""" template.export_all(COLORS, OUTPUT_DIR) - result = pathlib.Path("/tmp/colors.sh").is_file() + result = pathlib.Path("/tmp/wal/colors.sh").is_file() self.assertTrue(result) - content = pathlib.Path("/tmp/colors.sh").read_text() + content = pathlib.Path("/tmp/wal/colors.sh").read_text() content = content.split("\n")[6] self.assertEqual(content, "foreground='#F5F1F4'") @@ -32,10 +32,10 @@ class TestExportColors(unittest.TestCase): """> Test substitutions in template file (css).""" template.export(COLORS, "colors.css", OUTPUT_DIR) - result = pathlib.Path("/tmp/colors.css").is_file() + result = pathlib.Path("/tmp/wal/colors.css").is_file() self.assertTrue(result) - content = pathlib.Path("/tmp/colors.css").read_text() + content = pathlib.Path("/tmp/wal/colors.css").read_text() content = content.split("\n")[6] self.assertEqual(content, " --background: #1F211E;") -- cgit v1.2.3 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