Skip to content

Commit

Permalink
fix: Fix test generation for *Value wrapper classes
Browse files Browse the repository at this point in the history
This fixes googleapis#1372
  • Loading branch information
vam-google committed Sep 9, 2022
1 parent 0bf4485 commit fcfae9e
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# New boringssl requires C++14
build --repo_env=BAZEL_CXXOPTS="-std=c++14"
14 changes: 14 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

# Import boringssl explicitly to override what gRPC imports as its dependency.
# Boringssl build fails on gcc12 without this fix:
# https://github.com/google/boringssl/commit/8462a367bb57e9524c3d8eca9c62733c63a63cf4,
# which is present only in the newest version of boringssl, not the one imported
# by gRPC. Remove this import once gRPC depends on a newer version.
http_archive(
name = "boringssl",
sha256 = "b460f8673f3393e58ce506e9cdde7f2c3b2575b075f214cb819fb57d809f052b",
strip_prefix = "boringssl-bb41bc007079982da419c0ec3186e510cbcf09d0",
urls = [
"https://github.com/google/boringssl/archive/bb41bc007079982da419c0ec3186e510cbcf09d0.zip",
],
)

#
# Import grpc as a native bazel dependency. This avoids duplication and also
# speeds up loading phase a lot (otherwise python_rules will be building grpcio
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import json
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from proto.marshal.rules import wrappers
{% if 'rest' in opts.transport %}
from requests import Response
from requests import Request, PreparedRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ def test_{{ method_name }}_flattened():
assert TimestampRule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
{% elif field.ident|string() == 'duration_pb2.Duration' %}
assert DurationRule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
{% elif (field.ident|string()).startswith('wrappers_pb2.') %}
assert wrappers.{{ (field.ident|string())[13:] }}Rule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
{% else %}
arg = args[0].{{ key }}
mock_val = {{ field.mock_value }}
Expand Down Expand Up @@ -493,6 +495,8 @@ async def test_{{ method_name }}_flattened_async():
assert TimestampRule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
{% elif field.ident|string() == 'duration_pb2.Duration' %}
assert DurationRule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
{% elif (field.ident|string()).startswith('wrappers_pb2.') %}
assert wrappers.{{ (field.ident|string())[13:] }}Rule().to_proto(args[0].{{ key }}) == {{ field.mock_value }}
{% else %}
arg = args[0].{{ key }}
mock_val = {{ field.mock_value }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from proto.marshal.rules import wrappers

from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from proto.marshal.rules import wrappers

from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from proto.marshal.rules import wrappers

from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from proto.marshal.rules import wrappers

from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from proto.marshal.rules import wrappers

from google.api import monitored_resource_pb2 # type: ignore
from google.api_core import client_options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from proto.marshal.rules import wrappers

from google.api import distribution_pb2 # type: ignore
from google.api import label_pb2 # type: ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import math
import pytest
from proto.marshal.rules.dates import DurationRule, TimestampRule

from proto.marshal.rules import wrappers

from google.api_core import client_options
from google.api_core import exceptions as core_exceptions
Expand Down

0 comments on commit fcfae9e

Please sign in to comment.