summaryrefslogtreecommitdiff
path: root/tests/test_main.py
blob: 196e3cf3a339ada68bc29e05a8b38ed45ab6606c (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
37
38
39
40
41
42
43
"""Test __main__ functions."""
import unittest
import unittest.mock

from pywal import __main__
from pywal import reload
from pywal import wallpaper
from pywal import util
from pywal.settings import CACHE_DIR


class TestMain(unittest.TestCase):
    """Test the gen_colors functions."""

    def test_args_a(self):
        """> Test arg parsing (-a)."""
        args = __main__.get_args(["-a", "50"])
        __main__.process_args(args)
        self.assertEqual(util.Color.alpha_num, "50")

    def test_args_c(self):
        """> Test arg parsing (-c)."""
        args = __main__.get_args(["-c"])
        __main__.process_args(args)
        self.assertFalse((CACHE_DIR / "schemes").is_dir())

    def test_args_e(self):
        """> Test arg parsing (-e)."""
        reload.env = unittest.mock.MagicMock()
        args = __main__.get_args(["-e"])
        __main__.process_args(args)
        self.assertFalse(reload.env.called)

    def test_args_n(self):
        """> Test arg parsing (-n)."""
        wallpaper.change = unittest.mock.MagicMock()
        args = __main__.get_args(["-n"])
        __main__.process_args(args)
        self.assertFalse(wallpaper.change.called)


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