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 12:09:21 +01:00
|
|
|
self.validThemeName = "test"
|
2016-12-08 11:52:47 +01:00
|
|
|
self.someWidget = MockWidget("foo")
|
2016-12-08 12:09:21 +01:00
|
|
|
self.theme = Theme(self.validThemeName)
|
|
|
|
|
|
|
|
self.widgetTheme = "test-widget"
|
|
|
|
self.defaultPrefix = "default-prefix"
|
|
|
|
self.defaultSuffix = "default-suffix"
|
|
|
|
self.widgetPrefix = "widget-prefix"
|
|
|
|
self.widgetSuffix = "widget-suffix"
|
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 12:09:21 +01:00
|
|
|
def test_default_prefix(self):
|
|
|
|
self.assertEquals(self.theme.prefix(self.someWidget), self.defaultPrefix)
|
|
|
|
|
|
|
|
def test_default_suffix(self):
|
|
|
|
self.assertEquals(self.theme.suffix(self.someWidget), self.defaultSuffix)
|
2016-12-08 11:52:47 +01:00
|
|
|
|
2016-12-08 12:09:21 +01:00
|
|
|
def test_widget_prefix(self):
|
|
|
|
self.someWidget.set_module(self.widgetTheme)
|
|
|
|
self.assertEquals(self.theme.prefix(self.someWidget), self.widgetPrefix)
|
2016-12-08 11:52:47 +01:00
|
|
|
|
2016-12-04 18:10:04 +01:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|