Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 129e41e

Browse filesBrowse files
authored
Merge pull request #6 from googleapis/master
feat: update docs and nox file to compile it (#610)
2 parents caf5a43 + 876f2fc commit 129e41e
Copy full SHA for 129e41e

File tree

Expand file treeCollapse file tree

10 files changed

+137
-28
lines changed
Filter options
Expand file treeCollapse file tree

10 files changed

+137
-28
lines changed

‎.gitignore

Copy file name to clipboardExpand all lines: .gitignore
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ bin
1212
MANIFEST
1313
django_tests
1414
__pycache__
15-
15+
# The directory into which Django has been cloned to run the test suite.
16+
django_tests_dir
1617
# Unit test / coverage reports
1718
.coverage
1819
.nox

‎docs/_static/custom.css

Copy file name to clipboard
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
div#python2-eol {
2+
border-color: red;
3+
border-width: medium;
4+
}
5+
6+
/* Ensure minimum width for 'Parameters' / 'Returns' column */
7+
dl.field-list > dt {
8+
min-width: 100px
9+
}

‎docs/api-reference.rst

Copy file name to clipboardExpand all lines: docs/api-reference.rst
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ API Reference
33

44
The following classes and methods constitute the Django Spanner API.
55

6-
[this page is under construction]
6+
.. toctree::
7+
:maxdepth: 1
8+
9+
schema-api

‎docs/conf.py

Copy file name to clipboardExpand all lines: docs/conf.py
+22-20Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818

1919
import sys
2020
import os
21-
22-
from version import __version__
21+
import shlex
2322

2423
# If extensions (or modules to document with autodoc) are in another directory,
2524
# add this directory to sys.path here. If the directory is relative to the
@@ -30,10 +29,12 @@
3029
# See also: https://github.com/docascode/sphinx-docfx-yaml/issues/85
3130
sys.path.insert(0, os.path.abspath("."))
3231

32+
__version__ = ""
33+
3334
# -- General configuration ------------------------------------------------
3435

3536
# If your documentation needs a minimal Sphinx version, state it here.
36-
needs_sphinx = "1.6.3"
37+
needs_sphinx = "1.5.5"
3738

3839
# Add any Sphinx extension module names here, as strings. They can be
3940
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -43,6 +44,7 @@
4344
"sphinx.ext.autosummary",
4445
"sphinx.ext.intersphinx",
4546
"sphinx.ext.coverage",
47+
"sphinx.ext.doctest",
4648
"sphinx.ext.napoleon",
4749
"sphinx.ext.todo",
4850
"sphinx.ext.viewcode",
@@ -171,7 +173,7 @@
171173
# Add any paths that contain custom static files (such as style sheets) here,
172174
# relative to this directory. They are copied after the builtin static files,
173175
# so a file named "default.css" will overwrite the builtin "default.css".
174-
# html_static_path = ["_static"]
176+
html_static_path = ["_static"]
175177

176178
# Add any extra paths that contain custom files (such as robots.txt or
177179
# .htaccess) here, relative to this directory. These files are copied
@@ -255,28 +257,28 @@
255257
# -- Options for LaTeX output ---------------------------------------------
256258

257259
latex_elements = {
258-
# # The paper size ('letterpaper' or 'a4paper').
260+
# The paper size ('letterpaper' or 'a4paper').
259261
# 'papersize': 'letterpaper',
260-
# # The font size ('10pt', '11pt' or '12pt').
262+
# The font size ('10pt', '11pt' or '12pt').
261263
# 'pointsize': '10pt',
262-
# # Additional stuff for the LaTeX preamble.
264+
# Additional stuff for the LaTeX preamble.
263265
# 'preamble': '',
264-
# # Latex figure (float) alignment
266+
# Latex figure (float) alignment
265267
# 'figure_align': 'htbp',
266268
}
267269

268270
# Grouping the document tree into LaTeX files. List of tuples
269271
# (source_start_file, target_name, title, author,
270272
# documentclass ["howto", "manual", or "own class"]). E.g.,
271-
# latex_documents = [
272-
# (
273-
# master_doc,
274-
# "django-google-spanner.tex",
275-
# u"Spanner Django Documentation",
276-
# author,
277-
# "manual",
278-
# )
279-
# ]
273+
latex_documents = [
274+
(
275+
master_doc,
276+
"django-google-spanner.tex",
277+
u"Spanner Django Documentation",
278+
author,
279+
"manual",
280+
)
281+
]
280282

281283
# The name of an image file (relative to this directory)
282284
# to place at the top of the title page.
@@ -349,13 +351,13 @@
349351

350352
# Example configuration for intersphinx: refer to the Python standard library.
351353
intersphinx_mapping = {
352-
"python": ("http://python.readthedocs.org/en/latest/", None),
353-
"google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
354+
"python": ("https://python.readthedocs.org/en/latest/", None),
355+
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
354356
"google.api_core": (
355357
"https://googleapis.dev/python/google-api-core/latest/",
356358
None,
357359
),
358-
"grpc": ("https://grpc.io/grpc/python/", None),
360+
"grpc": ("https://grpc.github.io/grpc/python/", None),
359361
}
360362

361363

‎docs/index.rst

Copy file name to clipboardExpand all lines: docs/index.rst
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
.. include:: README.rst
22

3+
Usage Documentation
4+
-------------------
5+
.. toctree::
6+
:maxdepth: 1
7+
:titlesonly:
8+
9+
schema-usage
10+
311
API Documentation
412
-----------------
513
.. toctree::

‎docs/schema-api.rst

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Schema API
2+
=====================
3+
4+
.. automodule:: django_spanner.schema
5+
:members:
6+
:inherited-members:
7+
8+

‎docs/schema-usage.rst

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Schema
2+
####################################
3+
4+
[this page is under construction]

‎noxfile.py

Copy file name to clipboardExpand all lines: noxfile.py
+22-2Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,37 @@ def default(session):
8585
)
8686

8787

88+
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
89+
def unit(session):
90+
"""Run the unit test suite."""
91+
default(session)
92+
93+
94+
@nox.session(python=DEFAULT_PYTHON_VERSION)
95+
def cover(session):
96+
"""Run the final coverage report.
97+
98+
This outputs the coverage report aggregating coverage from the unit
99+
test runs (not system test runs), and then erases coverage data.
100+
"""
101+
session.install("coverage", "pytest-cov")
102+
session.run("coverage", "report", "--show-missing", "--fail-under=20")
103+
104+
session.run("coverage", "erase")
105+
106+
88107
@nox.session(python=DEFAULT_PYTHON_VERSION)
89108
def docs(session):
90109
"""Build the docs for this library."""
91110

92111
session.install("-e", ".[tracing]")
93-
session.install("sphinx", "alabaster", "recommonmark")
112+
session.install("sphinx", "alabaster", "recommonmark", "django==2.2")
94113

95114
shutil.rmtree(os.path.join("docs", "_build"), ignore_errors=True)
115+
# Warnings as errors is disabled for `sphinx-build` because django module
116+
# has warnings.
96117
session.run(
97118
"sphinx-build",
98-
"-W", # warnings as errors
99119
"-T", # show full traceback on exception
100120
"-N", # no colors
101121
"-b",

‎tests/unit/django_spanner/test_base.py

Copy file name to clipboardExpand all lines: tests/unit/django_spanner/test_base.py
+14-4Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66

77
import sys
88
import unittest
9+
import os
910

1011
from mock_import import mock_import
1112
from unittest import mock
1213

1314

1415
@mock_import()
15-
@unittest.skipIf(sys.version_info < (3, 6), reason="Skipping Python 3.5")
16+
@unittest.skipIf(
17+
sys.version_info < (3, 6), reason="Skipping Python versions <= 3.5"
18+
)
1619
class TestBase(unittest.TestCase):
17-
PROJECT = "project"
20+
PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"]
1821
INSTANCE_ID = "instance_id"
1922
DATABASE_ID = "database_id"
2023
USER_AGENT = "django_spanner/2.2.0a1"
@@ -64,10 +67,10 @@ def test_get_connection_params(self):
6467
def test_get_new_connection(self):
6568
db_wrapper = self._make_one(self.settings_dict)
6669
db_wrapper.Database = mock_database = mock.MagicMock()
67-
mock_database.connect = mock_connect = mock.MagicMock()
70+
mock_database.connect = mock_connection = mock.MagicMock()
6871
conn_params = {"test_param": "dummy"}
6972
db_wrapper.get_new_connection(conn_params)
70-
mock_connect.assert_called_once_with(**conn_params)
73+
mock_connection.assert_called_once_with(**conn_params)
7174

7275
def test_init_connection_state(self):
7376
db_wrapper = self._make_one(self.settings_dict)
@@ -106,3 +109,10 @@ def test_is_usable(self):
106109

107110
mock_connection.cursor = mock.MagicMock(side_effect=Error)
108111
self.assertFalse(db_wrapper.is_usable())
112+
113+
def test__start_transaction_under_autocommit(self):
114+
db_wrapper = self._make_one(self.settings_dict)
115+
db_wrapper.connection = mock_connection = mock.MagicMock()
116+
mock_connection.cursor = mock_cursor = mock.MagicMock()
117+
db_wrapper._start_transaction_under_autocommit()
118+
mock_cursor.assert_called_once_with()
+44Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 sys
8+
import unittest
9+
import os
10+
11+
12+
@unittest.skipIf(
13+
sys.version_info < (3, 6), reason="Skipping Python versions <= 3.5"
14+
)
15+
class TestClient(unittest.TestCase):
16+
PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"]
17+
INSTANCE_ID = "instance_id"
18+
DATABASE_ID = "database_id"
19+
USER_AGENT = "django_spanner/2.2.0a1"
20+
OPTIONS = {"option": "dummy"}
21+
22+
settings_dict = {
23+
"PROJECT": PROJECT,
24+
"INSTANCE": INSTANCE_ID,
25+
"NAME": DATABASE_ID,
26+
"user_agent": USER_AGENT,
27+
"OPTIONS": OPTIONS,
28+
}
29+
30+
def _get_target_class(self):
31+
from django_spanner.client import DatabaseClient
32+
33+
return DatabaseClient
34+
35+
def _make_one(self, *args, **kwargs):
36+
return self._get_target_class()(*args, **kwargs)
37+
38+
def test_runshell(self):
39+
from google.cloud.spanner_dbapi.exceptions import NotSupportedError
40+
41+
db_wrapper = self._make_one(self.settings_dict)
42+
43+
with self.assertRaises(NotSupportedError):
44+
db_wrapper.runshell(parameters=self.settings_dict)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.