8000 feat: Stage 6 of `nox` implementation - enabling system tests (#480) · googleapis/python-spanner-django@94ba284 · GitHub
[go: up one dir, main page]

Skip to content

Commit 94ba284

Browse files
authored
feat: Stage 6 of nox implementation - enabling system tests (#480)
Add googleapis/python-test-utils and system test stub
1 parent 6028f88 commit 94ba284

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

.gitignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
*.py[co]
1+
*.py[cod]
22
*.sw[op]
33

44
# Packages
5+
*.egg
56
*.egg-info
7+
dist
68
build
9+
eggs
10+
.eggs
11+
bin
712
MANIFEST
8-
dist
913
django_tests
14+
__pycache__
1015

1116
# Unit test / coverage reports
1217
.coverage
1318
.nox
19+
.pytest_cache
1420

1521
# JetBrains
1622
.idea

noxfile.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,37 @@ def unit(session):
8787
default(session)
8888

8989

90+
@nox.session(python="3.8")
91+
def system(session):
92+
"""Run the system test suite."""
93+
system_test_path = os.path.join("tests", "system.py")
94+
system_test_folder_path = os.path.join("tests", "system")
95+
96+
# Sanity check: Only run tests if the environment variable is set.
97+
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""):
98+
session.skip("Credentials must be set via environment variable")
99+
100+
system_test_exists = os.path.exists(system_test_path)
101+
system_test_folder_exists = os.path.exists(system_test_folder_path)
102+
103+
# Sanity check: only run tests if found.
104+
if not system_test_exists and not system_test_folder_exists:
105+
session.skip("System tests were not found")
106+
107+
# Install all test dependencies, then install this package into the
108+
# virtualenv's dist-packages.
109+
session.install("mock", "pytest", "google-cloud-testutils")
110+
session.install("-e", ".")
111+
112+
# Run py.test against the system tests.
113+
if system_test_exists:
114+
session.run("py.test", "--quiet", system_test_path, *session.posargs)
115+
if system_test_folder_exists:
116+
session.run(
117+
"py.test", "--quiet", system_test_folder_path, *session.posargs
118+
)
119+
120+
90121
@nox.session(python="3.8")
91122
def cover(session):
92123
"""Run the final coverage report.

tests/system/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Use of this source code is governed by a BSD-style
4+
# license that can be found in the LICENSE file or at
5+
# https://developers.google.com/open-source/licenses/bsd

tests/system/test_system.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Use of this source code is governed by a BSD-style
4+
# license that can be found in the LICENSE file or at
5+
# https://developers.google.com/open-source/licenses/bsd
6+
7+
import unittest
8+
9+
10+
class TestSpannerDjangoDBAPI(unittest.TestCase):
11+
def setUp(self):
12+
# TODO: Implement this method
13+
pass
14+
15+
def tearDown(self):
16+
# TODO: Implement this method
17+
pass
18+
19+
def test_api(self):
20+
# An dummy stub to avoid `exit code 5` errors
21+
# TODO: Replace this with an actual system test method
22+
self.assertTrue(True)

0 commit comments

Comments
 (0)
0