pywal/tests/test_main.py

47 lines
1.3 KiB
Python
Raw Normal View History

2017-07-23 14:31:20 +02:00
"""Test __main__ functions."""
import unittest
2017-08-12 04:30:21 +02:00
import unittest.mock
2017-07-23 15:31:16 +02:00
import os
2017-08-03 07:10:42 +02:00
from pywal import __main__
from pywal import reload
2017-08-12 04:30:21 +02:00
from pywal import wallpaper
from pywal import util
2017-07-24 14:29:20 +02:00
from pywal.settings import CACHE_DIR
2017-07-23 14:31:20 +02:00
class TestMain(unittest.TestCase):
"""Test the gen_colors functions."""
2017-08-12 04:30:21 +02:00
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)."""
2017-07-23 15:31:16 +02:00
args = __main__.get_args(["-c"])
__main__.process_args(args)
2017-08-10 01:17:11 +02:00
scheme_dir = os.path.join(CACHE_DIR, "schemes")
self.assertFalse(os.path.isdir(scheme_dir))
2017-07-23 15:31:16 +02:00
2017-08-03 07:01:21 +02:00
def test_args_e(self):
2017-08-12 04:30:21 +02:00
"""> Test arg parsing (-e)."""
reload.env = unittest.mock.MagicMock()
2017-08-03 07:01:21 +02:00
args = __main__.get_args(["-e"])
__main__.process_args(args)
2017-08-03 07:09:03 +02:00
self.assertFalse(reload.env.called)
2017-08-12 04:30:21 +02:00
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)
2017-07-23 14:33:43 +02:00
2017-07-23 14:31:20 +02:00
if __name__ == "__main__":
unittest.main()