mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-09 15:38:30 +01:00
tests: Update tests to support the new json config files.
This commit is contained in:
parent
dc8b302180
commit
ede6385224
@ -7,7 +7,7 @@ from pywal import util
|
||||
|
||||
|
||||
# Import colors.
|
||||
COLORS = util.read_file("tests/test_files/test_file")
|
||||
COLORS = util.read_file_json("tests/test_files/test_file.json")
|
||||
|
||||
|
||||
class TestExportColors(unittest.TestCase):
|
||||
@ -15,7 +15,7 @@ class TestExportColors(unittest.TestCase):
|
||||
|
||||
def test_save_colors(self):
|
||||
"""> Export colors to a file."""
|
||||
tmp_file = pathlib.Path("/tmp/test_file")
|
||||
tmp_file = pathlib.Path("/tmp/test_file.json")
|
||||
export_colors.save_colors(COLORS, tmp_file, "plain colors")
|
||||
result = tmp_file.is_file()
|
||||
self.assertTrue(result)
|
||||
|
@ -1,16 +1 @@
|
||||
#363442
|
||||
#99A3B1
|
||||
#C5BDB6
|
||||
#98AEC2
|
||||
#A8B9C6
|
||||
#96C4CF
|
||||
#B7C5CC
|
||||
#C9CFD0
|
||||
#999999
|
||||
#99A3B1
|
||||
#C5BDB6
|
||||
#98AEC2
|
||||
#A8B9C6
|
||||
#96C4CF
|
||||
#B7C5CC
|
||||
#C9CFD0
|
||||
/home/dylan/Pictures/Wallpapers/1.jpg
|
||||
|
26
tests/test_files/test_file.json
Normal file
26
tests/test_files/test_file.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"special": {
|
||||
"background":"#3A5130",
|
||||
"foreground":"#FAF9F5",
|
||||
"cursor":"#FAF9F5"
|
||||
},
|
||||
|
||||
"colors": {
|
||||
"color0":"#3A5130",
|
||||
"color1":"#E3A19D",
|
||||
"color2":"#E1CEAE",
|
||||
"color3":"#D6DDCC",
|
||||
"color4":"#F1D2CB",
|
||||
"color5":"#F5E9D6",
|
||||
"color6":"#F9F0E5",
|
||||
"color7":"#FAF9F5",
|
||||
"color8":"#999999",
|
||||
"color9":"#E3A19D",
|
||||
"color10":"#E1CEAE",
|
||||
"color11":"#D6DDCC",
|
||||
"color12":"#F1D2CB",
|
||||
"color13":"#F5E9D6",
|
||||
"color14":"#F9F0E5",
|
||||
"color15":"#FAF9F5"
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ from pywal import util
|
||||
|
||||
|
||||
# Import colors.
|
||||
COLORS = util.read_file("tests/test_files/test_file")
|
||||
COLORS = util.read_file_json("tests/test_files/test_file.json")
|
||||
|
||||
|
||||
class TestFormatColors(unittest.TestCase):
|
||||
@ -15,32 +15,32 @@ class TestFormatColors(unittest.TestCase):
|
||||
def test_plain(self):
|
||||
"""> Convert colors to plain."""
|
||||
result = format_colors.plain(COLORS)
|
||||
self.assertEqual(result[0], "#363442\n")
|
||||
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='#363442'\n")
|
||||
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: #363442;\n")
|
||||
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: #363442;\n")
|
||||
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\"=\"54,52,66\"\n")
|
||||
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: #363442\n*color0: #363442\n")
|
||||
self.assertEqual(result[6], "*.color0: #3A5130\n*color0: #3A5130\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -6,7 +6,7 @@ from pywal import util
|
||||
|
||||
|
||||
# Import colors.
|
||||
COLORS = util.read_file("tests/test_files/test_file")
|
||||
COLORS = util.read_file_json("tests/test_files/test_file.json")
|
||||
|
||||
|
||||
class TestSetColors(unittest.TestCase):
|
||||
@ -14,17 +14,18 @@ class TestSetColors(unittest.TestCase):
|
||||
|
||||
def test_set_special(self):
|
||||
"""> Create special escape sequence."""
|
||||
result = set_colors.set_special(11, COLORS[0])
|
||||
self.assertEqual(result, "\x1b]11;#363442\x07")
|
||||
result = set_colors.set_special(11, COLORS["special"]["background"])
|
||||
self.assertEqual(result, "\x1b]11;#3A5130\x07")
|
||||
|
||||
def test_set_color(self):
|
||||
"""> Create color escape sequence."""
|
||||
result = set_colors.set_color(11, COLORS[0])
|
||||
self.assertEqual(result, "\033]4;11;#363442\007")
|
||||
result = set_colors.set_color(11, COLORS["colors"]["color0"])
|
||||
self.assertEqual(result, "\033]4;11;#3A5130\007")
|
||||
|
||||
def test_set_grey(self):
|
||||
"""> Create special escape sequence."""
|
||||
result = set_colors.set_grey(COLORS)
|
||||
colors = [list(COLORS["colors"].values())]
|
||||
result = set_colors.set_grey(colors[0])
|
||||
self.assertEqual(result, "#999999")
|
||||
|
||||
|
||||
|
@ -5,18 +5,27 @@ import pathlib
|
||||
from pywal import util
|
||||
|
||||
|
||||
# Import colors.
|
||||
COLORS = util.read_file_json("tests/test_files/test_file.json")
|
||||
|
||||
|
||||
class TestUtil(unittest.TestCase):
|
||||
"""Test the util functions."""
|
||||
|
||||
def test_read_file_start(self):
|
||||
def test_read_file(self):
|
||||
"""> Read colors from a file."""
|
||||
result = util.read_file("tests/test_files/test_file")
|
||||
self.assertEqual(result[0], "#363442")
|
||||
self.assertEqual(result[0], "/home/dylan/Pictures/Wallpapers/1.jpg")
|
||||
|
||||
def test_read_file_start(self):
|
||||
"""> Read colors from a file."""
|
||||
result = util.read_file_json("tests/test_files/test_file.json")
|
||||
self.assertEqual(result["colors"]["color0"], "#3A5130")
|
||||
|
||||
def test_read_file_end(self):
|
||||
"""> Read colors from a file."""
|
||||
result = util.read_file("tests/test_files/test_file")
|
||||
self.assertEqual(result[15], "#C9CFD0")
|
||||
result = util.read_file_json("tests/test_files/test_file.json")
|
||||
self.assertEqual(result["colors"]["color15"], "#FAF9F5")
|
||||
|
||||
def test_save_file(self):
|
||||
"""> Save colors to a file."""
|
||||
@ -25,6 +34,13 @@ class TestUtil(unittest.TestCase):
|
||||
result = tmp_file.is_file()
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_save_file_json(self):
|
||||
"""> Save colors to a file."""
|
||||
tmp_file = pathlib.Path("/tmp/test_file.json")
|
||||
util.save_file_json(COLORS, tmp_file)
|
||||
result = tmp_file.is_file()
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_create_dir(self):
|
||||
"""> Create a directoru."""
|
||||
tmp_dir = pathlib.Path("/tmp/test_dir")
|
||||
|
Loading…
Reference in New Issue
Block a user