Skip to content

Commit

Permalink
ci: add build for docfx and refactor settings for unit tests (#626)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
vi3k6i5 committed May 19, 2021
1 parent d09ad61 commit 3a8d922
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 7 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -24,3 +24,7 @@ django_tests_dir

# Built documentation
docs/_build

# mac hidden files.
.DS_Store

43 changes: 41 additions & 2 deletions noxfile.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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")

Expand All @@ -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", ""),
)
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py → tests/unit/conftest.py
Expand Up @@ -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.
Expand Down
19 changes: 15 additions & 4 deletions tests/settings.py → tests/unit/settings.py
Expand Up @@ -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

Expand All @@ -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"
Expand Down

0 comments on commit 3a8d922

Please sign in to comment.