def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.GeographicViewServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) client = GeographicViewServiceClient(transport=transport) assert client.transport is transport
def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.GeographicViewServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel
def test_geographic_view_service_transport_auth_adc(): # If credentials and host are not provided, the transport class should use # ADC credentials. with mock.patch.object(google.auth, 'default') as adc: adc.return_value = (ga_credentials.AnonymousCredentials(), None) transports.GeographicViewServiceGrpcTransport(host="squid.clam.whelk") adc.assert_called_once_with(scopes=( 'https://www.googleapis.com/auth/adwords', ))
def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.GeographicViewServiceGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = GeographicViewServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, )
def test_geographic_view_service_grpc_transport_channel(): channel = grpc.insecure_channel('http://localhost/') # Check that channel is used if provided. transport = transports.GeographicViewServiceGrpcTransport( host="squid.clam.whelk", channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" assert transport._ssl_channel_credentials == None