diff --git a/tests/test_colors.py b/tests/test_colors.py index 0946585..ca1858e 100755 --- a/tests/test_colors.py +++ b/tests/test_colors.py @@ -1,4 +1,5 @@ """Test imagemagick functions.""" + import unittest from pywal import colors @@ -27,6 +28,16 @@ def test_color_import_no_alpha(self): result = colors.file("tests/test_files/test_file2.json") self.assertEqual(result["alpha"], "100") + def test_color_import_no_checkum(self): + """> Read checksum from a file with no checksum""" + result = colors.file("tests/test_files/test_file.json") + self.assertEqual(result["checksum"], "None") + + def test_gen_colors_checksum(self): + """> Generate a colorscheme with the wallpaper's checksum""" + result = colors.get("tests/test_files/test.jpg") + self.assertEqual(len(result["checksum"]), 32) + if __name__ == "__main__": unittest.main() diff --git a/tests/test_files/test_file3.json b/tests/test_files/test_file3.json new file mode 100644 index 0000000..bbfc10b --- /dev/null +++ b/tests/test_files/test_file3.json @@ -0,0 +1,29 @@ +{ + "checksum": "8e21a704294404a9084375f1761aaa51", + "wallpaper": "5.png", + "alpha": "100", + + "special": { + "background": "#1F211E", + "foreground": "#F5F1F4", + "cursor": "#F5F1F4" + }, + "colors": { + "color0": "#1F211E", + "color1": "#4B7A85", + "color2": "#CC6A93", + "color3": "#5C9894", + "color4": "#A0A89B", + "color5": "#D1B9A9", + "color6": "#E3D6D8", + "color7": "#F5F1F4", + "color8": "#666666", + "color9": "#4B7A85", + "color10": "#CC6A93", + "color11": "#5C9894", + "color12": "#A0A89B", + "color13": "#D1B9A9", + "color14": "#E3D6D8", + "color15": "#F5F1F4" + } +} diff --git a/tests/test_util.py b/tests/test_util.py index 79b6b96..ed03149 100755 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,4 +1,5 @@ """Test util functions.""" + import unittest import os @@ -88,6 +89,11 @@ def test_lighten_color(self): result = util.lighten_color("#000000", 0.25) self.assertEqual(result, "#3f3f3f") + def test_gen_color_checksum(self): + """> Generate checksum from image file""" + result = util.get_img_checksum("tests/test_files/test.jpg") + self.assertEqual(result, "8e21a704294404a9084375f1761aaa51") + if __name__ == "__main__": unittest.main()