From ede63852249617b71a37887de9969a5022170e5e Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Thu, 29 Jun 2017 12:15:41 +1000 Subject: tests: Update tests to support the new json config files. --- tests/test_util.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'tests/test_util.py') diff --git a/tests/test_util.py b/tests/test_util.py index b1a396b..cf2b716 100755 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -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") -- cgit v1.2.3