def test_name_property_works_as_expected(self): expected = 'Test string' item = Envelope() item.name = expected actual = item.name self.assertEqual(expected, actual) expected = 'Other string' item.name = expected actual = item.name self.assertEqual(expected, actual)
def test_serialize_works_as_expected(self): item = Envelope() item.ver = 42 item.name = 'Test string' item.time = 'Test string' item.sample_rate = 1.5 item.seq = 'Test string' item.ikey = 'Test string' for key, value in { 'key1': 'test value 1' , 'key2': 'test value 2' }.items(): item.tags[key] = value item.data = object() actual = json.dumps(item.write(), separators=(',', ':'), cls=TestJsonEncoder) expected = '{"ver":42,"name":"Test string","time":"Test string","sampleRate":1.5,"seq":"Test string","iKey":"Test string","tags":{"key1":"test value 1","key2":"test value 2"},"data":{}}' self.assertEqual(expected, actual)
def test_serialize_works_as_expected(self): item = Envelope() item.ver = 42 item.name = 'Test string' item.time = 'Test string' item.sample_rate = 1.5 item.seq = 'Test string' item.ikey = 'Test string' for key, value in { 'key1': 'test value 1', 'key2': 'test value 2' }.items(): item.tags[key] = value item.data = object() actual = json.dumps(item.write(), separators=(',', ':'), cls=TestJsonEncoder) expected = '{"ver":42,"name":"Test string","time":"Test string","sampleRate":1.5,"seq":"Test string","iKey":"Test string","tags":{"key1":"test value 1","key2":"test value 2"},"data":{}}' self.assertEqual(expected, actual)