Skip to content

Commit

Permalink
Added checksum tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madstone0-0 authored and eylles committed Apr 10, 2024
1 parent 9ca5690 commit 29b7cf5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_colors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test imagemagick functions."""

import unittest

from pywal import colors
Expand Down Expand Up @@ -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()
29 changes: 29 additions & 0 deletions tests/test_files/test_file3.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
6 changes: 6 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Test util functions."""

import unittest
import os

Expand Down Expand Up @@ -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()

0 comments on commit 29b7cf5

Please sign in to comment.