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-06-30 01:54:10 +02:00
|
|
|
from pywal import export
|
2017-06-27 09:02:42 +02:00
|
|
|
from pywal import util
|
|
|
|
|
|
|
|
|
2017-06-27 09:24:27 +02:00
|
|
|
# Import colors.
|
2017-06-29 04:15:41 +02:00
|
|
|
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):
|
2017-06-30 01:54:10 +02:00
|
|
|
"""Test the export functions."""
|
2017-06-27 09:02:42 +02:00
|
|
|
|
2017-06-29 11:52:43 +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"])
|
|
|
|
|
2017-06-29 16:47:13 +02:00
|
|
|
output_dir = pathlib.Path("/tmp")
|
2017-06-30 01:28:23 +02:00
|
|
|
template_dir = pathlib.Path("tests/test_files/templates")
|
2017-06-30 01:54:10 +02:00
|
|
|
export.export_all_templates(COLORS, template_dir, output_dir)
|
2017-06-29 11:52:43 +02:00
|
|
|
|
|
|
|
result = pathlib.Path("/tmp/test_template").is_file()
|
2017-06-27 09:02:42 +02:00
|
|
|
self.assertTrue(result)
|
|
|
|
|
2017-06-29 16:47:13 +02:00
|
|
|
content = pathlib.Path("/tmp/test_template").read_text()
|
2017-06-30 01:28:23 +02:00
|
|
|
self.assertEqual(content, '\n'.join(["test1 #3A5130",
|
|
|
|
"test2 #3A5130",
|
|
|
|
"test3 58,81,48", ""]))
|
2017-06-29 16:47:13 +02:00
|
|
|
|
2017-06-27 09:02:42 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|