Ejemplo n.º 1
0
 def test_name_property_works_as_expected(self):
     expected = 'Test string'
     item = RequestData()
     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_name_property_works_as_expected(self):
     expected = 'Test string'
     item = RequestData()
     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 = RequestData()
     item.ver = 42
     item.id = 'Test string'
     item.name = 'Test string'
     item.duration = 'Test string'
     item.response_code = 'Test string'
     item.success = True
     item.url = 'Test string'
     for key, value in { 'key1': 'test value 1' , 'key2': 'test value 2' }.items():
         item.properties[key] = value
     for key, value in { 'key1': 3.1415 , 'key2': 42.2 }.items():
         item.measurements[key] = value
     actual = json.dumps(item.write(), separators=(',', ':'), cls=TestJsonEncoder)
     expected = '{"ver":42,"id":"Test string","name":"Test string","duration":"Test string","responseCode":"Test string","success":true,"url":"Test string","properties":{"key1":"test value 1","key2":"test value 2"},"measurements":{"key1":3.1415,"key2":42.2}}'
     self.assertEqual(expected, actual)
Ejemplo n.º 4
0
 def test_serialize_works_as_expected(self):
     item = RequestData()
     item.ver = 42
     item.id = 'Test string'
     item.name = 'Test string'
     item.duration = 'Test string'
     item.response_code = 'Test string'
     item.success = True
     item.url = 'Test string'
     for key, value in {
             'key1': 'test value 1',
             'key2': 'test value 2'
     }.items():
         item.properties[key] = value
     for key, value in {'key1': 3.1415, 'key2': 42.2}.items():
         item.measurements[key] = value
     actual = json.dumps(item.write(),
                         separators=(',', ':'),
                         cls=TestJsonEncoder)
     expected = '{"ver":42,"id":"Test string","name":"Test string","duration":"Test string","responseCode":"Test string","success":true,"url":"Test string","properties":{"key1":"test value 1","key2":"test value 2"},"measurements":{"key1":3.1415,"key2":42.2}}'
     self.assertEqual(expected, actual)