| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c386123 commit 876f2fc
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,8 @@ bin | |||
| 12 | 12 | MANIFEST | |
| 13 | 13 | django_tests | |
| 14 | 14 | __pycache__ | |
| 15 | - | ||
| 15 | + # The directory into which Django has been cloned to run the test suite. | ||
| 16 | + django_tests_dir | ||
| 16 | 17 | # Unit test / coverage reports | |
| 17 | 18 | .coverage | |
| 18 | 19 | .nox | |
| Original file line number | Diff line number | Diff 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 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,4 +3,7 @@ API Reference | |||
| 3 | 3 | ||
| 4 | 4 | The following classes and methods constitute the Django Spanner API. | |
| 5 | 5 | ||
| 6 | - [this page is under construction] | ||
| 6 | + .. toctree:: | ||
| 7 | + :maxdepth: 1 | ||
| 8 | + | ||
| 9 | + schema-api | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,8 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | import sys | |
| 20 | 20 | import os | |
| 21 | - | ||
| 22 | - from version import __version__ | ||
| 21 | + import shlex | ||
| 23 | 22 | ||
| 24 | 23 | # If extensions (or modules to document with autodoc) are in another directory, | |
| 25 | 24 | # add this directory to sys.path here. If the directory is relative to the | |
@@ -30,10 +29,12 @@ | |||
| 30 | 29 | # See also: https://github.com/docascode/sphinx-docfx-yaml/issues/85 | |
| 31 | 30 | sys.path.insert(0, os.path.abspath(".")) | |
| 32 | 31 | ||
| 32 | + __version__ = "" | ||
| 33 | + | ||
| 33 | 34 | # -- General configuration ------------------------------------------------ | |
| 34 | 35 | ||
| 35 | 36 | # If your documentation needs a minimal Sphinx version, state it here. | |
| 36 | - needs_sphinx = "1.6.3" | ||
| 37 | + needs_sphinx = "1.5.5" | ||
| 37 | 38 | ||
| 38 | 39 | # Add any Sphinx extension module names here, as strings. They can be | |
| 39 | 40 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | |
@@ -43,6 +44,7 @@ | |||
| 43 | 44 | "sphinx.ext.autosummary", | |
| 44 | 45 | "sphinx.ext.intersphinx", | |
| 45 | 46 | "sphinx.ext.coverage", | |
| 47 | + "sphinx.ext.doctest", | ||
| 46 | 48 | "sphinx.ext.napoleon", | |
| 47 | 49 | "sphinx.ext.todo", | |
| 48 | 50 | "sphinx.ext.viewcode", | |
@@ -171,7 +173,7 @@ | |||
| 171 | 173 | # Add any paths that contain custom static files (such as style sheets) here, | |
| 172 | 174 | # relative to this directory. They are copied after the builtin static files, | |
| 173 | 175 | # so a file named "default.css" will overwrite the builtin "default.css". | |
| 174 | - # html_static_path = ["_static"] | ||
| 176 | + html_static_path = ["_static"] | ||
| 175 | 177 | ||
| 176 | 178 | # Add any extra paths that contain custom files (such as robots.txt or | |
| 177 | 179 | # .htaccess) here, relative to this directory. These files are copied | |
@@ -255,28 +257,28 @@ | |||
| 255 | 257 | # -- Options for LaTeX output --------------------------------------------- | |
| 256 | 258 | ||
| 257 | 259 | latex_elements = { | |
| 258 | - # # The paper size ('letterpaper' or 'a4paper'). | ||
| 260 | + # The paper size ('letterpaper' or 'a4paper'). | ||
| 259 | 261 | # 'papersize': 'letterpaper', | |
| 260 | - # # The font size ('10pt', '11pt' or '12pt'). | ||
| 262 | + # The font size ('10pt', '11pt' or '12pt'). | ||
| 261 | 263 | # 'pointsize': '10pt', | |
| 262 | - # # Additional stuff for the LaTeX preamble. | ||
| 264 | + # Additional stuff for the LaTeX preamble. | ||
| 263 | 265 | # 'preamble': '', | |
| 264 | - # # Latex figure (float) alignment | ||
| 266 | + # Latex figure (float) alignment | ||
| 265 | 267 | # 'figure_align': 'htbp', | |
| 266 | 268 | } | |
| 267 | 269 | ||
| 268 | 270 | # Grouping the document tree into LaTeX files. List of tuples | |
| 269 | 271 | # (source_start_file, target_name, title, author, | |
| 270 | 272 | # 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 | + ] | ||
| 280 | 282 | ||
| 281 | 283 | # The name of an image file (relative to this directory) | |
| 282 | 284 | # to place at the top of the title page. | |
@@ -349,13 +351,13 @@ | |||
| 349 | 351 | ||
| 350 | 352 | # Example configuration for intersphinx: refer to the Python standard library. | |
| 351 | 353 | 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), | ||
| 354 | 356 | "google.api_core": ( | |
| 355 | 357 | "https://googleapis.dev/python/google-api-core/latest/", | |
| 356 | 358 | None, | |
| 357 | 359 | ), | |
| 358 | - "grpc": ("https://grpc.io/grpc/python/", None), | ||
| 360 | + "grpc": ("https://grpc.github.io/grpc/python/", None), | ||
| 359 | 361 | } | |
| 360 | 362 | ||
| 361 | 363 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,13 @@ | |||
| 1 | 1 | .. include:: README.rst | |
| 2 | 2 | ||
| 3 | + Usage Documentation | ||
| 4 | + ------------------- | ||
| 5 | + .. toctree:: | ||
| 6 | + :maxdepth: 1 | ||
| 7 | + :titlesonly: | ||
| 8 | + | ||
| 9 | + schema-usage | ||
| 10 | + | ||
| 3 | 11 | API Documentation | |
| 4 | 12 | ----------------- | |
| 5 | 13 | .. toctree:: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,8 @@ | |||
| 1 | + Schema API | ||
| 2 | + ===================== | ||
| 3 | + | ||
| 4 | + .. automodule:: django_spanner.schema | ||
| 5 | + :members: | ||
| 6 | + :inherited-members: | ||
| 7 | + | ||
| 8 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,4 @@ | |||
| 1 | + Schema | ||
| 2 | + #################################### | ||
| 3 | + | ||
| 4 | + [this page is under construction] | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -85,17 +85,37 @@ def default(session): | |||
| 85 | 85 | ) | |
| 86 | 86 | ||
| 87 | 87 | ||
| 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 | + | ||
| 88 | 107 | @nox.session(python=DEFAULT_PYTHON_VERSION) | |
| 89 | 108 | def docs(session): | |
| 90 | 109 | """Build the docs for this library.""" | |
| 91 | 110 | ||
| 92 | 111 | session.install("-e", ".[tracing]") | |
| 93 | - session.install("sphinx", "alabaster", "recommonmark") | ||
| 112 | + session.install("sphinx", "alabaster", "recommonmark", "django==2.2") | ||
| 94 | 113 | ||
| 95 | 114 | 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. | ||
| 96 | 117 | session.run( | |
| 97 | 118 | "sphinx-build", | |
| 98 | - "-W", # warnings as errors | ||
| 99 | 119 | "-T", # show full traceback on exception | |
| 100 | 120 | "-N", # no colors | |
| 101 | 121 | "-b", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,15 +6,18 @@ | |||
| 6 | 6 | ||
| 7 | 7 | import sys | |
| 8 | 8 | import unittest | |
| 9 | + import os | ||
| 9 | 10 | ||
| 10 | 11 | from mock_import import mock_import | |
| 11 | 12 | from unittest import mock | |
| 12 | 13 | ||
| 13 | 14 | ||
| 14 | 15 | @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 | + ) | ||
| 16 | 19 | class TestBase(unittest.TestCase): | |
| 17 | - PROJECT = "project" | ||
| 20 | + PROJECT = os.environ["GOOGLE_CLOUD_PROJECT"] | ||
| 18 | 21 | INSTANCE_ID = "instance_id" | |
| 19 | 22 | DATABASE_ID = "database_id" | |
| 20 | 23 | USER_AGENT = "django_spanner/2.2.0a1" | |
@@ -64,10 +67,10 @@ def test_get_connection_params(self): | |||
| 64 | 67 | def test_get_new_connection(self): | |
| 65 | 68 | db_wrapper = self._make_one(self.settings_dict) | |
| 66 | 69 | db_wrapper.Database = mock_database = mock.MagicMock() | |
| 67 | - mock_database.connect = mock_connect = mock.MagicMock() | ||
| 70 | + mock_database.connect = mock_connection = mock.MagicMock() | ||
| 68 | 71 | conn_params = {"test_param": "dummy"} | |
| 69 | 72 | 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) | ||
| 71 | 74 | ||
| 72 | 75 | def test_init_connection_state(self): | |
| 73 | 76 | db_wrapper = self._make_one(self.settings_dict) | |
@@ -106,3 +109,10 @@ def test_is_usable(self): | |||
| 106 | 109 | ||
| 107 | 110 | mock_connection.cursor = mock.MagicMock(side_effect=Error) | |
| 108 | 111 | 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() | ||
| Original file line number | Diff line number | Diff 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) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments