-
Notifications
You must be signed in to change notification settings - Fork 77
Closed
Labels
type: cleanupAn internal cleanup or hygiene concern.An internal cleanup or hygiene concern.
Description
Some unit tests initialize a variable response or client but don't use them.
Here are examples of each one:
def test_cloud_catalog_auth_adc():
# If no credentials are provided, we should use ADC credentials.
with mock.patch.object(auth, "default") as adc:
adc.return_value = (credentials.AnonymousCredentials(), None)
client = CloudCatalogClient()
adc.assert_called_once_with(
scopes=("https://www.googleapis.com/auth/cloud-platform",)
)def test_get_billing_account_field_headers():
client = CloudBillingClient(credentials=credentials.AnonymousCredentials())
# Any value that is part of the HTTP/1.1 URI should be sent as
# a field header. Set these to a non-empty value.
request = cloud_billing.GetBillingAccountRequest(name="name/value")
# Mock the actual call within the gRPC stub, and fake the request.
with mock.patch.object(
type(client._transport.get_billing_account), "__call__"
) as call:
call.return_value = cloud_billing.BillingAccount()
response = client.get_billing_account(request)
# Establish that the underlying gRPC stub method was called.
assert len(call.mock_calls) == 1
_, args, _ = call.mock_calls[0]
assert args[0] == request
# Establish that the field header was sent.
_, _, kw = call.mock_calls[0]
assert ("x-goog-request-params", "name=name/value") in kw["metadata"]Metadata
Metadata
Assignees
Labels
type: cleanupAn internal cleanup or hygiene concern.An internal cleanup or hygiene concern.