コード例 #1
0
    def test_decimal(self):
        obj = {'my_date': decimal.Decimal(1) / decimal.Decimal(7)}

        renderer = MessagePackRenderer()
        parser = MessagePackParser()

        content = renderer.render(obj, 'application/msgpack')
        data = parser.parse(BytesIO(content))
        self.assertEquals(obj, data)
コード例 #2
0
    def test_decimal(self):
        obj = {'my_date': decimal.Decimal(1) / decimal.Decimal(7)}

        renderer = MessagePackRenderer()
        parser = MessagePackParser()

        content = renderer.render(obj, 'application/msgpack')
        data = parser.parse(BytesIO(content))
        self.assertEquals(obj, data)
コード例 #3
0
    def test_time(self):
        obj = {'my_date': datetime.datetime.now().time()}

        renderer = MessagePackRenderer()
        parser = MessagePackParser()

        content = renderer.render(obj, 'application/msgpack')
        data = parser.parse(BytesIO(content))
        self.assertEquals(obj, data)
コード例 #4
0
 def test_render(self):
     """
     Test basic MessagePack rendering.
     """
     obj = {'foo': ['bar', 'baz']}
     renderer = MessagePackRenderer()
     content = renderer.render(obj, 'application/msgpack')
     msgpack_repr = b'\x81\xa3foo\x92\xa3bar\xa3baz'
     self.assertEquals(content, msgpack_repr)
コード例 #5
0
    def test_time(self):
        obj = {'my_date': datetime.datetime.now().time()}

        renderer = MessagePackRenderer()
        parser = MessagePackParser()

        content = renderer.render(obj, 'application/msgpack')
        data = parser.parse(BytesIO(content))
        self.assertEquals(obj, data)
コード例 #6
0
 def test_render(self):
     """
     Test basic MessagePack rendering.
     """
     obj = {'foo': ['bar', 'baz']}
     renderer = MessagePackRenderer()
     content = renderer.render(obj, 'application/msgpack')
     msgpack_repr = b'\x81\xa3foo\x92\xa3bar\xa3baz'
     self.assertEquals(content, msgpack_repr)
コード例 #7
0
    def test_date(self):
        obj = {'my_date': datetime.date.today()}

        renderer = MessagePackRenderer()
        parser = MessagePackParser()

        content = renderer.render(obj, 'application/msgpack')
        data = parser.parse(StringIO(content))
        self.assertEquals(obj, data)
コード例 #8
0
    def test_date(self):
        obj = {'my_date': datetime.date.today()}

        renderer = MessagePackRenderer()
        parser = MessagePackParser()

        content = renderer.render(obj, 'application/msgpack')
        data = parser.parse(StringIO(content))
        self.assertEquals(obj, data)
コード例 #9
0
    def test_render_and_parse(self):
        """
        Test rendering and then parsing returns the original object.
        IE obj -> render -> parse -> obj.
        """
        obj = {'foo': ['bar', {'baz': [1, 2]}]}

        renderer = MessagePackRenderer()
        parser = MessagePackParser()

        content = renderer.render(obj, 'application/msgpack')
        data = parser.parse(BytesIO(content))
        self.assertEquals(obj, data)
コード例 #10
0
    def test_render_and_parse(self):
        """
        Test rendering and then parsing returns the original object.
        IE obj -> render -> parse -> obj.
        """
        obj = {'foo': ['bar', {'baz': [1, 2]}]}

        renderer = MessagePackRenderer()
        parser = MessagePackParser()

        content = renderer.render(obj, 'application/msgpack')
        data = parser.parse(BytesIO(content))
        self.assertEquals(obj, data)
コード例 #11
0
 def test_handle_empty_data_render(self):
     renderer = MessagePackRenderer()
     self.assertEqual(renderer.render(data=None), '')