def test_map_nested(self): message = test_pb2.MapNested() message.children['one'].value = 1.2 message.children['two'].value = 3.4 self.assertLen( message_helpers.find_submessages(message, test_pb2.MapNested.Child), 2)
def test_nested_map(self): message = test_pb2.MapNested() message.children['one'].value = 1.2 message.children['two'].value = 3.4 record = proto_to_json.get_database_json(message) self.assertLen(record, 1) self.assertLen(record['children'], 2) self.assertEqual(record['children'][0]['key'], 'one') self.assertLen(record['children'][0]['value'], 1) self.assertAlmostEqual(record['children'][0]['value']['value'], 1.2, places=3) self.assertEqual(record['children'][1]['key'], 'two') self.assertLen(record['children'][1]['value'], 1) self.assertAlmostEqual(record['children'][1]['value']['value'], 3.4, places=3)