def test_render_decimal(self):
     """
     Test YAML decimal rendering.
     """
     renderer = YAMLRenderer()
     content = renderer.render({'field': Decimal('111.2')}, 'application/yaml')
     self.assertYAMLContains(content.decode('utf-8'), "field: '111.2'")
 def test_render_decimal(self):
     """
     Test YAML decimal rendering.
     """
     renderer = YAMLRenderer()
     content = renderer.render({"field": Decimal("111.2")}, "application/yaml")
     self.assertYAMLContains(content.decode("utf-8"), "field: '111.2'")
Beispiel #3
0
 def test_proper_encoding(self):
     obj = {'countries': ['United Kingdom', 'France', 'España']}
     renderer = YAMLRenderer()
     content = renderer.render(obj, 'application/yaml')
     self.assertEqual(
         content.strip(),
         'countries: [United Kingdom, France, España]'.encode('utf-8'))
Beispiel #4
0
 def test_render_decimal(self):
     """
     Test YAML decimal rendering.
     """
     renderer = YAMLRenderer()
     content = renderer.render({'field': Decimal('111.2')}, 'application/yaml')
     self.assertYAMLContains(content, "field: '111.2'")
 def test_render(self):
     """
     Test basic YAML rendering.
     """
     obj = {'foo': ['bar', 'baz']}
     renderer = YAMLRenderer()
     content = renderer.render(obj, 'application/yaml')
     self.assertEqual(content, _yaml_repr)
 def test_render(self):
     """
     Test basic YAML rendering.
     """
     obj = {'foo': ['bar', 'baz']}
     renderer = YAMLRenderer()
     content = renderer.render(obj, 'application/yaml')
     self.assertEquals(content, _yaml_repr)
 def test_render(self):
     """
     Test basic YAML rendering.
     """
     obj = {"foo": ["bar", "baz"]}
     renderer = YAMLRenderer()
     content = renderer.render(obj, "application/yaml")
     self.assertEqual(content.decode("utf-8"), _yaml_repr)
        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(StringIO(content))
            self.assertEquals(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)
Beispiel #11
0
 def get_renderer(self):
     """
     Cf from rest_framework.renderers import JSONRenderer
     """
     if ROA_FORMAT == 'json':
         return JSONRenderer()
     elif ROA_FORMAT == 'xml':
         return XMLRenderer()
     elif ROAException == 'yaml':
         return YAMLRenderer()
     else:
         raise NotImplementedError
 def test_proper_encoding(self):
     obj = {'countries': ['United Kingdom', 'France', 'España']}
     renderer = YAMLRenderer()
     content = renderer.render(obj, 'application/yaml')
     self.assertEqual(content.strip(), 'countries: [United Kingdom, France, España]'.encode('utf-8'))
 def test_proper_encoding(self):
     obj = {"countries": ["United Kingdom", "France", "España"]}
     renderer = YAMLRenderer()
     content = renderer.render(obj, "application/yaml")
     self.assertEqual(content.strip(), "countries: [United Kingdom, France, España]".encode("utf-8"))