Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
48 changes: 19 additions & 29 deletions tests/unit/gapic/documentai_v1/test_document_processor_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,20 @@ def test_document_processor_service_client_client_options(
# unsupported value.
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
with pytest.raises(MutualTLSChannelError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
with mock.patch.dict(
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
):
with pytest.raises(ValueError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case quota_project_id is provided
options = client_options.ClientOptions(quota_project_id="octopus")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -359,7 +359,7 @@ def test_document_processor_service_client_mtls_env_auto(
)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)

if use_client_cert_env == "false":
expected_client_cert_source = None
Expand Down Expand Up @@ -458,7 +458,7 @@ def test_document_processor_service_client_client_options_scopes(
options = client_options.ClientOptions(scopes=["1", "2"],)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -493,7 +493,7 @@ def test_document_processor_service_client_client_options_credentials_file(
options = client_options.ClientOptions(credentials_file="credentials.json")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file="credentials.json",
Expand Down Expand Up @@ -526,9 +526,10 @@ def test_document_processor_service_client_client_options_from_dict():
)


def test_process_document(
transport: str = "grpc", request_type=document_processor_service.ProcessRequest
):
@pytest.mark.parametrize(
"request_type", [document_processor_service.ProcessRequest, dict,]
)
def test_process_document(request_type, transport: str = "grpc"):
client = DocumentProcessorServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -552,10 +553,6 @@ def test_process_document(
assert isinstance(response, document_processor_service.ProcessResponse)


def test_process_document_from_dict():
test_process_document(request_type=dict)


def test_process_document_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -737,9 +734,10 @@ async def test_process_document_flattened_error_async():
)


def test_batch_process_documents(
transport: str = "grpc", request_type=document_processor_service.BatchProcessRequest
):
@pytest.mark.parametrize(
"request_type", [document_processor_service.BatchProcessRequest, dict,]
)
def test_batch_process_documents(request_type, transport: str = "grpc"):
client = DocumentProcessorServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -765,10 +763,6 @@ def test_batch_process_documents(
assert isinstance(response, future.Future)


def test_batch_process_documents_from_dict():
test_batch_process_documents(request_type=dict)


def test_batch_process_documents_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -962,10 +956,10 @@ async def test_batch_process_documents_flattened_error_async():
)


def test_review_document(
transport: str = "grpc",
request_type=document_processor_service.ReviewDocumentRequest,
):
@pytest.mark.parametrize(
"request_type", [document_processor_service.ReviewDocumentRequest, dict,]
)
def test_review_document(request_type, transport: str = "grpc"):
client = DocumentProcessorServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -989,10 +983,6 @@ def test_review_document(
assert isinstance(response, future.Future)


def test_review_document_from_dict():
test_review_document(request_type=dict)


def test_review_document_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -1765,7 +1755,7 @@ def test_parse_common_location_path():
assert expected == actual


def test_client_withDEFAULT_CLIENT_INFO():
def test_client_with_default_client_info():
client_info = gapic_v1.client_info.ClientInfo()

with mock.patch.object(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,20 +271,20 @@ def test_document_understanding_service_client_client_options(
# unsupported value.
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
with pytest.raises(MutualTLSChannelError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
with mock.patch.dict(
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
):
with pytest.raises(ValueError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case quota_project_id is provided
options = client_options.ClientOptions(quota_project_id="octopus")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -353,7 +353,7 @@ def test_document_understanding_service_client_mtls_env_auto(
)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)

if use_client_cert_env == "false":
expected_client_cert_source = None
Expand Down Expand Up @@ -452,7 +452,7 @@ def test_document_understanding_service_client_client_options_scopes(
options = client_options.ClientOptions(scopes=["1", "2"],)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -487,7 +487,7 @@ def test_document_understanding_service_client_client_options_credentials_file(
options = client_options.ClientOptions(credentials_file="credentials.json")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file="credentials.json",
Expand Down Expand Up @@ -520,10 +520,10 @@ def test_document_understanding_service_client_client_options_from_dict():
)


def test_batch_process_documents(
transport: str = "grpc",
request_type=document_understanding.BatchProcessDocumentsRequest,
):
@pytest.mark.parametrize(
"request_type", [document_understanding.BatchProcessDocumentsRequest, dict,]
)
def test_batch_process_documents(request_type, transport: str = "grpc"):
client = DocumentUnderstandingServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -549,10 +549,6 @@ def test_batch_process_documents(
assert isinstance(response, future.Future)


def test_batch_process_documents_from_dict():
test_batch_process_documents(request_type=dict)


def test_batch_process_documents_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -764,9 +760,10 @@ async def test_batch_process_documents_flattened_error_async():
)


def test_process_document(
transport: str = "grpc", request_type=document_understanding.ProcessDocumentRequest
):
@pytest.mark.parametrize(
"request_type", [document_understanding.ProcessDocumentRequest, dict,]
)
def test_process_document(request_type, transport: str = "grpc"):
client = DocumentUnderstandingServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -794,10 +791,6 @@ def test_process_document(
assert response.text == "text_value"


def test_process_document_from_dict():
test_process_document(request_type=dict)


def test_process_document_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -1440,7 +1433,7 @@ def test_parse_common_location_path():
assert expected == actual


def test_client_withDEFAULT_CLIENT_INFO():
def test_client_with_default_client_info():
client_info = gapic_v1.client_info.ClientInfo()

with mock.patch.object(
Expand Down
Loading