pywal/tests/test_template.py

37 lines
1.0 KiB
Python
Raw Normal View History

2017-06-27 09:46:55 +02:00
"""Test export functions."""
2017-06-27 09:02:42 +02:00
import unittest
import pathlib
2017-06-27 09:24:27 +02:00
2017-07-22 14:26:49 +02:00
from pywal import template
2017-06-27 09:02:42 +02:00
from pywal import util
2017-06-27 09:24:27 +02:00
# Import colors.
COLORS = util.read_file_json("tests/test_files/test_file.json")
2017-06-27 09:24:27 +02:00
2017-06-27 09:02:42 +02:00
class TestExportColors(unittest.TestCase):
"""Test the export functions."""
2017-06-27 09:02:42 +02:00
def test_template(self):
"""> Test substitutions in template file."""
# Merge both dicts so we can access their
# values simpler.
COLORS["colors"].update(COLORS["special"])
output_dir = pathlib.Path("/tmp")
2017-06-30 01:28:23 +02:00
template_dir = pathlib.Path("tests/test_files/templates")
2017-07-22 14:26:49 +02:00
template.export_all(COLORS, output_dir, template_dir)
result = pathlib.Path("/tmp/test_template").is_file()
2017-06-27 09:02:42 +02:00
self.assertTrue(result)
content = pathlib.Path("/tmp/test_template").read_text()
2017-07-09 15:57:53 +02:00
self.assertEqual(content, '\n'.join(["test1 #1F211E",
"test2 #1F211E",
"test3 31,33,30", ""]))
2017-06-27 09:02:42 +02:00
if __name__ == "__main__":
unittest.main()