2016-12-04 08:02:40 +01:00
|
|
|
# pylint: disable=C0103,C0111
|
2016-12-17 08:42:23 +01:00
|
|
|
|
2016-11-05 07:54:16 +01:00
|
|
|
import unittest
|
2016-12-17 08:42:23 +01:00
|
|
|
import mock
|
|
|
|
try:
|
|
|
|
from StringIO import StringIO
|
|
|
|
except ImportError:
|
|
|
|
from io import StringIO
|
2016-11-05 07:54:16 +01:00
|
|
|
|
2016-12-03 20:38:54 +01:00
|
|
|
from bumblebee.config import Config
|
2016-12-17 08:42:23 +01:00
|
|
|
from bumblebee.theme import themes
|
|
|
|
from bumblebee.engine import all_modules
|
2016-11-05 07:54:16 +01:00
|
|
|
|
2016-12-03 20:38:54 +01:00
|
|
|
class TestConfig(unittest.TestCase):
|
2016-11-05 07:54:16 +01:00
|
|
|
def setUp(self):
|
2016-12-03 20:38:54 +01:00
|
|
|
self.defaultConfig = Config()
|
2016-12-04 08:02:40 +01:00
|
|
|
self.someSimpleModules = ["foo", "bar", "baz"]
|
|
|
|
self.someAliasModules = ["foo:a", "bar:b", "baz:c"]
|
2016-12-03 20:54:57 +01:00
|
|
|
|
2016-12-03 20:38:54 +01:00
|
|
|
def test_no_modules_by_default(self):
|
|
|
|
self.assertEquals(self.defaultConfig.modules(), [])
|
|
|
|
|
2016-12-04 08:25:11 +01:00
|
|
|
def test_simple_modules(self):
|
2016-12-04 08:02:40 +01:00
|
|
|
cfg = Config(["-m"] + self.someSimpleModules)
|
|
|
|
self.assertEquals(cfg.modules(), [{
|
2016-12-03 20:54:57 +01:00
|
|
|
"name": x, "module": x
|
2016-12-04 08:02:40 +01:00
|
|
|
} for x in self.someSimpleModules])
|
2016-12-03 20:54:57 +01:00
|
|
|
|
2016-12-04 08:25:11 +01:00
|
|
|
def test_alias_modules(self):
|
2016-12-04 08:02:40 +01:00
|
|
|
cfg = Config(["-m"] + self.someAliasModules)
|
|
|
|
self.assertEquals(cfg.modules(), [{
|
2016-12-03 20:54:57 +01:00
|
|
|
"module": x.split(":")[0],
|
2016-12-04 08:02:40 +01:00
|
|
|
"name": x.split(":")[1],
|
|
|
|
} for x in self.someAliasModules])
|
2016-11-05 07:54:16 +01:00
|
|
|
|
2016-12-17 08:42:23 +01:00
|
|
|
@mock.patch("sys.stdout", new_callable=StringIO)
|
|
|
|
@mock.patch("sys.exit")
|
|
|
|
def test_list_themes(self, exit, stdout):
|
|
|
|
cfg = Config(["-l", "themes"])
|
|
|
|
result = stdout.getvalue()
|
|
|
|
for theme in themes():
|
|
|
|
self.assertTrue(theme in result)
|
|
|
|
|
|
|
|
@mock.patch("sys.stdout", new_callable=StringIO)
|
|
|
|
@mock.patch("sys.exit")
|
|
|
|
def test_list_modules(self, exit, stdout):
|
|
|
|
cfg = Config(["-l", "modules"])
|
|
|
|
result = stdout.getvalue()
|
|
|
|
for module in all_modules():
|
|
|
|
self.assertTrue(module["name"] in result)
|
|
|
|
|
2016-11-05 07:54:16 +01:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|