diff --git a/.gitignore b/.gitignore index 4a39372126..a853529eef 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,7 @@ django_tests_dir # Built documentation docs/_build + +# mac hidden files. +.DS_Store + diff --git a/noxfile.py b/noxfile.py index 1f70054f5f..5d65eb6153 100644 --- a/noxfile.py +++ b/noxfile.py @@ -25,7 +25,7 @@ DEFAULT_PYTHON_VERSION = "3.8" SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] -UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8"] +UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] @nox.session(python=DEFAULT_PYTHON_VERSION) @@ -104,7 +104,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=20") + session.run("coverage", "report", "--show-missing", "--fail-under=65") session.run("coverage", "erase") @@ -130,3 +130,42 @@ def docs(session): os.path.join("docs", ""), os.path.join("docs", "_build", "html", ""), ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def docfx(session): + """Build the docfx yaml files for this library.""" + + session.install("-e", ".[tracing]") + session.install( + "sphinx", + "alabaster", + "recommonmark", + "gcp-sphinx-docfx-yaml", + "django==2.2", + ) + + shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True) + session.run( + "sphinx-build", + "-T", # show full traceback on exception + "-N", # no colors + "-D", + ( + "extensions=sphinx.ext.autodoc," + "sphinx.ext.autosummary," + "docfx_yaml.extension," + "sphinx.ext.intersphinx," + "sphinx.ext.coverage," + "sphinx.ext.napoleon," + "sphinx.ext.todo," + "sphinx.ext.viewcode," + "recommonmark" + ), + "-b", + "html", + "-d", + os.path.join("docs", "_build", "doctrees", ""), + os.path.join("docs", ""), + os.path.join("docs", "_build", "html", ""), + ) diff --git a/setup.py b/setup.py index 5ca8570a3d..f37e04b0c1 100644 --- a/setup.py +++ b/setup.py @@ -56,6 +56,7 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Topic :: Utilities", "Framework :: Django", "Framework :: Django :: 2.2", diff --git a/tests/conftest.py b/tests/unit/conftest.py similarity index 82% rename from tests/conftest.py rename to tests/unit/conftest.py index 308a903387..f4be037821 100644 --- a/tests/conftest.py +++ b/tests/unit/conftest.py @@ -4,7 +4,7 @@ # We manually designate which settings we will be using in an environment # variable. This is similar to what occurs in the `manage.py` file. -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.unit.settings") # `pytest` automatically calls this function once when tests are run. diff --git a/tests/settings.py b/tests/unit/settings.py similarity index 70% rename from tests/settings.py rename to tests/unit/settings.py index ecf6567d46..1e44e6e11f 100644 --- a/tests/settings.py +++ b/tests/unit/settings.py @@ -4,6 +4,9 @@ # license that can be found in the LICENSE file or at # https://developers.google.com/open-source/licenses/bsd +import time +import os + DEBUG = True USE_TZ = True @@ -20,12 +23,20 @@ TIME_ZONE = "UTC" +ENGINE = "django_spanner" +PROJECT = os.getenv( + "GOOGLE_CLOUD_PROJECT", os.getenv("PROJECT_ID", "emulator-test-project"), +) + +INSTANCE = "django-test-instance" +NAME = "spanner-django-test-{}".format(str(int(time.time()))) + DATABASES = { "default": { - "ENGINE": "django_spanner", - "PROJECT": "emulator-local", - "INSTANCE": "django-test-instance", - "NAME": "django-test-db", + "ENGINE": ENGINE, + "PROJECT": PROJECT, + "INSTANCE": INSTANCE, + "NAME": NAME, } } SECRET_KEY = "spanner emulator secret key"