Package elisa :: Package core :: Package tests :: Module test_plugin
[hide private]
[frames] | no frames]

Source Code for Module elisa.core.tests.test_plugin

  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 elisa.core.tests.elisa_test_case import ElisaTestCase 
 18  import platform 
 19  from elisa.core import plugin, component 
 20   
 21  from elisa.extern.translation import gettexter, Translator 
 22   
23 -class TestAPlugin(plugin.Plugin):
24 name = "test" 25 config_file = "data/test_plugin.conf"
26
27 -class TestPlugin(ElisaTestCase):
28
29 - def test_instanciation(self):
30 """ 31 """ 32 TestAPlugin.load_config() 33 TestAPlugin.initialize() 34 t = TestAPlugin() 35 self.failUnless(t)
36
37 - def test_platform(self):
38 39 platfrm = platform.system().lower() 40 if platfrm == 'linux': 41 other_platform = 'windows' 42 elif platfrm == 'windows': 43 other_platform = 'linux' 44 else: 45 other_platform = 'linux' 46 47 components = {'foo_component': {'path': 'elisa.core.tests.test_component:FooComponent', 48 'description': 'To access file:// media', 49 'name': 'foo_component', 50 'platforms': [other_platform,]}} 51 52 TestAPlugin.load_config() 53 # override components 54 TestAPlugin.components = components 55 56 self.assertRaises(component.UnSupportedPlatform, 57 TestAPlugin.check_component_dependencies, 58 'foo_component')
59
60 - def test_deps(self):
61 components = {'foo_component': {'path': 'elisa.core.tests.test_component:FooComponent', 62 'description': 'To access file:// media', 63 'name': 'foo_component', 64 'external_dependencies': ['elisarock',] 65 } 66 } 67 68 TestAPlugin.load_config() 69 # override components 70 TestAPlugin.components = components 71 72 self.assertRaises(component.UnMetDependency, 73 TestAPlugin.check_component_dependencies, 74 'foo_component')
75
76 - def test_i18n_loading(self):
77 translator = Translator() 78 TestAPlugin.load_config() 79 TestAPlugin.load_translations(translator) 80 81 T_ = gettexter('elisa-test') 82 83 artist = T_('By Artist') #deu3 84 album = T_('By Album') #deu 85 dvd = T_('DVD') # deu2 86 87 artist_t = translator.translateTranslatable(artist, ['deu3']) 88 album_t = translator.translateTranslatable(album, ['deu']) 89 dvd_t = translator.translateTranslatable(dvd, ['deu2']) 90 91 self.assertEquals(artist_t, u'Nach Künstler2') 92 self.assertEquals(album_t, u'Nach Album') 93 self.assertEquals(dvd_t, u'Video DVD')
94
96 components = {'test': {'path': 'elisa.core.tests.test_component:FooComponent', 97 'description': 'To access file:// media', 98 'name': 'test', 99 } 100 } 101 102 TestAPlugin.load_config() 103 # override components 104 TestAPlugin.components = components 105 self.assertRaises(component.InitializeFailure, TestAPlugin.initialize)
106