Skip to content

Commit 7cd4163

Browse files
vam-googleparthea
andauthored
fix: Fix test generation for *Value wrapper classes (#1437)
This fixes googleapis/gapic-generator-python#1372 Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parent b944206 commit 7cd4163

11 files changed

Lines changed: 28 additions & 8 deletions

File tree

packages/gapic-generator/.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# New boringssl requires C++14
2+
build --repo_env=BAZEL_CXXOPTS="-std=c++14"

packages/gapic-generator/WORKSPACE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
5050

5151
protobuf_deps()
5252

53+
# Import boringssl explicitly to override what gRPC imports as its dependency.
54+
# Boringssl build fails on gcc12 without this fix:
55+
# https://github.com/google/boringssl/commit/8462a367bb57e9524c3d8eca9c62733c63a63cf4,
56+
# which is present only in the newest version of boringssl, not the one imported
57+
# by gRPC. Remove this import once gRPC depends on a newer version.
58+
http_archive(
59+
name = "boringssl",
60+
sha256 = "b460f8673f3393e58ce506e9cdde7f2c3b2575b075f214cb819fb57d809f052b",
61+
strip_prefix = "boringssl-bb41bc007079982da419c0ec3186e510cbcf09d0",
62+
urls = [
63+
"https://github.com/google/boringssl/archive/bb41bc007079982da419c0ec3186e510cbcf09d0.zip",
64+
],
65+
)
66+
5367
#
5468
# Import grpc as a native bazel dependency. This avoids duplication and also
5569
# speeds up loading phase a lot (otherwise python_rules will be building grpcio

packages/gapic-generator/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_%service.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import json
2121
import math
2222
import pytest
2323
from proto.marshal.rules.dates import DurationRule, TimestampRule
24-
24+
from proto.marshal.rules import wrappers
2525
{% if 'rest' in opts.transport %}
2626
from requests import Response
2727
from requests import Request, PreparedRequest

packages/gapic-generator/gapic/templates/tests/unit/gapic/%name_%version/%sub/test_macros.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ def test_{{ method_name }}_flattened():
400400
assert TimestampRule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
401401
{% elif field.ident|string() == 'duration_pb2.Duration' %}
402402
assert DurationRule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
403+
{% elif (field.ident|string()).startswith('wrappers_pb2.') %}
404+
assert wrappers.{{ (field.ident|string())[13:] }}Rule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
403405
{% else %}
404406
arg = args[0].{{ key }}
405407
mock_val = {{ field.mock_value }}
@@ -493,6 +495,8 @@ async def test_{{ method_name }}_flattened_async():
493495
assert TimestampRule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
494496
{% elif field.ident|string() == 'duration_pb2.Duration' %}
495497
assert DurationRule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
498+
{% elif (field.ident|string()).startswith('wrappers_pb2.') %}
499+
assert wrappers.{{ (field.ident|string())[13:] }}Rule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
496500
{% else %}
497501
arg = args[0].{{ key }}
498502
mock_val = {{ field.mock_value }}

packages/gapic-generator/tests/integration/goldens/asset/tests/unit/gapic/asset_v1/test_asset_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import math
2727
import pytest
2828
from proto.marshal.rules.dates import DurationRule, TimestampRule
29-
29+
from proto.marshal.rules import wrappers
3030

3131
from google.api_core import client_options
3232
from google.api_core import exceptions as core_exceptions

packages/gapic-generator/tests/integration/goldens/credentials/tests/unit/gapic/credentials_v1/test_iam_credentials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import math
2727
import pytest
2828
from proto.marshal.rules.dates import DurationRule, TimestampRule
29-
29+
from proto.marshal.rules import wrappers
3030

3131
from google.api_core import client_options
3232
from google.api_core import exceptions as core_exceptions

packages/gapic-generator/tests/integration/goldens/eventarc/tests/unit/gapic/eventarc_v1/test_eventarc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import math
2727
import pytest
2828
from proto.marshal.rules.dates import DurationRule, TimestampRule
29-
29+
from proto.marshal.rules import wrappers
3030

3131
from google.api_core import client_options
3232
from google.api_core import exceptions as core_exceptions

packages/gapic-generator/tests/integration/goldens/logging/tests/unit/gapic/logging_v2/test_config_service_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import math
2727
import pytest
2828
from proto.marshal.rules.dates import DurationRule, TimestampRule
29-
29+
from proto.marshal.rules import wrappers
3030

3131
from google.api_core import client_options
3232
from google.api_core import exceptions as core_exceptions

packages/gapic-generator/tests/integration/goldens/logging/tests/unit/gapic/logging_v2/test_logging_service_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import math
2727
import pytest
2828
from proto.marshal.rules.dates import DurationRule, TimestampRule
29-
29+
from proto.marshal.rules import wrappers
3030

3131
from google.api import monitored_resource_pb2 # type: ignore
3232
from google.api_core import client_options

packages/gapic-generator/tests/integration/goldens/logging/tests/unit/gapic/logging_v2/test_metrics_service_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import math
2727
import pytest
2828
from proto.marshal.rules.dates import DurationRule, TimestampRule
29-
29+
from proto.marshal.rules import wrappers
3030

3131
from google.api import distribution_pb2 # type: ignore
3232
from google.api import label_pb2 # type: ignore

0 commit comments

Comments
 (0)