Skip to content

Commit

Permalink
refactor: update coverage score in nox file and cleanup imports in te…
Browse files Browse the repository at this point in the history
…st_operations (#638)

* refactor: update coverage score in nox file and cleanup imports in test_operations

* refactor: lint correction in test_operations
  • Loading branch information
vi3k6i5 committed May 26, 2021
1 parent 0a29721 commit b1f49f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
4 changes: 2 additions & 2 deletions noxfile.py
Expand Up @@ -87,7 +87,7 @@ def default(session):
"--cov-append",
"--cov-config=.coveragerc",
"--cov-report=",
"--cov-fail-under=65",
"--cov-fail-under=80",
os.path.join("tests", "unit"),
*session.posargs,
)
Expand Down Expand Up @@ -157,7 +157,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=65")
session.run("coverage", "report", "--show-missing", "--fail-under=80")

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

Expand Down
27 changes: 7 additions & 20 deletions tests/unit/django_spanner/test_operations.py
Expand Up @@ -4,10 +4,15 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd

from django.db.utils import DatabaseError
from base64 import b64encode
from datetime import timedelta
from tests.unit.django_spanner.simple_test import SpannerSimpleTestClass
from decimal import Decimal
from django.conf import settings
from django.core.management.color import no_style
from django.db.utils import DatabaseError
from google.cloud.spanner_dbapi.types import DateStr
from tests.unit.django_spanner.simple_test import SpannerSimpleTestClass
import uuid


class TestOperations(SpannerSimpleTestClass):
Expand All @@ -29,8 +34,6 @@ def test_bulk_batch_size(self):
)

def test_sql_flush(self):
from django.core.management.color import no_style

self.assertEqual(
self.db_operations.sql_flush(
style=no_style(), tables=["Table1", "Table2"]
Expand All @@ -39,15 +42,11 @@ def test_sql_flush(self):
)

def test_sql_flush_empty_table_list(self):
from django.core.management.color import no_style

self.assertEqual(
self.db_operations.sql_flush(style=no_style(), tables=[]), [],
)

def test_adapt_datefield_value(self):
from google.cloud.spanner_dbapi.types import DateStr

self.assertIsInstance(
self.db_operations.adapt_datefield_value("dummy_date"), DateStr,
)
Expand All @@ -69,8 +68,6 @@ def test_adapt_decimalfield_value_none(self):
)

def test_convert_binaryfield_value(self):
from base64 import b64encode

self.assertEqual(
self.db_operations.convert_binaryfield_value(
value=b64encode(b"abc"), expression=None, connection=None
Expand All @@ -96,8 +93,6 @@ def test_adapt_timefield_value_none(self):
)

def test_convert_uuidfield_value(self):
import uuid

uuid_obj = uuid.uuid4()
self.assertEqual(
self.db_operations.convert_uuidfield_value(
Expand Down Expand Up @@ -126,8 +121,6 @@ def test_date_extract_sql_lookup_type_dayofweek(self):
)

def test_datetime_extract_sql(self):
from django.conf import settings

settings.USE_TZ = True
self.assertEqual(
self.db_operations.datetime_extract_sql(
Expand All @@ -137,8 +130,6 @@ def test_datetime_extract_sql(self):
)

def test_datetime_extract_sql_use_tz_false(self):
from django.conf import settings

settings.USE_TZ = False
self.assertEqual(
self.db_operations.datetime_extract_sql(
Expand Down Expand Up @@ -167,17 +158,13 @@ def test_datetime_cast_date_sql(self):
)

def test_datetime_cast_time_sql(self):
from django.conf import settings

settings.USE_TZ = True
self.assertEqual(
self.db_operations.datetime_cast_time_sql("dummy_field", "IST"),
"TIMESTAMP(FORMAT_TIMESTAMP('%Y-%m-%d %R:%E9S %Z', dummy_field, 'IST'))",
)

def test_datetime_cast_time_sql_use_tz_false(self):
from django.conf import settings

settings.USE_TZ = False
self.assertEqual(
self.db_operations.datetime_cast_time_sql("dummy_field", "IST"),
Expand Down

0 comments on commit b1f49f7

Please sign in to comment.