def test_render_and_parse(self): """ Test rendering and then parsing returns the original object. IE obj -> render -> parse -> obj. """ obj = {'foo': ['bar', 'baz']} renderer = YAMLRenderer() parser = YAMLParser() content = renderer.render(obj, 'application/yaml') data = parser.parse(StringIO(content)) self.assertEqual(obj, data)
def test_render_and_parse(self): """ Test rendering and then parsing returns the original object. IE obj -> render -> parse -> obj. """ obj = {"foo": ["bar", "baz"]} renderer = YAMLRenderer() parser = YAMLParser() content = renderer.render(obj, "application/yaml") data = parser.parse(BytesIO(content)) self.assertEqual(obj, data)
def test_render_and_parse(self): """ Test rendering and then parsing returns the original object. IE obj -> render -> parse -> obj. """ obj = {'foo': ['bar', 'baz']} renderer = YAMLRenderer() parser = YAMLParser() content = renderer.render(obj, 'application/yaml') data = parser.parse(StringIO(content)) self.assertEquals(obj, data)
def get_parser(cls): """ Cf from rest_framework.parsers import JSONParser """ if ROA_FORMAT == 'json': return JSONParser() elif ROA_FORMAT == 'xml': return XMLParser() elif ROAException == 'yaml': return YAMLParser() else: raise NotImplementedError