diff options
| author | Dylan Araps <dylan.araps@gmail.com> | 2017-06-29 12:15:41 +1000 |
|---|---|---|
| committer | Dylan Araps <dylan.araps@gmail.com> | 2017-06-29 12:15:41 +1000 |
| commit | ede63852249617b71a37887de9969a5022170e5e (patch) | |
| tree | ebabee7964521503bb0457280075ede6208009bc /tests/test_util.py | |
| parent | dc8b30218018d190bdee3678b14e721148d691ba (diff) | |
tests: Update tests to support the new json config files.
Diffstat (limited to 'tests/test_util.py')
| -rwxr-xr-x | tests/test_util.py | 24 |
1 files changed, 20 insertions, 4 deletions
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") |
