10000 feat: Stage 6 of `nox` implementation - enabling system tests by mf2199 · Pull Request #480 · googleapis/python-spanner-django · GitHub
[go: up one dir, main page]

Skip to content
10000

feat: Stage 6 of nox implementation - enabling system tests #480

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

Merged
merged 6 commits into from
Sep 8, 2020
Merged
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
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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