Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: Stage 6 of nox implementation - enabling system tests (#480)
Add googleapis/python-test-utils and system test stub
  • Loading branch information
mf2199 authored and c24t committed Sep 15, 2020
1 parent a9fd5a3 commit dc73bf6
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .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
Expand Down
31 changes: 31 additions & 0 deletions noxfile.py
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions 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
22 changes: 22 additions & 0 deletions 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)

0 comments on commit dc73bf6

Please sign in to comment.