Skip to content

Commit 1093e27

Browse files
chore: use gapic-generator-python 0.58.4 (#254)
* chore: use gapic-generator-python 0.58.4 fix: provide appropriate mock values for message body fields committer: dovs PiperOrigin-RevId: 419025932 Source-Link: googleapis/googleapis@73da669 Source-Link: googleapis/googleapis-gen@46df624 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent 110472b commit 1093e27

File tree

6 files changed

+81
-135
lines changed

6 files changed

+81
-135
lines changed

packages/google-cloud-documentai/google/cloud/documentai_v1/services/document_processor_service/transports/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def __init__(
103103
credentials, _ = google.auth.load_credentials_from_file(
104104
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
105105
)
106-
107106
elif credentials is None:
108107
credentials, _ = google.auth.default(
109108
**scopes_kwargs, quota_project_id=quota_project_id

packages/google-cloud-documentai/google/cloud/documentai_v1beta2/services/document_understanding_service/transports/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def __init__(
104104
credentials, _ = google.auth.load_credentials_from_file(
105105
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
106106
)
107-
108107
elif credentials is None:
109108
credentials, _ = google.auth.default(
110109
**scopes_kwargs, quota_project_id=quota_project_id

packages/google-cloud-documentai/google/cloud/documentai_v1beta3/services/document_processor_service/transports/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def __init__(
104104
credentials, _ = google.auth.load_credentials_from_file(
105105
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
106106
)
107-
108107
elif credentials is None:
109108
credentials, _ = google.auth.default(
110109
**scopes_kwargs, quota_project_id=quota_project_id

packages/google-cloud-documentai/tests/unit/gapic/documentai_v1/test_document_processor_service.py

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -277,20 +277,20 @@ def test_document_processor_service_client_client_options(
277277
# unsupported value.
278278
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
279279
with pytest.raises(MutualTLSChannelError):
280-
client = client_class()
280+
client = client_class(transport=transport_name)
281281

282282
# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
283283
with mock.patch.dict(
284284
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
285285
):
286286
with pytest.raises(ValueError):
287-
client = client_class()
287+
client = client_class(transport=transport_name)
288288

289289
# Check the case quota_project_id is provided
290290
options = client_options.ClientOptions(quota_project_id="octopus")
291291
with mock.patch.object(transport_class, "__init__") as patched:
292292
patched.return_value = None
293-
client = client_class(transport=transport_name, client_options=options)
293+
client = client_class(client_options=options, transport=transport_name)
294294
patched.assert_called_once_with(
295295
credentials=None,
296296
credentials_file=None,
@@ -359,7 +359,7 @@ def test_document_processor_service_client_mtls_env_auto(
359359
)
360360
with mock.patch.object(transport_class, "__init__") as patched:
361361
patched.return_value = None
362-
client = client_class(transport=transport_name, client_options=options)
362+
client = client_class(client_options=options, transport=transport_name)
363363

364364
if use_client_cert_env == "false":
365365
expected_client_cert_source = None
@@ -458,7 +458,7 @@ def test_document_processor_service_client_client_options_scopes(
458458
options = client_options.ClientOptions(scopes=["1", "2"],)
459459
with mock.patch.object(transport_class, "__init__") as patched:
460460
patched.return_value = None
461-
client = client_class(transport=transport_name, client_options=options)
461+
client = client_class(client_options=options, transport=transport_name)
462462
patched.assert_called_once_with(
463463
credentials=None,
464464
credentials_file=None,
@@ -493,7 +493,7 @@ def test_document_processor_service_client_client_options_credentials_file(
493493
options = client_options.ClientOptions(credentials_file="credentials.json")
494494
with mock.patch.object(transport_class, "__init__") as patched:
495495
patched.return_value = None
496-
client = client_class(transport=transport_name, client_options=options)
496+
client = client_class(client_options=options, transport=transport_name)
497497
patched.assert_called_once_with(
498498
credentials=None,
499499
credentials_file="credentials.json",
@@ -526,9 +526,10 @@ def test_document_processor_service_client_client_options_from_dict():
526526
)
527527

528528

529-
def test_process_document(
530-
transport: str = "grpc", request_type=document_processor_service.ProcessRequest
531-
):
529+
@pytest.mark.parametrize(
530+
"request_type", [document_processor_service.ProcessRequest, dict,]
531+
)
532+
def test_process_document(request_type, transport: str = "grpc"):
532533
client = DocumentProcessorServiceClient(
533534
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
534535
)
@@ -552,10 +553,6 @@ def test_process_document(
552553
assert isinstance(response, document_processor_service.ProcessResponse)
553554

554555

555-
def test_process_document_from_dict():
556-
test_process_document(request_type=dict)
557-
558-
559556
def test_process_document_empty_call():
560557
# This test is a coverage failsafe to make sure that totally empty calls,
561558
# i.e. request == None and no flattened fields passed, work.
@@ -737,9 +734,10 @@ async def test_process_document_flattened_error_async():
737734
)
738735

739736

740-
def test_batch_process_documents(
741-
transport: str = "grpc", request_type=document_processor_service.BatchProcessRequest
742-
):
737+
@pytest.mark.parametrize(
738+
"request_type", [document_processor_service.BatchProcessRequest, dict,]
739+
)
740+
def test_batch_process_documents(request_type, transport: str = "grpc"):
743741
client = DocumentProcessorServiceClient(
744742
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
745743
)
@@ -765,10 +763,6 @@ def test_batch_process_documents(
765763
assert isinstance(response, future.Future)
766764

767765

768-
def test_batch_process_documents_from_dict():
769-
test_batch_process_documents(request_type=dict)
770-
771-
772766
def test_batch_process_documents_empty_call():
773767
# This test is a coverage failsafe to make sure that totally empty calls,
774768
# i.e. request == None and no flattened fields passed, work.
@@ -962,10 +956,10 @@ async def test_batch_process_documents_flattened_error_async():
962956
)
963957

964958

965-
def test_review_document(
966-
transport: str = "grpc",
967-
request_type=document_processor_service.ReviewDocumentRequest,
968-
):
959+
@pytest.mark.parametrize(
960+
"request_type", [document_processor_service.ReviewDocumentRequest, dict,]
961+
)
962+
def test_review_document(request_type, transport: str = "grpc"):
969963
client = DocumentProcessorServiceClient(
970964
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
971965
)
@@ -989,10 +983,6 @@ def test_review_document(
989983
assert isinstance(response, future.Future)
990984

991985

992-
def test_review_document_from_dict():
993-
test_review_document(request_type=dict)
994-
995-
996986
def test_review_document_empty_call():
997987
# This test is a coverage failsafe to make sure that totally empty calls,
998988
# i.e. request == None and no flattened fields passed, work.
@@ -1765,7 +1755,7 @@ def test_parse_common_location_path():
17651755
assert expected == actual
17661756

17671757

1768-
def test_client_withDEFAULT_CLIENT_INFO():
1758+
def test_client_with_default_client_info():
17691759
client_info = gapic_v1.client_info.ClientInfo()
17701760

17711761
with mock.patch.object(

packages/google-cloud-documentai/tests/unit/gapic/documentai_v1beta2/test_document_understanding_service.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,20 @@ def test_document_understanding_service_client_client_options(
271271
# unsupported value.
272272
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
273273
with pytest.raises(MutualTLSChannelError):
274-
client = client_class()
274+
client = client_class(transport=transport_name)
275275

276276
# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
277277
with mock.patch.dict(
278278
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
279279
):
280280
with pytest.raises(ValueError):
281-
client = client_class()
281+
client = client_class(transport=transport_name)
282282

283283
# Check the case quota_project_id is provided
284284
options = client_options.ClientOptions(quota_project_id="octopus")
285285
with mock.patch.object(transport_class, "__init__") as patched:
286286
patched.return_value = None
287-
client = client_class(transport=transport_name, client_options=options)
287+
client = client_class(client_options=options, transport=transport_name)
288288
patched.assert_called_once_with(
289289
credentials=None,
290290
credentials_file=None,
@@ -353,7 +353,7 @@ def test_document_understanding_service_client_mtls_env_auto(
353353
)
354354
with mock.patch.object(transport_class, "__init__") as patched:
355355
patched.return_value = None
356-
client = client_class(transport=transport_name, client_options=options)
356+
client = client_class(client_options=options, transport=transport_name)
357357

358358
if use_client_cert_env == "false":
359359
expected_client_cert_source = None
@@ -452,7 +452,7 @@ def test_document_understanding_service_client_client_options_scopes(
452452
options = client_options.ClientOptions(scopes=["1", "2"],)
453453
with mock.patch.object(transport_class, "__init__") as patched:
454454
patched.return_value = None
455-
client = client_class(transport=transport_name, client_options=options)
455+
client = client_class(client_options=options, transport=transport_name)
456456
patched.assert_called_once_with(
457457
credentials=None,
458458
credentials_file=None,
@@ -487,7 +487,7 @@ def test_document_understanding_service_client_client_options_credentials_file(
487487
options = client_options.ClientOptions(credentials_file="credentials.json")
488488
with mock.patch.object(transport_class, "__init__") as patched:
489489
patched.return_value = None
490-
client = client_class(transport=transport_name, client_options=options)
490+
client = client_class(client_options=options, transport=transport_name)
491491
patched.assert_called_once_with(
492492
credentials=None,
493493
credentials_file="credentials.json",
@@ -520,10 +520,10 @@ def test_document_understanding_service_client_client_options_from_dict():
520520
)
521521

522522

523-
def test_batch_process_documents(
524-
transport: str = "grpc",
525-
request_type=document_understanding.BatchProcessDocumentsRequest,
526-
):
523+
@pytest.mark.parametrize(
524+
"request_type", [document_understanding.BatchProcessDocumentsRequest, dict,]
525+
)
526+
def test_batch_process_documents(request_type, transport: str = "grpc"):
527527
client = DocumentUnderstandingServiceClient(
528528
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
529529
)
@@ -549,10 +549,6 @@ def test_batch_process_documents(
549549
assert isinstance(response, future.Future)
550550

551551

552-
def test_batch_process_documents_from_dict():
553-
test_batch_process_documents(request_type=dict)
554-
555-
556552
def test_batch_process_documents_empty_call():
557553
# This test is a coverage failsafe to make sure that totally empty calls,
558554
# i.e. request == None and no flattened fields passed, work.
@@ -764,9 +760,10 @@ async def test_batch_process_documents_flattened_error_async():
764760
)
765761

766762

767-
def test_process_document(
768-
transport: str = "grpc", request_type=document_understanding.ProcessDocumentRequest
769-
):
763+
@pytest.mark.parametrize(
764+
"request_type", [document_understanding.ProcessDocumentRequest, dict,]
765+
)
766+
def test_process_document(request_type, transport: str = "grpc"):
770767
client = DocumentUnderstandingServiceClient(
771768
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
772769
)
@@ -794,10 +791,6 @@ def test_process_document(
794791
assert response.text == "text_value"
795792

796793

797-
def test_process_document_from_dict():
798-
test_process_document(request_type=dict)
799-
800-
801794
def test_process_document_empty_call():
802795
# This test is a coverage failsafe to make sure that totally empty calls,
803796
# i.e. request == None and no flattened fields passed, work.
@@ -1440,7 +1433,7 @@ def test_parse_common_location_path():
14401433
assert expected == actual
14411434

14421435

1443-
def test_client_withDEFAULT_CLIENT_INFO():
1436+
def test_client_with_default_client_info():
14441437
client_info = gapic_v1.client_info.ClientInfo()
14451438

14461439
with mock.patch.object(

0 commit comments

Comments
 (0)