async def test_file_by_symbol(self):
     requests = (
         reflection_pb2.ServerReflectionRequest(
             file_containing_symbol=_EMPTY_PROTO_SYMBOL_NAME),
         reflection_pb2.ServerReflectionRequest(
             file_containing_symbol='i.donut.exist.co.uk.org.net.me.name.foo'
         ),
     )
     responses = []
     async for response in self._stub.ServerReflectionInfo(iter(requests)):
         responses.append(response)
     expected_responses = (
         reflection_pb2.ServerReflectionResponse(
             valid_host='',
             file_descriptor_response=reflection_pb2.FileDescriptorResponse(
                 file_descriptor_proto=(
                     _file_descriptor_to_proto(empty_pb2.DESCRIPTOR), ))),
         reflection_pb2.ServerReflectionResponse(
             valid_host='',
             error_response=reflection_pb2.ErrorResponse(
                 error_code=grpc.StatusCode.NOT_FOUND.value[0],
                 error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
             )),
     )
     self.assertSequenceEqual(expected_responses, responses)
Exemple #2
0
 def testFileContainingExtension(self):
     requests = (
         reflection_pb2.ServerReflectionRequest(
             file_containing_extension=reflection_pb2.ExtensionRequest(
                 containing_type=_EMPTY_EXTENSIONS_SYMBOL_NAME,
                 extension_number=125,
             ), ),
         reflection_pb2.ServerReflectionRequest(
             file_containing_extension=reflection_pb2.ExtensionRequest(
                 containing_type='i.donut.exist.co.uk.org.net.me.name.foo',
                 extension_number=55,
             ), ),
     )
     responses = tuple(self._stub.ServerReflectionInfo(iter(requests)))
     expected_responses = (
         reflection_pb2.ServerReflectionResponse(
             valid_host='',
             file_descriptor_response=reflection_pb2.FileDescriptorResponse(
                 file_descriptor_proto=(_file_descriptor_to_proto(
                     empty2_extensions_pb2.DESCRIPTOR), ))),
         reflection_pb2.ServerReflectionResponse(
             valid_host='',
             error_response=reflection_pb2.ErrorResponse(
                 error_code=grpc.StatusCode.NOT_FOUND.value[0],
                 error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
             )),
     )
     self._assert_sequence_of_proto_equal(expected_responses, responses)
Exemple #3
0
def _file_descriptor_response(descriptor):
    proto = descriptor_pb2.FileDescriptorProto()
    descriptor.CopyToProto(proto)
    serialized_proto = proto.SerializeToString()
    return _reflection_pb2.ServerReflectionResponse(
        file_descriptor_response=_reflection_pb2.FileDescriptorResponse(
            file_descriptor_proto=(serialized_proto,)),)
Exemple #4
0
 def testFileByName(self):
   requests = (
     reflection_pb2.ServerReflectionRequest(
       file_by_filename=_EMPTY_PROTO_FILE_NAME
     ),
     reflection_pb2.ServerReflectionRequest(
       file_by_filename='i-donut-exist'
     ),
   )
   responses = tuple(self._stub.ServerReflectionInfo(iter(requests)))
   expected_responses = (
     reflection_pb2.ServerReflectionResponse(
       valid_host='',
       file_descriptor_response=reflection_pb2.FileDescriptorResponse(
         file_descriptor_proto=(
           _file_descriptor_to_proto(empty_pb2.DESCRIPTOR),
         )
       )
     ),
     reflection_pb2.ServerReflectionResponse(
       valid_host='',
       error_response=reflection_pb2.ErrorResponse(
         error_code=grpc.StatusCode.NOT_FOUND.value[0],
         error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
       )
     ),
   )
   self.assertSequenceEqual(expected_responses, responses)