1
# -*- coding: utf-8 -*-
2
# Elisa - Home multimedia server
3
# Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com).
6
# This file is available under one of two license agreements.
8
# This file is licensed under the GPL version 3.
9
# See "LICENSE.GPL" in the root of this distribution including a special
10
# exception to use Elisa with Fluendo's plugins.
12
# The GPL part of Elisa is also available under a commercial licensing
13
# agreement from Fluendo.
14
# See "LICENSE.Elisa" in the root directory of this distribution package
15
# for details on that license.
17
from twisted.trial import unittest
18
from elisa.core.tests.elisa_test_case import ElisaTestCase
19
from elisa.core import common, player_engine_registry, plugin
20
from elisa.core.components import player_engine
22
class FooEngine(player_engine.PlayerEngine):
23
uri_schemes = {'foo' : 150, 'test' : 100, 'test2' : 50 }
25
class BarEngine(player_engine.PlayerEngine):
26
uri_schemes = {'bar' : 150, 'test' : 50, 'test2' : 100 }
28
class GooEngine(player_engine.PlayerEngine):
29
uri_schemes = {'goo' : 150}
31
class FooPlugin(plugin.Plugin):
33
components = {'foo_eng': {'path':FooEngine},
34
'goo_eng': {'path':GooEngine}
37
class BarPlugin(plugin.Plugin):
39
components = {'bar_eng': {'path':BarEngine}}
42
class TestPlayerEngineRegistry(ElisaTestCase):
45
ElisaTestCase.setUp(self)
48
from elisa.core.common import application
49
registry = application.plugin_registry
50
registry.register_plugin(FooPlugin)
51
registry.register_plugin(BarPlugin)
53
application.config.set_option('player_engines',
54
['bar:bar_eng', 'foo:foo_eng', 'foo:goo_eng'])
56
self._en_reg = player_engine_registry.PlayerEngineRegistry()
57
self._en_reg.initialize()
59
def test_engine_creating(self):
60
plug_reg = common.application.plugin_registry
62
test = self._en_reg.create_engine_for_scheme('test')
63
self.assertEquals(type(test),
64
plug_reg.get_component_class('bar:bar_eng'))
68
bad = self._en_reg.create_engine_for_scheme('this_scheme_does_not_exist!')
69
self.assertFalse(True)
70
except player_engine_registry.NoEngineFound:
71
self.assertFalse(False)
73
test2 = self._en_reg.create_engine_for_scheme('test2')
74
self.assertEquals(type(test2),
75
plug_reg.get_component_class('foo:foo_eng'))
77
goo = self._en_reg.create_engine_for_scheme('goo')
78
self.assertEquals(type(goo),
79
plug_reg.get_component_class('foo:goo_eng'))