33 """Tests for google.protobuf.symbol_database."""
36 import unittest2
as unittest
49 if descriptor._USE_C_DESCRIPTORS:
56 db.RegisterFileDescriptor(unittest_pb2.DESCRIPTOR)
57 db.RegisterMessage(unittest_pb2.TestAllTypes)
58 db.RegisterMessage(unittest_pb2.TestAllTypes.NestedMessage)
59 db.RegisterMessage(unittest_pb2.TestAllTypes.OptionalGroup)
60 db.RegisterMessage(unittest_pb2.TestAllTypes.RepeatedGroup)
61 db.RegisterEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR)
62 db.RegisterEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR)
63 db.RegisterServiceDescriptor(unittest_pb2._TESTSERVICE)
68 unittest_pb2.TestAllTypes.DESCRIPTOR)
69 self.assertTrue(instance
is unittest_pb2.TestAllTypes)
73 [
'google/protobuf/unittest.proto'])
75 unittest_pb2.TestAllTypes
is
76 messages[
'protobuf_unittest.TestAllTypes'])
80 unittest_pb2.TestAllTypes, self.
_Database().GetSymbol(
81 'protobuf_unittest.TestAllTypes'))
83 unittest_pb2.TestAllTypes.NestedMessage, self.
_Database().GetSymbol(
84 'protobuf_unittest.TestAllTypes.NestedMessage'))
86 unittest_pb2.TestAllTypes.OptionalGroup, self.
_Database().GetSymbol(
87 'protobuf_unittest.TestAllTypes.OptionalGroup'))
89 unittest_pb2.TestAllTypes.RepeatedGroup, self.
_Database().GetSymbol(
90 'protobuf_unittest.TestAllTypes.RepeatedGroup'))
95 'protobuf_unittest.ForeignEnum',
97 'protobuf_unittest.ForeignEnum').full_name)
99 'protobuf_unittest.TestAllTypes.NestedEnum',
100 self.
_Database().pool.FindEnumTypeByName(
101 'protobuf_unittest.TestAllTypes.NestedEnum').full_name)
105 'protobuf_unittest.TestAllTypes',
106 self.
_Database().pool.FindMessageTypeByName(
107 'protobuf_unittest.TestAllTypes').full_name)
109 'protobuf_unittest.TestAllTypes.NestedMessage',
110 self.
_Database().pool.FindMessageTypeByName(
111 'protobuf_unittest.TestAllTypes.NestedMessage').full_name)
115 'protobuf_unittest.TestService',
117 'protobuf_unittest.TestService').full_name)
122 'google/protobuf/unittest.proto',
123 self.
_Database().pool.FindFileContainingSymbol(
124 'protobuf_unittest.TestAllTypes.NestedEnum').name)
126 'google/protobuf/unittest.proto',
127 self.
_Database().pool.FindFileContainingSymbol(
128 'protobuf_unittest.TestAllTypes').name)
132 'google/protobuf/unittest.proto',
134 'google/protobuf/unittest.proto').name)
137 if __name__ ==
'__main__':