Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from May 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
vi3k6i5 marked this conversation as resolved.
Show resolved Hide resolved
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