summaryrefslogtreecommitdiff
path: root/tests/test_export.py
blob: 167d3edffc59b23967620f352aae1b8ac81057d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""Test export functions."""
import unittest
import pathlib

from pywal import export
from pywal import util


# Import colors.
COLORS = util.read_file_json("tests/test_files/test_file.json")


class TestExportColors(unittest.TestCase):
    """Test the export functions."""

    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")
        template_dir = pathlib.Path("tests/test_files/templates")
        export.export_all_templates(COLORS, template_dir, output_dir)

        result = pathlib.Path("/tmp/test_template").is_file()
        self.assertTrue(result)

        content = pathlib.Path("/tmp/test_template").read_text()
        self.assertEqual(content, '\n'.join(["test1 #1F211E",
                                             "test2 #1F211E",
                                             "test3 31,33,30", ""]))


if __name__ == "__main__":
    unittest.main()