def test_json_encode(self): self.assertEquals(registry.decode( registry.encode(py_data, serializer="json")[-1], content_type='application/json', content_encoding='utf-8'), registry.decode( json_data, content_type='application/json', content_encoding='utf-8'))
def test_yaml_encode(self): self.assertEquals(registry.decode( registry.encode(py_data, serializer="yaml")[-1], content_type='application/x-yaml', content_encoding='utf-8'), registry.decode( yaml_data, content_type='application/x-yaml', content_encoding='utf-8'))
def test_content_type_decoding(self): content_type = 'plain/text' self.assertEquals(unicode_string, registry.decode( unicode_string_as_utf8, content_type='plain/text', content_encoding='utf-8')) self.assertEquals(latin_string, registry.decode( latin_string_as_latin1, content_type='application/data', content_encoding='latin-1'))
def test_content_type_binary(self): content_type = 'plain/text' self.assertNotEquals(unicode_string, registry.decode( unicode_string_as_utf8, content_type='application/data', content_encoding='binary')) self.assertEquals(unicode_string_as_utf8, registry.decode( unicode_string_as_utf8, content_type='application/data', content_encoding='binary'))
def test_yaml_encode(self): try: import yaml except ImportError: return say("* PyYAML not installed, will not execute " "related tests.") self.assertEquals(registry.decode( registry.encode(py_data, serializer="yaml")[-1], content_type='application/x-yaml', content_encoding='utf-8'), registry.decode( yaml_data, content_type='application/x-yaml', content_encoding='utf-8'))
def test_msgpack_encode(self): try: import msgpack except ImportError: return say("* msgpack-python not installed, will not execute " "related tests.") self.assertEquals(registry.decode( registry.encode(msgpack_py_data, serializer="msgpack")[-1], content_type='application/x-msgpack', content_encoding='binary'), registry.decode( msgpack_data, content_type='application/x-msgpack', content_encoding='binary'))
def test_pickle_decode(self): self.assertEquals(py_data, registry.decode( pickle_data, content_type='application/x-python-serialize', content_encoding='binary'))
def test_yaml_decode(self): self.assertEquals(py_data, registry.decode( yaml_data, content_type='application/x-yaml', content_encoding='utf-8'))
def test_json_decode(self): self.assertEquals(py_data, registry.decode( json_data, content_type='application/json', content_encoding='utf-8'))