blob: 9b9870d0cb1753eb723f08f4af9be072e88a12e3 (
plain) (
blame)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
"""Test export functions."""
import unittest
import pathlib
from pywal import template
from pywal import util
# Import colors.
COLORS = util.read_file_json("tests/test_files/test_file.json")
OUTPUT_DIR = pathlib.Path("/tmp/wal")
util.create_dir("/tmp/wal")
class TestExportColors(unittest.TestCase):
"""Test the export functions."""
def test_all_templates(self):
"""> Test substitutions in template file."""
# Merge both dicts so we can access their
# values simpler.
COLORS["colors"].update(COLORS["special"])
template.export_all(COLORS, OUTPUT_DIR)
result = pathlib.Path("/tmp/colors.sh").is_file()
self.assertTrue(result)
content = pathlib.Path("/tmp/colors.sh").read_text()
content = content.split("\n")[6]
self.assertEqual(content, "foreground='#F5F1F4'")
def test_css_template(self):
"""> Test substitutions in template file (css)."""
# Merge both dicts so we can access their
# values simpler.
COLORS["colors"].update(COLORS["special"])
template.export(COLORS, "colors.css", OUTPUT_DIR)
result = pathlib.Path("/tmp/colors.css").is_file()
self.assertTrue(result)
content = pathlib.Path("/tmp/colors.css").read_text()
content = content.split("\n")[6]
self.assertEqual(content, " --background: #1F211E;")
if __name__ == "__main__":
unittest.main()
|