8000 refactor: update coverage score in nox file and cleanup imports in te… · googleapis/python-spanner-django@b1f49f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1f49f7

Browse files
authored
refactor: update coverage score in nox file and cleanup imports in test_operations (#638)
* refactor: update coverage score in nox file and cleanup imports in test_operations * refactor: lint correction in test_operations
1 parent 0a29721 commit b1f49f7

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def default(session):
8787
"--cov-append",
8888
"--cov-config=.coveragerc",
8989
"--cov-report=",
90-
"--cov-fail-under=65",
90+
"--cov-fail-under=80",
9191
os.path.join("tests", "unit"),
9292
*session.posargs,
9393
)
@@ -157,7 +157,7 @@ def cover(session):
157157
test runs (not system test runs), and then erases coverage data.
158158
"""
159159
session.install("coverage", "pytest-cov")
160-
session.run("coverage", "report", "--show-missing", "--fail-under=65")
160+
session.run("coverage", "report", "--show-missing", "--fail-under=80")
161161

162162
session.run("coverage", "erase")
163163

tests/unit/django_spanner/test_operations.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
# license that can be found in the LICENSE file or at
55
# https://developers.google.com/open-source/licenses/bsd
66

7-
from django.db.utils import DatabaseError
7+
from base64 import b64encode
88
from datetime import timedelta
9-
from tests.unit.django_spanner.simple_test import SpannerSimpleTestClass
109
from decimal import Decimal
10+
from django.conf import settings
11+
from django.core.management.color import no_style
12+
from django.db.utils import DatabaseError
13+
from google.cloud.spanner_dbapi.types import DateStr
14+
from tests.unit.django_spanner.simple_test import SpannerSimpleTestClass
15+
import uuid
1116

1217

1318
class TestOperations(SpannerSimpleTestClass):
@@ -29,8 +34,6 @@ def test_bulk_batch_size(self):
2934
)
3035

3136
def test_sql_flush(self):
32-
from django.core.management.color import no_style
33-
3437
self.assertEqual(
3538
self.db_operations.sql_flush(
3639
style=no_style(), tables=["Table1", "Table2"]
@@ -39,15 +42,11 @@ def test_sql_flush(self):
3942
)
4043

4144
def test_sql_flush_empty_table_list(self):
42-
from django.core.management.color import no_style
43-
4445
self.assertEqual(
4546
self.db_operations.sql_flush(style=no_style(), tables=[]), [],
4647
)
4748

4849
def test_adapt_datefield_value(self):
49-
from google.cloud.spanner_dbapi.types import DateStr
50-
5150
self.assertIsInstance(
5251
self.db_operations.adapt_datefield_value("dummy_date"), DateStr,
5352
)
@@ -69,8 +68,6 @@ def test_adapt_decimalfield_value_none(self):
6968
)
7069

7170
def test_convert_binaryfield_value(self):
72-
from base64 import b64encode
73-
7471
self.assertEqual(
7572
self.db_operations.convert_binaryfield_value(
7673
value=b64encode(b"abc"), expression=None, connection=None
@@ -96,8 +93,6 @@ def test_adapt_timefield_value_none(self):
9693
)
9794

9895
def test_convert_uuidfield_value(self):
99-
import uuid
100-
10196
uuid_obj = uuid.uuid4()
10297
self.assertEqual(
10398
self.db_operations.convert_uuidfield_value(
@@ -126,8 +121,6 @@ def test_date_extract_sql_lookup_type_dayofweek(self):
126121
)
127122

128123
def test_datetime_extract_sql(self):
129-
from django.conf import settings
130-
131124
settings.USE_TZ = True
132125
self.assertEqual(
133126
self.db_operations.datetime_extract_sql(
@@ -137,8 +130,6 @@ def test_datetime_extract_sql(self):
137130
)
138131

139132
def test_datetime_extract_sql_use_tz_false(self):
140-
from django.conf import settings
141-
142133
settings.USE_TZ = False
143134
self.assertEqual(
144135
self.db_operations.datetime_extract_sql(
@@ -167,17 +158,13 @@ def test_datetime_cast_date_sql(self):
167158
)
168159

169160
def test_datetime_cast_time_sql(self):
170-
from django.conf import settings
171-
172161
settings.USE_TZ = True
173162
self.assertEqual(
174163
self.db_operations.datetime_cast_time_sql("dummy_field", "IST"),
175164
"TIMESTAMP(FORMAT_TIMESTAMP('%Y-%m-%d %R:%E9S %Z', dummy_field, 'IST'))",
176165
)
177166

178167
def test_datetime_cast_time_sql_use_tz_false(self):
179-
from django.conf import settings
180-
181168
settings.USE_TZ = False
182169
self.assertEqual(
183170
self.db_operations.datetime_cast_time_sql("dummy_field", "IST"),

0 commit comments

Comments
 (0)
0