def test_encoding(self): data = 'Fòöbàr' hex_encoded_data = '22465c75303066325c7530306636625c75303065307222' encoded_data = utils.encode_data(data, 'hex') self.assertEqual(encoded_data, hex_encoded_data) decoded_data, encoding = utils.decode_data(encoded_data) self.assertEqual(decoded_data, data) self.assertEqual(encoding, 'hex') base64_encoded_data = 'IkZcdTAwZjJcdTAwZjZiXHUwMGUwciI=' encoded_data = utils.encode_data(data, 'base64') self.assertEqual(encoded_data, base64_encoded_data) decoded_data, encoding = utils.decode_data(encoded_data) self.assertEqual(decoded_data, data) self.assertEqual(encoding, 'base64')
def test_from_addon_signals(self): data = 'Fòöbàr' base64_encoded_data = 'IkZcdTAwZjJcdTAwZjZiXHUwMGUwciI=' encoded_data = AddonSignals._encodeData(data) # pylint: disable=protected-access self.assertEqual(encoded_data, base64_encoded_data) decoded_data, encoding = utils.decode_data(encoded_data) self.assertEqual(decoded_data, data) self.assertEqual(encoding, 'base64')
def onNotification(self, sender, method, data): if method.split('.')[1].lower() != 'upnext_data': # method looks like Other.upnext_data return data = utils.decode_data(data) data['id'] = "%s_play_action" % str(sender.replace(".SIGNAL", "")) self.api.addon_data_received(data)
def onNotification(self, sender, method, data): if method.split('.')[1].lower( ) != 'upnext_data': # method looks like Other.upnext_data return data = utils.decode_data(data) data['id'] = "%s_play_action" % str(sender.replace(".SIGNAL", "")) self.api.addon_data_received(data)