From dc73bf65f9dbe0f9a62059ea23c6423dfcfd1901 Mon Sep 17 00:00:00 2001 From: MF2199 <38331387+mf2199@users.noreply.github.com> Date: Tue, 8 Sep 2020 15:33:03 -0400 Subject: [PATCH] feat: Stage 6 of `nox` implementation - enabling system tests (#480) Add googleapis/python-test-utils and system test stub --- .gitignore | 10 ++++++++-- noxfile.py | 31 +++++++++++++++++++++++++++++++ tests/system/__init__.py | 5 +++++ tests/system/test_system.py | 22 ++++++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 tests/system/__init__.py create mode 100644 tests/system/test_system.py diff --git a/.gitignore b/.gitignore index 0b5859361d..efe8469b33 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,22 @@ -*.py[co] +*.py[cod] *.sw[op] # Packages +*.egg *.egg-info +dist build +eggs +.eggs +bin MANIFEST -dist django_tests +__pycache__ # Unit test / coverage reports .coverage .nox +.pytest_cache # JetBrains .idea diff --git a/noxfile.py b/noxfile.py index 016fe33c39..b1aa46bf51 100644 --- a/noxfile.py +++ b/noxfile.py @@ -87,6 +87,37 @@ def unit(session): default(session) +@nox.session(python="3.8") +def system(session): + """Run the system test suite.""" + system_test_path = os.path.join("tests", "system.py") + system_test_folder_path = os.path.join("tests", "system") + + # Sanity check: Only run tests if the environment variable is set. + if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): + session.skip("Credentials must be set via environment variable") + + system_test_exists = os.path.exists(system_test_path) + system_test_folder_exists = os.path.exists(system_test_folder_path) + + # Sanity check: only run tests if found. + if not system_test_exists and not system_test_folder_exists: + session.skip("System tests were not found") + + # Install all test dependencies, then install this package into the + # virtualenv's dist-packages. + session.install("mock", "pytest", "google-cloud-testutils") + session.install("-e", ".") + + # Run py.test against the system tests. + if system_test_exists: + session.run("py.test", "--quiet", system_test_path, *session.posargs) + if system_test_folder_exists: + session.run( + "py.test", "--quiet", system_test_folder_path, *session.posargs + ) + + @nox.session(python="3.8") def cover(session): """Run the final coverage report. diff --git a/tests/system/__init__.py b/tests/system/__init__.py new file mode 100644 index 0000000000..6b607710ed --- /dev/null +++ b/tests/system/__init__.py @@ -0,0 +1,5 @@ +# Copyright 2020 Google LLC +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd diff --git a/tests/system/test_system.py b/tests/system/test_system.py new file mode 100644 index 0000000000..5710ba6ce6 --- /dev/null +++ b/tests/system/test_system.py @@ -0,0 +1,22 @@ +# Copyright 2020 Google LLC +# +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file or at +# https://developers.google.com/open-source/licenses/bsd + +import unittest + + +class TestSpannerDjangoDBAPI(unittest.TestCase): + def setUp(self): + # TODO: Implement this method + pass + + def tearDown(self): + # TODO: Implement this method + pass + + def test_api(self): + # An dummy stub to avoid `exit code 5` errors + # TODO: Replace this with an actual system test method + self.assertTrue(True)