Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Experiment Auth Testing Strategy using Gapic Showcase #2207

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,12 @@ switched_rules_by_language(
gapic = True,
grpc = True,
)

# BEGIN workaround
load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python39",
python_version = "3.9",
)
# END workaround
10 changes: 9 additions & 1 deletion repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,22 @@ def gapic_generator_python():
strip_prefix = "rules_gapic-%s" % _rules_gapic_version,
urls = ["https://github.com/googleapis/rules_gapic/archive/v%s.tar.gz" % _rules_gapic_version],
)
_commit_sha = "fae3e6e091418d6343902debaf545cfc8f32c3ff"
_commit_sha = "b53452f85b7d66e1336d136ddb52dd2136cc9552"
_maybe(
http_archive,
name = "com_google_googleapis",
strip_prefix = "googleapis-{}".format(_commit_sha),
urls = ["https://github.com/googleapis/googleapis/archive/{}.zip".format(_commit_sha)],
)

_commit_sha = "4847b10e47f7ce97128c9b5410000dde1b8bdcea"
_maybe(
http_archive,
name = "com_google_gapic_showcase",
strip_prefix = "gapic-showcase-{}".format(_commit_sha),
urls = ["https://github.com/googleapis/gapic-showcase/archive/{}.zip".format(_commit_sha)],
)

def gapic_generator_register_toolchains():
native.register_toolchains(
"@gapic_generator_python//:pandoc_toolchain_linux",
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ INTEGRATION_TEST_LIBRARIES = [
"eventarc", # create_channel is a reserved term in transport layer.
"logging", # Java package remapping in gapic.yaml.
"redis", # Has a gapic.yaml.
"showcase",
]

[integration_test(
Expand Down Expand Up @@ -173,5 +174,31 @@ test_suite(
":credentials_py_gapic_test",
":eventarc_py_gapic_test",
":redis_py_gapic_test",
":showcase_py_gapic_test",
],
)

# Showcase
py_gapic_library(
name = "showcase_py_gapic",
srcs = ["@com_google_gapic_showcase//schema/google/showcase/v1beta1:showcase_proto"],
grpc_service_config = "showcase_grpc_service_config.json",
opt_args = [
"autogen-snippets=False", # See https://github.com/googleapis/gapic-generator-python/issues/1990
],
service_yaml = "showcase_v1beta1.yaml",
transport = "grpc+rest",
deps = [":iam_policy_py_proto"],
)

py_test(
name = "showcase_py_gapic_test",
srcs = [
"showcase_py_gapic_pytest.py",
"showcase_py_gapic_test.py",
],
legacy_create_init = False,
deps = [
":showcase_py_gapic",
],
)
13 changes: 13 additions & 0 deletions tests/integration/goldens/showcase/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[run]
branch = True

[report]
show_missing = True
omit =
google/showcase/__init__.py
google/showcase/gapic_version.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
33 changes: 33 additions & 0 deletions tests/integration/goldens/showcase/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
#
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Generated by synthtool. DO NOT EDIT!
[flake8]
ignore = E203, E266, E501, W503
exclude =
# Exclude generated code.
**/proto/**
**/gapic/**
**/services/**
**/types/**
*_pb2.py

# Standard linting exemptions.
**/.nox/**
__pycache__,
.git,
*.pyc,
conf.py
12 changes: 12 additions & 0 deletions tests/integration/goldens/showcase/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package(default_visibility = ["//visibility:public"])

filegroup(
name = "goldens_files",
srcs = glob(
["**/*"],
exclude = [
"BUILD.bazel",
".*.sw*",
],
),
)
2 changes: 2 additions & 0 deletions tests/integration/goldens/showcase/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-include google/showcase *.py
recursive-include google/showcase_v1beta1 *.py
49 changes: 49 additions & 0 deletions tests/integration/goldens/showcase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Python Client for Google Showcase API
=================================================

Quick Start
-----------

In order to use this library, you first need to go through the following steps:

1. `Select or create a Cloud Platform project.`_
2. `Enable billing for your project.`_
3. Enable the Google Showcase API.
4. `Setup Authentication.`_

.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html

Installation
~~~~~~~~~~~~

Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
create isolated Python environments. The basic problem it addresses is one of
dependencies and versions, and indirectly permissions.

With `virtualenv`_, it's possible to install this library without needing system
install permissions, and without clashing with the installed system
dependencies.

.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/


Mac/Linux
^^^^^^^^^

.. code-block:: console

python3 -m venv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install /path/to/library


Windows
^^^^^^^

.. code-block:: console

python3 -m venv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install \path\to\library
3 changes: 3 additions & 0 deletions tests/integration/goldens/showcase/docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dl.field-list > dt {
min-width: 100px
}
Loading
Loading