31 """Tests for google.protobuf.symbol_database."""
41 class SymbolDatabaseTest(unittest.TestCase):
44 if descriptor._USE_C_DESCRIPTORS:
51 db.RegisterFileDescriptor(unittest_pb2.DESCRIPTOR)
52 db.RegisterMessage(unittest_pb2.TestAllTypes)
53 db.RegisterMessage(unittest_pb2.TestAllTypes.NestedMessage)
54 db.RegisterMessage(unittest_pb2.TestAllTypes.OptionalGroup)
55 db.RegisterMessage(unittest_pb2.TestAllTypes.RepeatedGroup)
56 db.RegisterEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR)
57 db.RegisterEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR)
58 db.RegisterServiceDescriptor(unittest_pb2._TESTSERVICE)
63 unittest_pb2.TestAllTypes.DESCRIPTOR)
64 self.assertTrue(instance
is unittest_pb2.TestAllTypes)
68 [
'google/protobuf/unittest.proto'])
70 unittest_pb2.TestAllTypes
is
71 messages[
'protobuf_unittest.TestAllTypes'])
75 unittest_pb2.TestAllTypes, self.
_Database().GetSymbol(
76 'protobuf_unittest.TestAllTypes'))
78 unittest_pb2.TestAllTypes.NestedMessage, self.
_Database().GetSymbol(
79 'protobuf_unittest.TestAllTypes.NestedMessage'))
81 unittest_pb2.TestAllTypes.OptionalGroup, self.
_Database().GetSymbol(
82 'protobuf_unittest.TestAllTypes.OptionalGroup'))
84 unittest_pb2.TestAllTypes.RepeatedGroup, self.
_Database().GetSymbol(
85 'protobuf_unittest.TestAllTypes.RepeatedGroup'))
90 'protobuf_unittest.ForeignEnum',
92 'protobuf_unittest.ForeignEnum').full_name)
94 'protobuf_unittest.TestAllTypes.NestedEnum',
96 'protobuf_unittest.TestAllTypes.NestedEnum').full_name)
100 'protobuf_unittest.TestAllTypes',
101 self.
_Database().pool.FindMessageTypeByName(
102 'protobuf_unittest.TestAllTypes').full_name)
104 'protobuf_unittest.TestAllTypes.NestedMessage',
105 self.
_Database().pool.FindMessageTypeByName(
106 'protobuf_unittest.TestAllTypes.NestedMessage').full_name)
110 'protobuf_unittest.TestService',
112 'protobuf_unittest.TestService').full_name)
117 'google/protobuf/unittest.proto',
118 self.
_Database().pool.FindFileContainingSymbol(
119 'protobuf_unittest.TestAllTypes.NestedEnum').name)
121 'google/protobuf/unittest.proto',
122 self.
_Database().pool.FindFileContainingSymbol(
123 'protobuf_unittest.TestAllTypes').name)
127 'google/protobuf/unittest.proto',
129 'google/protobuf/unittest.proto').name)
132 if __name__ ==
'__main__':