예제 #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_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)
    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)
    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)
예제 #7
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)
예제 #8
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)
예제 #9
0
 def test_handle_invalid_payload(self):
     invalid_msgpack_repr = b'\xa1\xa3foo\x92\xa3bar\xa4baz'
     parser = MessagePackParser()
     with self.assertRaises(ParseError):
         parser.parse(invalid_msgpack_repr)