2016-12-08 09:44:05 +01:00
|
|
|
# pylint: disable=C0103,C0111,W0703
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
from bumblebee.theme import Theme
|
|
|
|
from bumblebee.error import ThemeLoadError
|
2016-12-08 11:52:47 +01:00
|
|
|
from tests.util import MockWidget
|
2016-12-08 09:44:05 +01:00
|
|
|
|
|
|
|
class TestTheme(unittest.TestCase):
|
|
|
|
def setUp(self):
|
2016-12-08 10:17:25 +01:00
|
|
|
self.nonexistentThemeName = "no-such-theme"
|
|
|
|
self.invalidThemeName = "invalid"
|
2016-12-08 11:52:47 +01:00
|
|
|
self.validThemeName = "solarized-powerline"
|
|
|
|
self.someWidget = MockWidget("foo")
|
2016-12-08 09:44:05 +01:00
|
|
|
|
|
|
|
def test_load_valid_theme(self):
|
|
|
|
try:
|
2016-12-08 11:52:47 +01:00
|
|
|
Theme(self.validThemeName)
|
2016-12-08 09:44:05 +01:00
|
|
|
except Exception as e:
|
|
|
|
self.fail(e)
|
|
|
|
|
|
|
|
def test_load_nonexistent_theme(self):
|
|
|
|
with self.assertRaises(ThemeLoadError):
|
2016-12-08 10:17:25 +01:00
|
|
|
Theme(self.nonexistentThemeName)
|
2016-12-08 09:44:05 +01:00
|
|
|
|
|
|
|
def test_load_invalid_theme(self):
|
|
|
|
with self.assertRaises(ThemeLoadError):
|
2016-12-08 10:17:25 +01:00
|
|
|
Theme(self.invalidThemeName)
|
2016-12-04 18:10:04 +01:00
|
|
|
|
2016-12-08 11:52:47 +01:00
|
|
|
def test_prefix(self):
|
|
|
|
theme = Theme(self.validThemeName)
|
|
|
|
theme.loads('{"defaults": { "prefix": "test" }}')
|
|
|
|
self.assertEquals(theme.prefix(self.someWidget), "test")
|
|
|
|
|
|
|
|
def test_suffix(self):
|
|
|
|
theme = Theme(self.validThemeName)
|
|
|
|
theme.loads('{"defaults": { "suffix": "test" }}')
|
|
|
|
self.assertEquals(theme.suffix(self.someWidget), "test")
|
|
|
|
|
2016-12-04 18:10:04 +01:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|