Skip to content
This repository was archived by the owner on Mar 20, 2026. It is now read-only.

Commit 3a8d922

Browse files
authored
ci: add build for docfx and refactor settings for unit tests (#626)
* feat: updated nox file for docs and docfx and added unit tests for client * fix: lint_setup_py was failing in Kokoro is not fixed * feat: updated nox file for docs and docfx and added unit tests for client * feat: added docfx build in nox file * feat: updated nox file for docs and docfx and added unit tests for client * feat: added docfx build in nox file * feat: adding unit tests for django spanner * feat: updated nox file for docs and docfx and added unit tests for client * feat: added docfx build in nox file * feat: updated nox file for docs and docfx and added unit tests for client * feat: added docfx build in nox file * feat: updated nox file for docs and docfx and added unit tests for client * feat: adding unit tests for django spanner * bug: fixed schema tests settings to create instance and delete it after test completion * bug: test fixes for schema file * feat: added unit test coverage for functions, introspection and schema * refactor: lint the code * refactor: removed unrelated code from PR * ci: added build for docfx and refactores settings for unit tests * build: added python 3.9 in setup file * refactor: changed coverage check to 65 from 68 to be conservative in the estimates
1 parent d09ad61 commit 3a8d922

5 files changed

Lines changed: 62 additions & 7 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ django_tests_dir
2424

2525
# Built documentation
2626
docs/_build
27+
28+
# mac hidden files.
29+
.DS_Store
30+

noxfile.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
DEFAULT_PYTHON_VERSION = "3.8"
2727
SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"]
28-
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8"]
28+
UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
2929

3030

3131
@nox.session(python=DEFAULT_PYTHON_VERSION)
@@ -104,7 +104,7 @@ def cover(session):
104104
test runs (not system test runs), and then erases coverage data.
105105
"""
106106
session.install("coverage", "pytest-cov")
107-
session.run("coverage", "report", "--show-missing", "--fail-under=20")
107+
session.run("coverage", "report", "--show-missing", "--fail-under=65")
108108

109109
session.run("coverage", "erase")
110110

@@ -130,3 +130,42 @@ def docs(session):
130130
os.path.join("docs", ""),
131131
os.path.join("docs", "_build", "html", ""),
132132
)
133+
134+
135+
@nox.session(python=DEFAULT_PYTHON_VERSION)
136+
def docfx(session):
137+
"""Build the docfx yaml files for this library."""
138+
139+
session.install("-e", ".[tracing]")
140+
session.install(
141+
"sphinx",
142+
"alabaster",
143+
"recommonmark",
144+
"gcp-sphinx-docfx-yaml",
145+
"django==2.2",
146+
)
147+
148+
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
149+
session.run(
150+
"sphinx-build",
151+
"-T", # show full traceback on exception
152+
"-N", # no colors
153+
"-D",
154+
(
155+
"extensions=sphinx.ext.autodoc,"
156+
"sphinx.ext.autosummary,"
157+
"docfx_yaml.extension,"
158+
"sphinx.ext.intersphinx,"
159+
"sphinx.ext.coverage,"
160+
"sphinx.ext.napoleon,"
161+
"sphinx.ext.todo,"
162+
"sphinx.ext.viewcode,"
163+
"recommonmark"
164+
),
165+
"-b",
166+
"html",
167+
"-d",
168+
os.path.join("docs", "_build", "doctrees", ""),
169+
os.path.join("docs", ""),
170+
os.path.join("docs", "_build", "html", ""),
171+
)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"Programming Language :: Python :: 3.6",
5757
"Programming Language :: Python :: 3.7",
5858
"Programming Language :: Python :: 3.8",
59+
"Programming Language :: Python :: 3.9",
5960
"Topic :: Utilities",
6061
"Framework :: Django",
6162
"Framework :: Django :: 2.2",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# We manually designate which settings we will be using in an environment
66
# variable. This is similar to what occurs in the `manage.py` file.
7-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")
7+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.unit.settings")
88

99

1010
# `pytest` automatically calls this function once when tests are run.
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# license that can be found in the LICENSE file or at
55
# https://developers.google.com/open-source/licenses/bsd
66

7+
import time
8+
import os
9+
710
DEBUG = True
811
USE_TZ = True
912

@@ -20,12 +23,20 @@
2023

2124
TIME_ZONE = "UTC"
2225

26+
ENGINE = "django_spanner"
27+
PROJECT = os.getenv(
28+
"GOOGLE_CLOUD_PROJECT", os.getenv("PROJECT_ID", "emulator-test-project"),
29+
)
30+
31+
INSTANCE = "django-test-instance"
32+
NAME = "spanner-django-test-{}".format(str(int(time.time())))
33+
2334
DATABASES = {
2435
"default": {
25-
"ENGINE": "django_spanner",
26-
"PROJECT": "emulator-local",
27-
"INSTANCE": "django-test-instance",
28-
"NAME": "django-test-db",
36+
"ENGINE": ENGINE,
37+
"PROJECT": PROJECT,
38+
"INSTANCE": INSTANCE,
39+
"NAME": NAME,
2940
}
3041
}
3142
SECRET_KEY = "spanner emulator secret key"

0 commit comments

Comments
 (0)