8000 chore: Code refactoring to follow common Google API scheme - Stage I … · googleapis/python-spanner-django@59eb432 · GitHub
[go: up one dir, main page]

Skip to content

Commit 59eb432

Browse files
authored
chore: Code refactoring to follow common Google API scheme - Stage I (#487)
1 parent 94ba284 commit 59eb432

23 files changed

+32
-22
lines changed

django_spanner/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
# license that can be found in the LICENSE file or at
55
# https://developers.google.com/open-source/licenses/bsd
66

7-
import spanner_dbapi as Database
87
from django.db.backends.base.base import BaseDatabaseWrapper
9-
from google.cloud import spanner_v1 as spanner
8+
from google.cloud import spanner_v1 as spanner, spanner_dbapi as Database
109

1110
from .client import DatabaseClient
1211
from .creation import DatabaseCreation

django_spanner/operations.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
from django.db.utils import DatabaseError
1717
from django.utils import timezone
1818
from django.utils.duration import duration_microseconds
19-
from spanner_dbapi.parse_utils import DateStr, TimestampStr, escape_name
19+
from google.cloud.spanner_dbapi.parse_utils import (
20+
DateStr,
21+
TimestampStr,
22+
escape_name,
23+
)
2024

2125

2226
class DatabaseOperations(BaseDatabaseOperations):

google/__init__.py

Whitespace-only changes.

google/cloud/__init__.py

Whitespace-only changes.

spanner_dbapi/__init__.py renamed to google/cloud/spanner_dbapi/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def connect(
9797

9898

9999
__all__ = [
100+
"Connection",
100101
"DatabaseError",
101102
"DataError",
102103
"Error",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

noxfile.py

Copy file name to clipboard
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
BLACK_PATHS = [
1919
"django_spanner",
2020
"docs",
21-
"spanner_dbapi",
21+
"google",
2222
"tests",
2323
"noxfile.py",
2424
"setup.py",
@@ -34,7 +34,7 @@ def lint(session):
3434
"""
3535
session.install("flake8", BLACK_VERSION)
3636
session.run("black", "--check", *BLACK_PATHS)
37-
session.run("flake8", "django_spanner", "spanner_dbapi", "tests")
37+
session.run("flake8", "django_spanner", "google", "tests")
3838

3939

4040
@nox.session(python="3.8")
@@ -70,7 +70,7 @@ def default(session):
7070
"py.test",
7171
"--quiet",
7272
"--cov=django_spanner",
73-
"--cov=spanner_dbapi",
73+
"--cov=google.cloud",
7474
"--cov=tests.spanner_dbapi",
7575
"--cov-append",
7676
"--cov-config=.coveragerc",
@@ -126,7 +126,7 @@ def cover(session):
126126
test runs (not system test runs), and then erases coverage data.
127127
"""
128128
session.install("coverage", "pytest-cov")
129-
session.run("coverage", "report", "--show-missing", "--fail-under=20")
129+
session.run("coverage", "report", "--show-missing", "--fail-under=40")
130130
session.run("coverage", "erase")
131131

132132

tests/spanner_dbapi/test_connect.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import google.auth.credentials
1313
from google.api_core.gapic_v1.client_info import ClientInfo
14-
from spanner_dbapi import connect, Connection
14+
from google.cloud.spanner_dbapi import connect, Connection
1515

1616

1717
def _make_credentials():
@@ -30,9 +30,12 @@ def test_connect(self):
3030
CREDENTIALS = _make_credentials()
3131
CLIENT_INFO = ClientInfo(user_agent=USER_AGENT)
3232

33-
with mock.patch("spanner_dbapi.spanner_v1.Client") as client_mock:
33+
with mock.patch(
34+
"google.cloud.spanner_dbapi.spanner_v1.Client"
35+
) as client_mock:
3436
with mock.patch(
35-
"spanner_dbapi.google_client_info", return_value=CLIENT_INFO
37+
"google.cloud.spanner_dbapi.google_client_info",
38+
return_value=CLIENT_INFO,
3639
) as client_info_mock:
3740

3841
connection = connect(

tests/spanner_dbapi/test_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import unittest
1010
from unittest import mock
1111

12-
from spanner_dbapi import connect, InterfaceError
12+
from google.cloud.spanner_dbapi import connect, InterfaceError
1313

1414

1515
class TestConnection(unittest.TestCase):

tests/spanner_dbapi/test_cursor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import unittest
1010
from unittest import mock
1111

12-
from spanner_dbapi import connect, InterfaceError
12+
from google.cloud.spanner_dbapi import connect, InterfaceError
1313

1414

1515
class TestCursor(unittest.TestCase):

tests/spanner_dbapi/test_globals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from unittest import TestCase
88

9-
from spanner_dbapi import apilevel, paramstyle, threadsafety
9+
from google.cloud.spanner_dbapi import apilevel, paramstyle, threadsafety
1010

1111

1212
class DBAPIGlobalsTests(TestCase):

tests/spanner_dbapi/test_parse_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from unittest import TestCase
1010

1111
from google.cloud.spanner_v1 import param_types
12-
from spanner_dbapi.exceptions import Error, ProgrammingError
13-
from spanner_dbapi.parse_utils import (
12+
from google.cloud.spanner_dbapi.exceptions import Error, ProgrammingError
13+
from google.cloud.spanner_dbapi.parse_utils import (
1414
STMT_DDL,
1515
STMT_NON_UPDATING,
1616
DateStr,
@@ -24,7 +24,7 @@
2424
sql_pyformat_args_to_spanner,
2525
strip_backticks,
2626
)
27-
from spanner_dbapi.utils import backtick_unicode
27+
from google.cloud.spanner_dbapi.utils import backtick_unicode
2828

2929

3030
class ParseUtilsTests(TestCase):

tests/spanner_dbapi/test_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
from unittest import TestCase
88

9-
from spanner_dbapi.exceptions import ProgrammingError
10-
from spanner_dbapi.parser import (
9+
from google.cloud.spanner_dbapi.exceptions import ProgrammingError
10+
from google.cloud.spanner_dbapi.parser import (
1111
ARGS,
1212
FUNC,
1313
TERMINAL,

tests/spanner_dbapi/test_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
import datetime
88
from unittest import TestCase
99

10-
from spanner_dbapi.types import (
10+
from google.cloud.spanner_dbapi.types import (
1111
Date,
1212
DateFromTicks,
1313
Time,
1414
TimeFromTicks,
1515
Timestamp,
1616
TimestampFromTicks,
1717
)
18-
from spanner_dbapi.utils import PeekIterator
18+
from google.cloud.spanner_dbapi.utils import PeekIterator
1919

2020
tzUTC = 0 # 0 hours offset from UTC
2121

tests/spanner_dbapi/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from unittest import TestCase
88

9-
from spanner_dbapi.utils import PeekIterator
9+
from google.cloud.spanner_dbapi.utils import PeekIterator
1010

1111

1212
class UtilsTests(TestCase):
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
from unittest import TestCase
99

1010
from google.api_core.gapic_v1.client_info import ClientInfo
11-
from spanner_dbapi.version import DEFAULT_USER_AGENT, google_client_info
11+
from google.cloud.spanner_dbapi.version import (
12+
DEFAULT_USER_AGENT,
13+
google_client_info,
14+
)
1215

1316
vers = sys.version_info
1417

0 commit comments

Comments
 (0)
0