def _get_oneofs( self, oneof_pbs: Sequence[descriptor_pb2.OneofDescriptorProto], address: metadata.Address, path: Tuple[int, ...], ) -> Dict[str, wrappers.Oneof]: """Return a dictionary of wrapped oneofs for the given message. Args: oneof_fields (Sequence[~.descriptor_pb2.OneofDescriptorProto]): A sequence of protobuf field objects. address (~.metadata.Address): An address object denoting the location of these oneofs. path (Tuple[int]): The source location path thus far, as understood by ``SourceCodeInfo.Location``. Returns: Mapping[str, ~.wrappers.Oneof]: A ordered mapping of :class:`~.wrappers.Oneof` objects. """ # Iterate over the oneofs and collect them into a dictionary. answer = collections.OrderedDict( (oneof_pb.name, wrappers.Oneof(oneof_pb=oneof_pb)) for i, oneof_pb in enumerate(oneof_pbs)) # Done; return the answer. return answer
def test_wrapped_oneof(): oneof_pb = make_oneof_pb2("oneof_name") wrapped = wrappers.Oneof(oneof_pb=oneof_pb) assert wrapped.oneof_pb == oneof_pb assert wrapped.name == oneof_pb.name