[tests/engine] Add test for module aliasing
This commit is contained in:
parent
6a14681a65
commit
90dd636b43
2 changed files with 10 additions and 1 deletions
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
import bumblebee.engine
|
import bumblebee.engine
|
||||||
|
|
||||||
|
ALIASES = [ "test-alias" ]
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(bumblebee.engine.Module):
|
||||||
def __init__(self, engine, config):
|
def __init__(self, engine, config):
|
||||||
super(Module, self).__init__(engine, config,
|
super(Module, self).__init__(engine, config,
|
||||||
|
|
|
@ -13,8 +13,10 @@ from mocks import MockOutput, MockInput
|
||||||
class TestEngine(unittest.TestCase):
|
class TestEngine(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.engine = Engine(config=Config(), output=MockOutput(), inp=MockInput())
|
self.engine = Engine(config=Config(), output=MockOutput(), inp=MockInput())
|
||||||
self.singleWidgetModule = [{"module": "test", "name": "a"}]
|
|
||||||
self.testModule = "test"
|
self.testModule = "test"
|
||||||
|
self.testAlias = "test-alias"
|
||||||
|
self.singleWidgetModule = [{"module": self.testModule, "name": "a"}]
|
||||||
|
self.singleWidgetAlias = [{"module": self.testAlias, "name": "a" }]
|
||||||
self.invalidModule = "no-such-module"
|
self.invalidModule = "no-such-module"
|
||||||
self.testModuleSpec = "bumblebee.modules.{}".format(self.testModule)
|
self.testModuleSpec = "bumblebee.modules.{}".format(self.testModule)
|
||||||
self.testModules = [
|
self.testModules = [
|
||||||
|
@ -54,6 +56,11 @@ class TestEngine(unittest.TestCase):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.fail(e)
|
self.fail(e)
|
||||||
|
|
||||||
|
def test_aliases(self):
|
||||||
|
modules = self.engine.load_modules(self.singleWidgetAlias)
|
||||||
|
self.assertEquals(len(modules), 1)
|
||||||
|
self.assertEquals(modules[0].__module__, self.testModuleSpec)
|
||||||
|
|
||||||
def test_custom_cmd(self):
|
def test_custom_cmd(self):
|
||||||
testmodules = [
|
testmodules = [
|
||||||
{ "name": "test", "button": "test.left-click", "action": "echo" },
|
{ "name": "test", "button": "test.left-click", "action": "echo" },
|
||||||
|
|
Loading…
Reference in a new issue