Skip to content

Commit

Permalink
chore: Update gapic-generator-python to v1.11.8 (#255)
Browse files Browse the repository at this point in the history
* chore: Update gapic-generator-python to v1.11.7

PiperOrigin-RevId: 573230664

Source-Link: googleapis/googleapis@93beed3

Source-Link: googleapis/googleapis-gen@f4a4eda
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZjRhNGVkYWE4MDU3NjM5ZmNmNmFkZjkxNzk4NzIyODBkMWE4ZjY1MSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: Update gapic-generator-python to v1.11.8

PiperOrigin-RevId: 574178735

Source-Link: googleapis/googleapis@7307199

Source-Link: googleapis/googleapis-gen@ce3af21
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiY2UzYWYyMWI3YzU1OWE4N2MyYmVmYzA3NmJlMGUzYWVkYTNhMjZmMCJ9

* 🦉 Updates from OwlBot post-processor

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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Oct 18, 2023
1 parent 8ab9c66 commit 5ac0aab
Show file tree
Hide file tree
Showing 8 changed files with 797 additions and 497 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1415,8 +1415,9 @@ def test_get_application_rest(request_type):
# Wrap the value into a proper Response obj
response_value = Response()
response_value.status_code = 200
pb_return_value = application.Application.pb(return_value)
json_return_value = json_format.MessageToJson(pb_return_value)
# Convert return value to protobuf type
return_value = application.Application.pb(return_value)
json_return_value = json_format.MessageToJson(return_value)

response_value._content = json_return_value.encode("UTF-8")
req.return_value = response_value
Expand Down Expand Up @@ -1543,8 +1544,9 @@ def test_get_application_rest_flattened():
# Wrap the value into a proper Response obj
response_value = Response()
response_value.status_code = 200
pb_return_value = application.Application.pb(return_value)
json_return_value = json_format.MessageToJson(pb_return_value)
# Convert return value to protobuf type
return_value = application.Application.pb(return_value)
json_return_value = json_format.MessageToJson(return_value)
response_value._content = json_return_value.encode("UTF-8")
req.return_value = response_value

Expand Down Expand Up @@ -1622,6 +1624,73 @@ def test_create_application_rest(request_type):
"use_container_optimized_os": True,
},
}
# The version of a generated dependency at test runtime may differ from the version used during generation.
# Delete any fields which are not present in the current runtime dependency
# See https://github.com/googleapis/gapic-generator-python/issues/1748

# Determine if the message type is proto-plus or protobuf
test_field = appengine.CreateApplicationRequest.meta.fields["application"]

def get_message_fields(field):
# Given a field which is a message (composite type), return a list with
# all the fields of the message.
# If the field is not a composite type, return an empty list.
message_fields = []

if hasattr(field, "message") and field.message:
is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

runtime_nested_fields = [
(field.name, nested_field.name)
for field in get_message_fields(test_field)
for nested_field in get_message_fields(field)
]

subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["application"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
if isinstance(value, list) and len(value):
is_repeated = True
result = value[0]
# For fields where the type is another message
if isinstance(value, dict):
result = value

if result and hasattr(result, "keys"):
for subfield in result.keys():
if (field, subfield) not in runtime_nested_fields:
subfields_not_in_runtime.append(
{
"field": field,
"subfield": subfield,
"is_repeated": is_repeated,
}
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
if subfield:
if field_repeated:
for i in range(0, len(request_init["application"][field])):
del request_init["application"][field][i][subfield]
else:
del request_init["application"][field][subfield]
request = request_type(**request_init)

# Mock the http request call within the method and fake a response.
Expand Down Expand Up @@ -1711,33 +1780,6 @@ def test_create_application_rest_bad_request(

# send a request that will satisfy transcoding
request_init = {}
request_init["application"] = {
"name": "name_value",
"id": "id_value",
"dispatch_rules": [
{"domain": "domain_value", "path": "path_value", "service": "service_value"}
],
"auth_domain": "auth_domain_value",
"location_id": "location_id_value",
"code_bucket": "code_bucket_value",
"default_cookie_expiration": {"seconds": 751, "nanos": 543},
"serving_status": 1,
"default_hostname": "default_hostname_value",
"default_bucket": "default_bucket_value",
"service_account": "service_account_value",
"iap": {
"enabled": True,
"oauth2_client_id": "oauth2_client_id_value",
"oauth2_client_secret": "oauth2_client_secret_value",
"oauth2_client_secret_sha256": "oauth2_client_secret_sha256_value",
},
"gcr_domain": "gcr_domain_value",
"database_type": 1,
"feature_settings": {
"split_health_checks": True,
"use_container_optimized_os": True,
},
}
request = request_type(**request_init)

# Mock the http request call within the method and fake a BadRequest error.
Expand Down Expand Up @@ -1800,6 +1842,73 @@ def test_update_application_rest(request_type):
"use_container_optimized_os": True,
},
}
# The version of a generated dependency at test runtime may differ from the version used during generation.
# Delete any fields which are not present in the current runtime dependency
# See https://github.com/googleapis/gapic-generator-python/issues/1748

# Determine if the message type is proto-plus or protobuf
test_field = appengine.UpdateApplicationRequest.meta.fields["application"]

def get_message_fields(field):
# Given a field which is a message (composite type), return a list with
# all the fields of the message.
# If the field is not a composite type, return an empty list.
message_fields = []

if hasattr(field, "message") and field.message:
is_field_type_proto_plus_type = not hasattr(field.message, "DESCRIPTOR")

if is_field_type_proto_plus_type:
message_fields = field.message.meta.fields.values()
# Add `# pragma: NO COVER` because there may not be any `*_pb2` field types
else: # pragma: NO COVER
message_fields = field.message.DESCRIPTOR.fields
return message_fields

runtime_nested_fields = [
(field.name, nested_field.name)
for field in get_message_fields(test_field)
for nested_field in get_message_fields(field)
]

subfields_not_in_runtime = []

# For each item in the sample request, create a list of sub fields which are not present at runtime
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for field, value in request_init["application"].items(): # pragma: NO COVER
result = None
is_repeated = False
# For repeated fields
if isinstance(value, list) and len(value):
is_repeated = True
result = value[0]
# For fields where the type is another message
if isinstance(value, dict):
result = value

if result and hasattr(result, "keys"):
for subfield in result.keys():
if (field, subfield) not in runtime_nested_fields:
subfields_not_in_runtime.append(
{
"field": field,
"subfield": subfield,
"is_repeated": is_repeated,
}
)

# Remove fields from the sample request which are not present in the runtime version of the dependency
# Add `# pragma: NO COVER` because this test code will not run if all subfields are present at runtime
for subfield_to_delete in subfields_not_in_runtime: # pragma: NO COVER
field = subfield_to_delete.get("field")
field_repeated = subfield_to_delete.get("is_repeated")
subfield = subfield_to_delete.get("subfield")
if subfield:
if field_repeated:
for i in range(0, len(request_init["application"][field])):
del request_init["application"][field][i][subfield]
else:
del request_init["application"][field][subfield]
request = request_type(**request_init)

# Mock the http request call within the method and fake a response.
Expand Down Expand Up @@ -1889,33 +1998,6 @@ def test_update_application_rest_bad_request(

# send a request that will satisfy transcoding
request_init = {"name": "apps/sample1"}
request_init["application"] = {
"name": "name_value",
"id": "id_value",
"dispatch_rules": [
{"domain": "domain_value", "path": "path_value", "service": "service_value"}
],
"auth_domain": "auth_domain_value",
"location_id": "location_id_value",
"code_bucket": "code_bucket_value",
"default_cookie_expiration": {"seconds": 751, "nanos": 543},
"serving_status": 1,
"default_hostname": "default_hostname_value",
"default_bucket": "default_bucket_value",
"service_account": "service_account_value",
"iap": {
"enabled": True,
"oauth2_client_id": "oauth2_client_id_value",
"oauth2_client_secret": "oauth2_client_secret_value",
"oauth2_client_secret_sha256": "oauth2_client_secret_sha256_value",
},
"gcr_domain": "gcr_domain_value",
"database_type": 1,
"feature_settings": {
"split_health_checks": True,
"use_container_optimized_os": True,
},
}
request = request_type(**request_init)

# Mock the http request call within the method and fake a BadRequest error.
Expand Down
Loading

0 comments on commit 5ac0aab

Please sign in to comment.