~x23team/moovida/redtube-plugin

« back to all changes in this revision

Viewing changes to elisa-core/elisa/core/tests/test_player_engine_registry.py

  • Committer: Florian Boucault
  • Date: 2008-09-23 11:59:57 UTC
  • mfrom: (59.12.4 player_removal)
  • Revision ID: kaleo@samantha-20080923115957-zlal0ziz05qdfefa
Removed all references to old, deprecated player infrastructure as well as
player plugin.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
# Elisa - Home multimedia server
3
 
# Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com).
4
 
# All rights reserved.
5
 
#
6
 
# This file is available under one of two license agreements.
7
 
#
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.
11
 
#
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.
16
 
 
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
21
 
 
22
 
class FooEngine(player_engine.PlayerEngine):
23
 
    uri_schemes = {'foo' : 150, 'test' : 100, 'test2' : 50 }
24
 
 
25
 
class BarEngine(player_engine.PlayerEngine):
26
 
    uri_schemes = {'bar' : 150, 'test' : 50, 'test2' : 100 }
27
 
 
28
 
class GooEngine(player_engine.PlayerEngine):
29
 
    uri_schemes = {'goo' : 150}
30
 
 
31
 
class FooPlugin(plugin.Plugin):
32
 
    name = 'foo'
33
 
    components = {'foo_eng': {'path':FooEngine},
34
 
                  'goo_eng': {'path':GooEngine}
35
 
                  }
36
 
 
37
 
class BarPlugin(plugin.Plugin):
38
 
    name = 'bar'
39
 
    components = {'bar_eng': {'path':BarEngine}}
40
 
 
41
 
 
42
 
class TestPlayerEngineRegistry(ElisaTestCase):
43
 
 
44
 
    def setUp(self):
45
 
        ElisaTestCase.setUp(self)
46
 
 
47
 
        # Silly
48
 
        from elisa.core.common import application
49
 
        registry = application.plugin_registry
50
 
        registry.register_plugin(FooPlugin)
51
 
        registry.register_plugin(BarPlugin)
52
 
 
53
 
        application.config.set_option('player_engines', 
54
 
                ['bar:bar_eng', 'foo:foo_eng', 'foo:goo_eng'])
55
 
 
56
 
        self._en_reg = player_engine_registry.PlayerEngineRegistry()
57
 
        self._en_reg.initialize()
58
 
   
59
 
    def test_engine_creating(self):
60
 
        plug_reg = common.application.plugin_registry
61
 
 
62
 
        test = self._en_reg.create_engine_for_scheme('test')
63
 
        self.assertEquals(type(test),
64
 
                        plug_reg.get_component_class('bar:bar_eng'))
65
 
 
66
 
 
67
 
        try:
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)
72
 
            
73
 
        test2 = self._en_reg.create_engine_for_scheme('test2')
74
 
        self.assertEquals(type(test2),
75
 
                        plug_reg.get_component_class('foo:foo_eng'))
76
 
 
77
 
        goo = self._en_reg.create_engine_for_scheme('goo')
78
 
        self.assertEquals(type(goo),
79
 
                        plug_reg.get_component_class('foo:goo_eng'))
80