Exemplo n.º 1
0
 def testRoundtripUtf8(self):
     converter = StringConverter()
     orig = u"asd" + unichr(270) + unichr(40928)
     self.assertEquals(orig,
                       converter.deserialize(*converter.serialize(orig)))
     orig = "i am a normal string"
     self.assertEquals(orig,
                       converter.deserialize(*converter.serialize(orig)))
Exemplo n.º 2
0
    def test_round_trip(self):
        converter = ScopeConverter()

        root = Scope('/foo/bar')
        assert converter.deserialize(*converter.serialize(root)) == root

        some_scope = Scope('/foo/bar')
        assert converter.deserialize(
            *converter.serialize(some_scope)) == some_scope
Exemplo n.º 3
0
    def testRoundTrip(self):
        converter = ScopeConverter()

        root = Scope('/foo/bar')
        self.assertEqual(root,
                         converter.deserialize(*converter.serialize(root)))

        someScope = Scope('/foo/bar')
        self.assertEqual(
            someScope, converter.deserialize(*converter.serialize(someScope)))
Exemplo n.º 4
0
 def testRoundtripAscii(self):
     converter = StringConverter(wireSchema="ascii-string",
                                 encoding="ascii",
                                 dataType=str)
     orig = "foooo"
     self.assertEquals(orig,
                       converter.deserialize(*converter.serialize(orig)))
Exemplo n.º 5
0
    def test_roundtrip(self):
        self.max_diff = None

        data = {}
        scope1 = Scope("/a/test")
        event1 = Event(event_id=EventId(uuid4(), 32),
                       scope=scope1,
                       method="foo",
                       data=42,
                       data_type=int,
                       user_times={"foo": 1231234.0})
        event1.meta_data.set_send_time()
        event1.meta_data.set_receive_time()
        event2 = Event(event_id=EventId(uuid4(), 1001),
                       scope=scope1,
                       method="fooasdas",
                       data=422,
                       data_type=int,
                       user_times={"bar": 1234.05})
        event2.meta_data.set_send_time()
        event2.meta_data.set_receive_time()
        data[scope1] = [event1, event2]

        converter = EventsByScopeMapConverter()
        roundtripped = converter.deserialize(*converter.serialize(data))

        assert len(roundtripped) == 1
        assert scope1 in roundtripped
        assert len(data[scope1]) == len(roundtripped[scope1])

        for orig, converted in zip(data[scope1], roundtripped[scope1]):

            assert orig.event_id == converted.event_id
            assert orig.scope == converted.scope
            # This test currently does not work correctly without a patch for
            # the converter selection for fundamental types
            # self.assertEqual(orig.data_type, converted.data_type)
            assert orig.data == converted.data
            assert pytest.approx(orig.meta_data.create_time) == \
                converted.meta_data.create_time
            assert pytest.approx(orig.causes) == converted.causes
Exemplo n.º 6
0
    def testRoundtrip(self):
        self.maxDiff = None

        data = {}
        scope1 = Scope("/a/test")
        event1 = Event(id=EventId(uuid4(), 32),
                       scope=scope1,
                       method="foo",
                       data=42,
                       type=int,
                       userTimes={"foo": 1231234.0})
        event1.metaData.setSendTime()
        event1.metaData.setReceiveTime()
        event2 = Event(id=EventId(uuid4(), 1001),
                       scope=scope1,
                       method="fooasdas",
                       data=422,
                       type=int,
                       userTimes={"bar": 1234.05})
        event2.metaData.setSendTime()
        event2.metaData.setReceiveTime()
        data[scope1] = [event1, event2]

        converter = EventsByScopeMapConverter()
        roundtripped = converter.deserialize(*converter.serialize(data))

        self.assertEqual(1, len(roundtripped))
        self.assertTrue(scope1 in roundtripped)
        self.assertEqual(len(data[scope1]), len(roundtripped[scope1]))

        for orig, converted in zip(data[scope1], roundtripped[scope1]):

            self.assertEqual(orig.id, converted.id)
            self.assertEqual(orig.scope, converted.scope)
            # This test currently does not work correctly without a patch for
            # the converter selection for fundamental types
            # self.assertEqual(orig.type, converted.type)
            self.assertEqual(orig.data, converted.data)
            self.assertAlmostEqual(orig.metaData.createTime,
                                   converted.metaData.createTime)
            self.assertEqual(orig.causes, converted.causes)
Exemplo n.º 7
0
def test_structure_base_converters(converter, values):
    for value in values:
        assert value == converter.deserialize(*converter.serialize(value))
Exemplo n.º 8
0
    def test_empty_roundtrip(self):

        data = {}
        converter = EventsByScopeMapConverter()
        assert converter.deserialize(*converter.serialize(data)) == data
Exemplo n.º 9
0
 def test_roundtrip_ascii(self):
     converter = StringConverter(wire_schema="ascii-string",
                                 encoding="ascii")
     orig = "foooo"
     assert converter.deserialize(*converter.serialize(orig)) == orig
Exemplo n.º 10
0
 def test_roundtrip_utf8(self, data):
     converter = StringConverter()
     assert converter.deserialize(*converter.serialize(data)) == data
Exemplo n.º 11
0
 def test_roundtrip(self):
     converter = NoneConverter()
     assert converter.deserialize(*converter.serialize(None)) is None
Exemplo n.º 12
0
def checkStructureBasedRountrip(converterName, values):
    converter = rsb.converter.__dict__[converterName]()
    for value in values:
        assert_equals(value,
                      converter.deserialize(*converter.serialize(value)))
Exemplo n.º 13
0
    def testEmptyRoundtrip(self):

        data = {}
        converter = EventsByScopeMapConverter()
        self.assertEquals(data,
                          converter.deserialize(*converter.serialize(data)))
Exemplo n.º 14
0
 def testRoundtrip(self):
     converter = NoneConverter()
     self.assertEquals(None,
                       converter.deserialize(*converter.serialize(None)))