Пример #1
0
class TestScraperChain(unittest.TestCase):
    bootstrapper.bootstrap()

    def setUp(self):
        self.chain = RequiredFeature('scraper-chain').request()

    def testReturnType(self):
        game_name = 'Half-Life 2'
        game = self.chain.query_game_information(game_name)
        self.assertEqual(isinstance(game, Game), True)

    def testImageDump(self):
        game_name = 'Half-Life 2'
        game = self.chain.query_game_information(game_name)

        for img_id in game.fanarts:
            art = game.fanarts.get(img_id)
            self.assertEqual(os.path.isfile(art.get_thumb()), True)
            if art != game.get_selected_fanart():
                self.assertEqual(os.path.isfile(art.get_original()), False)
            else:
                self.assertEqual(os.path.isfile(art.get_original()), True)

        for img_path in game.posters:
            self.assertEqual(os.path.isfile(img_path), True)

        self.assertEqual(os.path.isfile(game.get_selected_fanart().get_original()), True)

    def tearDown(self):
        self.chain.reset_cache()
Пример #2
0
class TestUpdateService(unittest.TestCase):
    bootstrapper.bootstrap()

    def setUp(self):
        self.update_service = RequiredFeature('update-service').request()

    def testVersionCheck(self):
        self.update_service.check_for_update()
Пример #3
0
import xbmcaddon

__addon__ = xbmcaddon.Addon()

if __name__ == '__main__':
    if __addon__.getSetting("luna_widget_enable") == 'true':
        import resources.lib.config.bootstrap as bootstrapper
        from xbmcswift2 import xbmcgui
        from resources.lib.di.requiredfeature import RequiredFeature
        plugin = bootstrapper.bootstrap()
        WINDOW = xbmcgui.Window(10000)
        core = RequiredFeature('core').request()
        storage = core.get_storage()

        sorted_list = sorted(storage.raw_dict().keys())

        sorted_storage = plugin.get_storage('sorted_game_storage')
        sorted_storage.clear()

        for i, game_name in enumerate(sorted_list):
            game = storage.get(game_name)
            WINDOW.setProperty('Luna.%s.name' % i, game.name)
            WINDOW.setProperty('Luna.%s.icon' % i, game.get_selected_poster())
            WINDOW.setProperty('Luna.%s.thumb' % i, game.get_selected_poster())
            WINDOW.setProperty('Luna.%s.fanart' % i,
                               game.get_selected_fanart().get_original())
            sorted_storage[i] = game_name

        sorted_storage.sync()
Пример #4
0
import xbmcaddon

__addon__ = xbmcaddon.Addon()

if __name__ == '__main__':
    if __addon__.getSetting("luna_widget_enable") == 'true':
        import resources.lib.config.bootstrap as bootstrapper
        from xbmcswift2 import xbmcgui
        from resources.lib.di.requiredfeature import RequiredFeature
        plugin = bootstrapper.bootstrap()
        WINDOW = xbmcgui.Window(10000)
        core = RequiredFeature('core').request()
        storage = core.get_storage()

        sorted_list = sorted(storage.raw_dict().keys())

        sorted_storage = plugin.get_storage('sorted_game_storage')
        sorted_storage.clear()

        for i, game_name in enumerate(sorted_list):
            game = storage.get(game_name)
            WINDOW.setProperty('Luna.%s.name' % i, game.name)
            WINDOW.setProperty('Luna.%s.icon' % i, game.get_selected_poster())
            WINDOW.setProperty('Luna.%s.thumb' % i, game.get_selected_poster())
            WINDOW.setProperty('Luna.%s.fanart' % i, game.get_selected_fanart().get_original())
            sorted_storage[i] = game_name

        sorted_storage.sync()
Пример #5
0
class TestConfigHelper(unittest.TestCase):
    bootstrapper.bootstrap()

    def setUp(self):
        path = os.path.join(os.path.expanduser('~'), 'LunaTestTemp/')
        if not os.path.exists(path):
            os.makedirs(path)
        self.addon_path = path
        self.bin_path = os.path.join(path, 'binary/bin')
        self.fake_settings = {
            'addon_path': self.addon_path,
            'binary_path': self.bin_path,
            'host_ip': '192.168.1.1',
            'enable_custom_res': False,
            'resolution_width': '',
            'resolution_height': '',
            'resolution': '1920x1080',
            'framerate': '60',
            'graphics_optimizations': False,
            'remote_optimizations': False,
            'local_audio': False,
            'enable_custom_bitrate': False,
            'bitrate': '',
            'packetsize': 1024,
            'enable_custom_input': True,
            'input_map': os.path.join(self.addon_path, 'input.map'),
            'input_device': os.path.join(self.addon_path, 'input.device'),
            'override_default_resolution': False
        }

    def testConfigurationDump(self):
        config = RequiredFeature('config-helper').request()
        config._configure(**self.fake_settings)
        config._dump_conf()

        self.assertEqual(os.path.isfile(config.full_path), True)

    def testConfigurationCorrectness(self):
        config = RequiredFeature('config-helper').request()
        config._configure(**self.fake_settings)
        config._dump_conf()

        self.assertEqual(self.bin_path,
                         config.get_section_setting('General', 'binpath'))
        self.assertEqual('192.168.1.1',
                         config.get_section_setting('General', 'address'))
        self.assertEqual('60', config.get_section_setting('General', 'fps'))
        self.assertEqual('-1',
                         config.get_section_setting('General', 'bitrate'))
        self.assertEqual('1024',
                         config.get_section_setting('General', 'packetsize'))
        self.assertEqual(os.path.join(self.addon_path, 'input.map'),
                         config.get_section_setting('General', 'mapping'))
        self.assertEqual(os.path.join(self.addon_path, 'input.device'),
                         config.get_section_setting('General', 'input'))
        self.assertEqual('False',
                         config.get_section_setting('General', 'sops'))
        self.assertEqual('False',
                         config.get_section_setting('General', 'localaudio'))
        self.assertEqual('False',
                         config.get_section_setting('General', 'remote'))

    def tearDown(self):
        path = os.path.join(os.path.expanduser('~'), 'LunaTestTemp/')
        shutil.rmtree(path, ignore_errors=True)