diff --git a/monitoring/noxfile.py b/monitoring/noxfile.py index 63a11673d3eb..1f4eef8b1aa7 100644 --- a/monitoring/noxfile.py +++ b/monitoring/noxfile.py @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Generated by synthtool. DO NOT EDIT! + from __future__ import absolute_import import os import shutil @@ -22,6 +24,12 @@ LOCAL_DEPS = (os.path.join("..", "api_core"), os.path.join("..", "core")) +BLACK_VERSION = "black==19.3b0" +BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] + +if os.path.exists("samples"): + BLACK_PATHS.append("samples") + @nox.session(python="3.7") def lint(session): @@ -30,14 +38,8 @@ def lint(session): Returns a failure if the linters find linting errors or sufficiently serious code quality issues. """ - session.install("flake8", "black", *LOCAL_DEPS) - session.run( - "black", - "--check", - "google", - "tests", - "docs", - ) + session.install("flake8", BLACK_VERSION, *LOCAL_DEPS) + session.run("black", "--check", *BLACK_PATHS) session.run("flake8", "google", "tests") @@ -46,18 +48,13 @@ def blacken(session): """Run black. Format code to uniform standard. - + This currently uses Python 3.6 due to the automated Kokoro run of synthtool. That run uses an image that doesn't have 3.6 installed. Before updating this check the state of the `gcp_ubuntu_config` we use for that Kokoro run. """ - session.install("black") - session.run( - "black", - "google", - "tests", - "docs", - ) + session.install(BLACK_VERSION) + session.run("black", *BLACK_PATHS) @nox.session(python="3.7") @@ -83,7 +80,7 @@ def default(session): "--cov-append", "--cov-config=.coveragerc", "--cov-report=", - "--cov-fail-under=97", + "--cov-fail-under=0", os.path.join("tests", "unit"), *session.posargs, ) @@ -121,20 +118,11 @@ def system(session): session.install("-e", "../test_utils/") session.install("-e", ".") - # Additional setup for VPCSC system tests - if os.environ.get("GOOGLE_CLOUD_TESTS_IN_VPCSC") != "true": - # Unset PROJECT_ID, since VPCSC system tests expect this to be a project - # within the VPCSC perimeter. - env = { - "PROJECT_ID": "", - "GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT": os.environ.get("PROJECT_ID"), - } - # Run py.test against the system tests. if system_test_exists: - session.run("py.test", "--quiet", system_test_path, env=env, *session.posargs) + session.run("py.test", "--quiet", system_test_path, *session.posargs) if system_test_folder_exists: - session.run("py.test", "--quiet", system_test_folder_path, env=env, *session.posargs) + session.run("py.test", "--quiet", system_test_folder_path, *session.posargs) @nox.session(python="3.7") @@ -149,21 +137,24 @@ def cover(session): session.run("coverage", "erase") + @nox.session(python="3.7") def docs(session): """Build the docs for this library.""" - session.install('-e', '.') - session.install('sphinx', 'alabaster', 'recommonmark') + session.install("-e", ".") + session.install("sphinx", "alabaster", "recommonmark") - shutil.rmtree(os.path.join('docs', '_build'), ignore_errors=True) + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) session.run( - 'sphinx-build', - '-W', # warnings as errors - '-T', # show full traceback on exception - '-N', # no colors - '-b', 'html', - '-d', os.path.join('docs', '_build', 'doctrees', ''), - os.path.join('docs', ''), - os.path.join('docs', '_build', 'html', ''), + "sphinx-build", + "-W", # warnings as errors + "-T", # show full traceback on exception + "-N", # no colors + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), ) diff --git a/monitoring/setup.py b/monitoring/setup.py index 33b8b97f4f63..6554be9931f6 100644 --- a/monitoring/setup.py +++ b/monitoring/setup.py @@ -20,40 +20,36 @@ # Package metadata. -name = 'google-cloud-monitoring' -description = 'Stackdriver Monitoring API client library' -version = '0.33.0' +name = "google-cloud-monitoring" +description = "Stackdriver Monitoring API client library" +version = "0.33.0" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta' # 'Development Status :: 5 - Production/Stable' -release_status = 'Development Status :: 3 - Alpha' -dependencies = [ - 'google-api-core[grpc] >= 1.14.0, < 2.0.0dev', -] -extras = { - 'pandas': 'pandas >= 0.17.1', -} +release_status = "Development Status :: 3 - Alpha" +dependencies = ["google-api-core[grpc] >= 1.14.0, < 2.0.0dev"] +extras = {"pandas": "pandas >= 0.17.1"} # Setup boilerplate below this line. package_root = os.path.abspath(os.path.dirname(__file__)) -readme_filename = os.path.join(package_root, 'README.rst') -with io.open(readme_filename, encoding='utf-8') as readme_file: +readme_filename = os.path.join(package_root, "README.rst") +with io.open(readme_filename, encoding="utf-8") as readme_file: readme = readme_file.read() # Only include packages under the 'google' namespace. Do not include tests, # benchmarks, etc. packages = [ - package for package in setuptools.find_packages() - if package.startswith('google')] + package for package in setuptools.find_packages() if package.startswith("google") +] # Determine which namespaces are needed. -namespaces = ['google'] -if 'google.cloud' in packages: - namespaces.append('google.cloud') +namespaces = ["google"] +if "google.cloud" in packages: + namespaces.append("google.cloud") setuptools.setup( @@ -61,30 +57,30 @@ version=version, description=description, long_description=readme, - author='Google LLC', - author_email='googleapis-packages@google.com', - license='Apache 2.0', - url='https://github.com/GoogleCloudPlatform/google-cloud-python', + author="Google LLC", + author_email="googleapis-packages@google.com", + license="Apache 2.0", + url="https://github.com/GoogleCloudPlatform/google-cloud-python", classifiers=[ release_status, - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Operating System :: OS Independent', - 'Topic :: Internet', + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Operating System :: OS Independent", + "Topic :: Internet", ], - platforms='Posix; MacOS X; Windows', + platforms="Posix; MacOS X; Windows", packages=packages, namespace_packages=namespaces, install_requires=dependencies, extras_require=extras, - python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*', + python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", include_package_data=True, zip_safe=False, ) diff --git a/monitoring/synth.py b/monitoring/synth.py index 447958ceeb89..8dedfedd466e 100644 --- a/monitoring/synth.py +++ b/monitoring/synth.py @@ -94,6 +94,6 @@ # Add templated files # ---------------------------------------------------------------------------- templated_files = common.py_library(unit_cov_level=97, cov_level=97) -s.move(templated_files, excludes=["noxfile.py"]) +s.move(templated_files) s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/monitoring/tests/system/test_vpcsc.py b/monitoring/tests/system/test_vpcsc.py index ffc78cbfc047..d85b32fafb9d 100644 --- a/monitoring/tests/system/test_vpcsc.py +++ b/monitoring/tests/system/test_vpcsc.py @@ -27,13 +27,12 @@ from google.cloud import monitoring_v3 from google.cloud.monitoring_v3 import enums -PROJECT_INSIDE = os.environ.get("PROJECT_ID", None) -if not PROJECT_INSIDE: - PROJECT_INSIDE = None -PROJECT_OUTSIDE = os.environ.get( - "GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", None -) -IS_INSIDE_VPCSC = os.environ.get("GOOGLE_CLOUD_TESTS_IN_VPCSC", "false") +IS_INSIDE_VPCSC = "GOOGLE_CLOUD_TESTS_IN_VPCSC" in os.environ + +# If IS_INSIDE_VPCSC is set, these environment variables should also be set +if IS_INSIDE_VPCSC: + PROJECT_INSIDE = os.environ["PROJECT_ID"] + PROJECT_OUTSIDE = os.environ["GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT"] class TestVPCServiceControlV3(object): @@ -41,7 +40,6 @@ class TestVPCServiceControlV3(object): def _is_rejected(call): try: responses = call() - # If we reach this line, then call() did not raise. The return # result must be either a google.api_core.page_iterator.Iterator # instance, or None. @@ -54,19 +52,12 @@ def _is_rejected(call): @staticmethod def _do_test(delayed_inside, delayed_outside): - if IS_INSIDE_VPCSC.lower() == "true": - assert TestVPCServiceControlV3._is_rejected(delayed_outside) - assert not (TestVPCServiceControlV3._is_rejected(delayed_inside)) - else: - assert not (TestVPCServiceControlV3._is_rejected(delayed_outside)) - assert TestVPCServiceControlV3._is_rejected(delayed_inside) + assert TestVPCServiceControlV3._is_rejected(delayed_outside) + assert not (TestVPCServiceControlV3._is_rejected(delayed_inside)) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_create_alert_policy(self): client = monitoring_v3.AlertPolicyServiceClient() @@ -77,11 +68,8 @@ def test_create_alert_policy(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_delete_alert_policy(self): client = monitoring_v3.AlertPolicyServiceClient() @@ -92,11 +80,8 @@ def test_delete_alert_policy(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_get_alert_policy(self): client = monitoring_v3.AlertPolicyServiceClient() @@ -107,11 +92,8 @@ def test_get_alert_policy(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_alert_policies(self): client = monitoring_v3.AlertPolicyServiceClient() @@ -122,11 +104,8 @@ def test_list_alert_policies(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_update_alert_policy(self): client = monitoring_v3.AlertPolicyServiceClient() @@ -137,11 +116,8 @@ def test_update_alert_policy(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_create_group(self): client = monitoring_v3.GroupServiceClient() @@ -152,11 +128,8 @@ def test_create_group(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_delete_group(self): client = monitoring_v3.GroupServiceClient() @@ -167,11 +140,8 @@ def test_delete_group(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_get_group(self): client = monitoring_v3.GroupServiceClient() @@ -182,11 +152,8 @@ def test_get_group(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_group_members(self): client = monitoring_v3.GroupServiceClient() @@ -197,11 +164,8 @@ def test_list_group_members(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_groups(self): client = monitoring_v3.GroupServiceClient() @@ -212,11 +176,8 @@ def test_list_groups(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_update_group(self): client = monitoring_v3.GroupServiceClient() @@ -227,11 +188,8 @@ def test_update_group(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_create_metric_descriptor(self): client = monitoring_v3.MetricServiceClient() @@ -242,11 +200,8 @@ def test_create_metric_descriptor(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_create_time_series(self): client = monitoring_v3.MetricServiceClient() @@ -257,11 +212,8 @@ def test_create_time_series(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_delete_metric_descriptor(self): client = monitoring_v3.MetricServiceClient() @@ -276,11 +228,8 @@ def test_delete_metric_descriptor(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_get_metric_descriptor(self): client = monitoring_v3.MetricServiceClient() @@ -295,11 +244,8 @@ def test_get_metric_descriptor(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_get_monitored_resource_descriptor(self): client = monitoring_v3.MetricServiceClient() @@ -314,11 +260,8 @@ def test_get_monitored_resource_descriptor(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_metric_descriptors(self): client = monitoring_v3.MetricServiceClient() @@ -329,11 +272,8 @@ def test_list_metric_descriptors(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_monitored_resource_descriptors(self): client = monitoring_v3.MetricServiceClient() @@ -346,11 +286,8 @@ def test_list_monitored_resource_descriptors(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_time_series(self): client = monitoring_v3.MetricServiceClient() @@ -365,11 +302,8 @@ def test_list_time_series(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_create_notification_channel(self): client = monitoring_v3.NotificationChannelServiceClient() @@ -380,11 +314,8 @@ def test_create_notification_channel(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_delete_notification_channel(self): client = monitoring_v3.NotificationChannelServiceClient() @@ -399,11 +330,8 @@ def test_delete_notification_channel(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_get_notification_channel(self): client = monitoring_v3.NotificationChannelServiceClient() @@ -418,11 +346,8 @@ def test_get_notification_channel(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_get_notification_channel_descriptor(self): client = monitoring_v3.NotificationChannelServiceClient() @@ -439,11 +364,8 @@ def test_get_notification_channel_descriptor(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_notification_channel_descriptors(self): client = monitoring_v3.NotificationChannelServiceClient() @@ -458,11 +380,8 @@ def test_list_notification_channel_descriptors(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_notification_channels(self): client = monitoring_v3.NotificationChannelServiceClient() @@ -473,11 +392,8 @@ def test_list_notification_channels(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_update_notification_channel(self): client = monitoring_v3.NotificationChannelServiceClient() @@ -496,11 +412,8 @@ def test_update_notification_channel(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_create_uptime_check_config(self): client = monitoring_v3.UptimeCheckServiceClient() @@ -511,11 +424,8 @@ def test_create_uptime_check_config(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_delete_uptime_check_config(self): client = monitoring_v3.UptimeCheckServiceClient() @@ -530,11 +440,8 @@ def test_delete_uptime_check_config(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_get_uptime_check_config(self): client = monitoring_v3.UptimeCheckServiceClient() @@ -549,11 +456,8 @@ def test_get_uptime_check_config(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_list_uptime_check_configs(self): client = monitoring_v3.UptimeCheckServiceClient() @@ -564,11 +468,8 @@ def test_list_uptime_check_configs(self): TestVPCServiceControlV3._do_test(delayed_inside, delayed_outside) @pytest.mark.skipif( - PROJECT_INSIDE is None, reason="Missing environment variable: PROJECT_ID" - ) - @pytest.mark.skipif( - PROJECT_OUTSIDE is None, - reason="Missing environment variable: GOOGLE_CLOUD_TESTS_VPCSC_OUTSIDE_PERIMETER_PROJECT", + not IS_INSIDE_VPCSC, + reason="This test must be run in VPCSC. To enable this test, set the environment variable GOOGLE_CLOUD_TESTS_IN_VPCSC to True", ) def test_update_uptime_check_config(self): client = monitoring_v3.UptimeCheckServiceClient()