Ejemplo n.º 1
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)
Ejemplo n.º 2
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._assert_sequence_of_proto_equal(expected_responses, responses)
Ejemplo n.º 3
0
 def testFileBySymbol(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 = 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._assert_sequence_of_proto_equal(expected_responses, responses)
Ejemplo n.º 4
0
 def testExtensionNumbersOfType(self):
     requests = (
         reflection_pb2.ServerReflectionRequest(
             all_extension_numbers_of_type=_EMPTY_EXTENSIONS_SYMBOL_NAME),
         reflection_pb2.ServerReflectionRequest(
             all_extension_numbers_of_type='i.donut.exist.co.uk.net.name.foo'
         ),
     )
     responses = tuple(self._stub.ServerReflectionInfo(iter(requests)))
     expected_responses = (
         reflection_pb2.ServerReflectionResponse(
             valid_host='',
             all_extension_numbers_response=reflection_pb2.
             ExtensionNumberResponse(
                 base_type_name=_EMPTY_EXTENSIONS_SYMBOL_NAME,
                 extension_number=_EMPTY_EXTENSIONS_NUMBERS)),
         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)
Ejemplo n.º 5
0
 def ServerReflectionInfo(self, request_iterator, context):
     # pylint: disable=unused-argument
     for request in request_iterator:
         if request.HasField('file_by_filename'):
             yield self._file_by_filename(request.file_by_filename)
         elif request.HasField('file_containing_symbol'):
             yield self._file_containing_symbol(
                 request.file_containing_symbol)
         elif request.HasField('file_containing_extension'):
             yield self._file_containing_extension(
                 request.file_containing_extension.containing_type,
                 request.file_containing_extension.extension_number)
         elif request.HasField('all_extension_numbers_of_type'):
             yield self._all_extension_numbers_of_type(
                 request.all_extension_numbers_of_type)
         elif request.HasField('list_services'):
             yield self._list_services()
         else:
             yield _reflection_pb2.ServerReflectionResponse(
                 error_response=_reflection_pb2.ErrorResponse(
                     error_code=grpc.StatusCode.INVALID_ARGUMENT.value[0],
                     error_message=grpc.StatusCode.INVALID_ARGUMENT.
                     value[1].encode(),
                 ))
Ejemplo n.º 6
0
def _not_found_error():
    return _reflection_pb2.ServerReflectionResponse(
        error_response=_reflection_pb2.ErrorResponse(
            error_code=grpc.StatusCode.NOT_FOUND.value[0],
            error_message=grpc.StatusCode.NOT_FOUND.value[1].encode(),
        ))