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)