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

Source Code for Module elisa.core.tests.test_config_upgrader

  1  # Elisa - Home multimedia server 
  2  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
  3  # All rights reserved. 
  4  # 
  5  # This file is available under one of two license agreements. 
  6  # 
  7  # This file is licensed under the GPL version 3. 
  8  # See "LICENSE.GPL" in the root of this distribution including a special 
  9  # exception to use Elisa with Fluendo's plugins. 
 10  # 
 11  # The GPL part of Elisa is also available under a commercial licensing 
 12  # agreement from Fluendo. 
 13  # See "LICENSE.Elisa" in the root directory of this distribution package 
 14  # for details on that license. 
 15   
 16   
 17  from elisa.core.tests.elisa_test_case import ElisaTestCase 
 18   
 19  from elisa.core import config, config_upgrader 
 20  import os 
 21   
22 -class TestConfigUpgrader(ElisaTestCase):
23 24 data_dir = '../elisa/core/tests/data' 25
26 - def _upgrade(self, old_conf_file, default_conf_file, version):
27 28 old_conf_file = os.path.join(self.data_dir, old_conf_file) 29 old_config = config.Config(old_conf_file) 30 31 default_conf_file = os.path.join(self.data_dir, default_conf_file) 32 default = open(default_conf_file).read() 33 upgrader = config_upgrader.ConfigUpgrader(old_config, default) 34 cfg = upgrader.update_for(version) 35 36 cfg_version = cfg.get_option('version', section='general') 37 version_str = '.'.join([str(i) for i in version]) 38 self.assertEquals(cfg_version, version_str) 39 return cfg
40
41 - def _assert_0_3_2(self, cfg):
42 for path in ['base:local_media', 'coherence_plugin:upnp_media', 43 'media_good:gnomevfs_media', 'media_bad:ipod_media', 44 'media_good:elisa_media', 'audiocd:audiocd_media']: 45 self.failIf(path not in cfg.get_option('media_providers')) 46 47 for path in ['media_good:amazon_covers', 'media_good:taglib_metadata', 48 'media_good:cover_cache', 'media_good:gst_metadata', 49 'media_good:cover_in_dir']: 50 self.failIf(path not in cfg.get_option('metadata_providers')) 51 52 for path in ['base:audio_activity', 'base:video_activity', 53 'base:image_activity', 'base:config_activity', 54 'base:service_activity']: 55 self.failIf(path not in cfg.get_option('menu_activities', 56 section='base:main_menu_activity')) 57 58 self.assertEqual(cfg.get_option('input_providers', section='backend1'), 59 ['input_good:lirc_input']) 60 self.assertEqual(cfg.get_option('input_providers', section='frontend1'), 61 ['pigment:pigment_input']) 62 self.assertEqual(cfg.get_option('service_providers'), 63 ['hal:hal_service', 64 'coherence_plugin:coherence_service']) 65 self.assertEqual(cfg.get_option('service_activities', 66 section='base:service_activity'), 67 ['service:about_activity'])
68
69 - def _assert_0_3_3(self, cfg):
70 media_providers = ['daap:daap_media', 'youtube:youtube_media', 71 'shoutcast:shoutcast_media', 'fspot:fspot_media', 72 'coherence:upnp_media', 'ipod:ipod_media', 73 'base:local_media', 'media_db:elisa_media', 74 'gvfs:gnomevfs_media', 'audiocd:audiocd_media', 75 'flickr:flickr_media', 'stage6:stage_media'] 76 cfg_media_providers = cfg.get_option('media_providers', default=[]) 77 for path in media_providers: 78 self.failIf(path not in cfg_media_providers, 79 '%r not in media_providers %r' % (path, 80 cfg_media_providers)) 81 82 metadata_providers = ['gstreamer:gst_metadata_client', 83 'album_art:cover_in_dir', 'amazon:amazon_covers'] 84 for path in metadata_providers: 85 self.failIf(path not in cfg.get_option('metadata_providers', 86 default=[])) 87 88 service_providers = ['gnome:gnome_screensaver_service', 89 'hal:hal_service', 90 'coherence:coherence_service'] 91 cfg_service_providers = cfg.get_option('service_providers', 92 default=[]) 93 for path in service_providers: 94 self.failIf(path not in cfg_service_providers, 95 "%r not in service_providers %r" % (path, 96 cfg_service_providers)) 97 98 self.assertEqual(cfg.get_option('service_activities', 99 section='base:service_activity'), 100 ['service:about_activity']) 101 102 themes = ['raval:tango_theme', 'raval:poblenou_theme', 103 'raval:chris_theme'] 104 cfg_themes = cfg.get_option('themes', 105 section='theme_switcher:theme_switcher_activity', 106 default=[]) 107 for path in themes: 108 self.failIf(path not in cfg_themes, 109 "%r not in themes %r" % (path, cfg_themes)) 110 111 # check backend 112 self.assertEqual(cfg.get_option('activity', section='backend1'), 113 'raval:elisa_activity') 114 self.assertEqual(cfg.get_option('mvc_mappings', section='backend1'), 115 'raval:data/raval_mvc_mappings.conf') 116 self.assertEqual(cfg.get_option('input_providers', section='backend1'), 117 ['lirc:lirc_input']) 118 119 # check frontend 120 self.assertEqual(cfg.get_option('theme', section='frontend1'), 121 'raval:tango_theme') 122 self.assertEqual(cfg.get_option('input_providers', section='frontend1'), 123 ['pigment:pigment_input']) 124 125 126 removed_sections = ['base:main_menu_activity', 127 'base:player_controller', 128 'poblenou:elisa_controller', 129 'base:audio_activity', 'base:video_activity', 130 'base:image_activity', 'elisa_view'] 131 for section_name in removed_sections: 132 self.failIf(cfg.get_section(section_name))
133 134
135 - def testUpgrade0_1_7To_0_3_1(self):
136 " 0.1.7 -> 0.3.1 " 137 self._upgrade('elisa_0_1_7.conf', 'elisa_0_3_1.conf', (0, 3, 1))
138
139 - def testUpgrade0_1_7To_0_3_2(self):
140 " 0.1.7 -> 0.3.2 " 141 self._upgrade('elisa_0_1_7.conf','elisa_0_3_2.conf', (0, 3, 2))
142
143 - def testUpgrade0_1_7To_0_3_3(self):
144 " 0.1.7 -> 0.3.3 " 145 self._upgrade('elisa_0_1_7.conf','elisa_0_3_3.conf', (0, 3, 3))
146
147 - def testUpgrade0_3_1To_0_3_2(self):
148 " 0.3.1 -> 0.3.2 " 149 cfg = self._upgrade('elisa_0_3_1.conf', 'elisa_0_3_2.conf', (0, 3, 2)) 150 self._assert_0_3_2(cfg)
151
152 - def testUpgrade0_3_2To_0_3_3(self):
153 " 0.3.2 -> 0.3.3 " 154 cfg = self._upgrade('elisa_0_3_2.conf', 'elisa_0_3_3.conf', (0, 3, 3)) 155 self._assert_0_3_3(cfg)
156