コード例 #1
0
ファイル: _face_interface_test.py プロジェクト: mindware/grpc
  def instantiate(
      self, methods, method_implementations, multi_method_implementation):
    serialization_behaviors = _serialization_behaviors_from_test_methods(
        methods)
    # TODO(nathaniel): Add a "groups" attribute to _digest.TestServiceDigest.
    service = next(iter(methods))[0]
    # TODO(nathaniel): Add a "cardinalities_by_group" attribute to
    # _digest.TestServiceDigest.
    cardinalities = {
        method: method_object.cardinality()
        for (group, method), method_object in methods.iteritems()}

    server_options = beta.server_options(
        request_deserializers=serialization_behaviors.request_deserializers,
        response_serializers=serialization_behaviors.response_serializers,
        thread_pool_size=test_constants.POOL_SIZE)
    server = beta.server(method_implementations, options=server_options)
    server_credentials = beta.ssl_server_credentials(
        [(resources.private_key(), resources.certificate_chain(),),])
    port = server.add_secure_port('[::]:0', server_credentials)
    server.start()
    client_credentials = beta.ssl_client_credentials(
        resources.test_root_certificates(), None, None)
    channel = test_utilities.create_not_really_secure_channel(
        'localhost', port, client_credentials, _SERVER_HOST_OVERRIDE)
    stub_options = beta.stub_options(
        request_serializers=serialization_behaviors.request_serializers,
        response_deserializers=serialization_behaviors.response_deserializers,
        thread_pool_size=test_constants.POOL_SIZE)
    generic_stub = beta.generic_stub(channel, options=stub_options)
    dynamic_stub = beta.dynamic_stub(
        channel, service, cardinalities, options=stub_options)
    return generic_stub, {service: dynamic_stub}, server
コード例 #2
0
ファイル: _not_found_test.py プロジェクト: larsonmpdx/grpc
 def setUp(self):
   self._server = beta.server({})
   port = self._server.add_insecure_port('[::]:0')
   channel = beta.create_insecure_channel('localhost', port)
   self._generic_stub = beta.generic_stub(channel)
   self._server.start()