def test_does_not_encode_unicode_and_None_to_unicode(self): self.assertEqual(utf8_decode(unicode_string), unicode_string) self.assertTrue(is_unicode(utf8_decode(unicode_string))) self.assertEqual(utf8_decode(unicode_string2), unicode_string2) self.assertTrue(is_unicode(utf8_decode(unicode_string2))) self.assertEqual(utf8_decode(None), None)
def test_does_not_encode_unicode_and_None_to_unicode(self): self.assertEqual(text.utf8_decode(constants.UNICODE_STRING), constants.UNICODE_STRING) self.assertTrue(builtins.is_unicode(text.utf8_decode(constants.UNICODE_STRING))) self.assertEqual(text.utf8_decode(constants.UNICODE_STRING2), constants.UNICODE_STRING2) self.assertTrue(builtins.is_unicode(text.utf8_decode(constants.UNICODE_STRING2))) self.assertEqual(text.utf8_decode(None), None)
def test_equality_encoding_realm_emptyValues(self): expected_value = ({ OAUTH_PARAM_NONCE: ['4572616e48616d6d65724c61686176'], OAUTH_PARAM_TIMESTAMP: ['137131200'], OAUTH_PARAM_CONSUMER_KEY: ['0685bd9184jfhq22'], 'oauth_something': [' Some Example'], OAUTH_PARAM_SIGNATURE_METHOD: ['HMAC-SHA1'], OAUTH_PARAM_VERSION: [utf8_decode(OAUTH_VERSION_1)], OAUTH_PARAM_TOKEN: ['ad180jjd733klru7'], 'oauth_empty': [''], OAUTH_PARAM_SIGNATURE: ['wOJIO9A2W5mFwDgiDvZbTSMK/PY='], }, 'Examp%20le' ) self.assertEqual(expected_value, parse_authorization_header('''\ OAuth\ \ realm="Examp%20le",\ oauth_consumer_key="0685bd9184jfhq22",\ oauth_token="ad180jjd733klru7",\ oauth_signature_method="HMAC-SHA1",\ oauth_signature="wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D",\ oauth_timestamp="137131200",\ oauth_nonce="4572616e48616d6d65724c61686176",\ oauth_version="1.0",\ oauth_something="%20Some+Example",\ oauth_empty=""\ '''), "parsing failed.")
def json_loads(value): """Wrapper to decode JSON.""" return json.loads(utf8_decode(value))
def test_converts_utf8_decode(self): self.assertEqual(text.utf8_decode(constants.UTF8_BYTES), constants.UNICODE_STRING) self.assertTrue(builtins.is_unicode(text.utf8_decode(constants.UTF8_BYTES))) self.assertEqual(text.utf8_decode(constants.UTF8_BYTES2), constants.UNICODE_STRING2) self.assertTrue(builtins.is_unicode(text.utf8_decode(constants.UTF8_BYTES2)))
def json_loads(value): """Wrapper to decode JSON.""" return json.loads(text.utf8_decode(value))
def test_converts_utf8_decode(self): self.assertEqual(utf8_decode(utf8_bytes), unicode_string) self.assertTrue(is_unicode(utf8_decode(utf8_bytes))) self.assertEqual(utf8_decode(utf8_bytes2), unicode_string2) self.assertTrue(is_unicode(utf8_decode(utf8_bytes2)))
def unquote_plus(v): if is_bytes(v): v = v.replace(b('+'), b(' ')) else: v = v.replace('+', ' ') return utf8_decode(unquote_to_bytes(v))