def test_get_use_inputstream_high_inputstream(self, mock_executeJSONRPC, mock_executeJSONRPC2): mock_executeJSONRPC.return_value = '{"result": {"version": {"major": 18}}}' mock_executeJSONRPC2.return_value = '{"result": {"addon": {"enabled": true, "version": "12.1.7"}}}' utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.use_inputstream(), second=False)
def test_get_user_agent_Windows(self, mock_system): """ADD ME""" mock_system.return_value = 'Windows' utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertIn( container=utils.get_user_agent(), member='Win')
def test_get_use_inputstream_low_inputstream(self, mock_executeJSONRPC): mock_executeJSONRPC.return_value = '{"result": {"version": {"major": 18}}}' utils = Utils(kodi_base_url='/foo/', constants=Constants()) def return_low_version(): return '0.9.9' utils.get_inputstream_version = return_low_version self.assertEquals( first=utils.use_inputstream(), second=False)
def test_capitalize(self): """ADD ME""" utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.capitalize('foo bar'), second='Foo Bar') self.assertEquals( first=utils.capitalize('FOO BAR'), second='Foo Bar') self.assertEquals( first=utils.capitalize('Foo Bar'), second='Foo Bar')
try: PLUGIN_HANDLE = int(argv[1]) KODI_BASE_URL = argv[0] except ValueError: PLUGIN_HANDLE = 1 KODI_BASE_URL = '' try: from urllib.parse import parse_qsl except: from urlparse import parse_qsl # init plugin object structure CONSTANTS = Constants() CACHE = Cache() UTILS = Utils(constants=CONSTANTS, kodi_base_url=KODI_BASE_URL) DIALOGS = Dialogs(utils=UTILS) ITEM_HELPER = ItemHelper(constants=CONSTANTS, utils=UTILS) SETTINGS = Settings(utils=UTILS, dialogs=DIALOGS, constants=CONSTANTS) SESSION = Session(constants=CONSTANTS, util=UTILS, settings=SETTINGS) CONTENT_LOADER = ContentLoader( session=SESSION, item_helper=ITEM_HELPER, cache=CACHE, handle=PLUGIN_HANDLE) def router(paramstring): """ Converts paramstrings into dicts & decides which method should be called in order to display contents
def test_get_inputstream_version_no_version(self, mock_executeJSONRPC): mock_executeJSONRPC.return_value = '{"result": {"addon": {"enabled": true}}}' utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.get_inputstream_version(), second='1.0.0')
def test_build_url(self): """ADD ME""" utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertIn( container=utils.build_url({'bar': 'baz'}), member='/foo/?bar=baz')
def test_get_addon(self): """ADD ME""" utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertIn( container=str(utils.get_addon()), member='xbmcaddon.Addon')
def test_generate_hash(self): """ADD ME""" utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.generate_hash('ABCDEFG'), second='bae3735e5822d8c30fafd70736316e7807f7cccf65e6e73c15f32a60')
def test_get_localized_string_unicode(self, mock_xbmcaddon): mock_xbmcaddon.return_value = MockAddon() utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.get_local_string(30001), second='Foo')
def test_get_use_inputstream_setting_off(self, mock_xbmcaddon): mock_xbmcaddon.return_value = MockAddon() utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.use_inputstream(), second=False)
def test_get_user_agent(self): """ADD ME""" utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertIn( container=utils.get_user_agent(), member='Chrome/59.0.3071.115')
def test_get_use_inputstream_error(self, mock_executeJSONRPC): mock_executeJSONRPC.return_value = '{"error": true}' utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.use_inputstream(), second=False)
def test_get_kodi_version_error_response(self, mock_executeJSONRPC): mock_executeJSONRPC.return_value = '{"error": true}' utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.get_kodi_version(), second=17)
def test_get_kodi_version_local_version(self, mock_executeJSONRPC): mock_executeJSONRPC.return_value = '{"result": {"version": {"major": 18}}}' utils = Utils(kodi_base_url='/foo/', constants=Constants()) self.assertEquals( first=utils.get_kodi_version(), second=18)