Skip to content

Commit

Permalink
testing: make warnings errors, fix some warnings (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Aug 29, 2023
1 parent 2cf460b commit 20a6117
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 23 deletions.
2 changes: 0 additions & 2 deletions heroku_connect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
.. _`Heroku Connect`: https://devcenter.heroku.com/categories/heroku-connect
"""

default_app_config = "heroku_connect.apps.HerokuConnectAppConfig"
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@
.. _`django-health-check`: https://github.com/KristianOellegaard/django-health-check
"""
default_app_config = (
"heroku_connect.contrib.heroku_connect_health_check.apps.HealthCheckConfig"
)
5 changes: 3 additions & 2 deletions heroku_connect/db/models/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"""
import uuid
from datetime import timezone

from django import forms
from django.db import models
from django.utils import timezone
from django.utils import timezone as django_timezone

__all__ = (
"HerokuConnectFieldMixin",
Expand Down Expand Up @@ -195,7 +196,7 @@ def from_db_value(self, value, *args, **kwargs):
if value is None:
return value
else:
return timezone.make_aware(value, timezone.utc)
return django_timezone.make_aware(value, timezone.utc)


class Email(HerokuConnectFieldMixin, models.EmailField):
Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ warning-is-error = 1
norecursedirs = env .eggs
addopts = --tb=short -rxs --nomigrations
DJANGO_SETTINGS_MODULE=tests.testapp.settings
filterwarnings =
error
# we're only using this setting in our test-app right now,
# also we're not a django project, so we would never add settings.
ignore:The USE_L10N setting is deprecate:DeprecationWarning
# django 3.2 is using this module, but not in later versions any more
ignore:'cgi' is deprecated:DeprecationWarning

[flake8]
max-line-length = 88
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def failed_trigger_log(connected_model):
)


@pytest.yield_fixture
@pytest.fixture
def set_write_mode_merge():
get_unique_connection_write_mode.cache_clear()
with httpretty.enabled():
Expand All @@ -206,7 +206,7 @@ def set_write_mode_merge():
yield


@pytest.yield_fixture
@pytest.fixture
def set_write_mode_ordered():
get_unique_connection_write_mode.cache_clear()
connections = copy.deepcopy(fixtures.connections)
Expand Down
22 changes: 8 additions & 14 deletions tests/db/models/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
from tests.testapp.models import NumberModel


class MyReadOnlyModel(hc_models.HerokuConnectModel):
sf_object_name = "My_Object__c"
date = hc_models.DateTime(sf_field_name="Date1__c")

class Meta:
app_label = "test"


class TestHerokuConnectModelMixin:
def test_meta(self, settings):
class MyModel(hc_models.HerokuConnectModel):
Expand Down Expand Up @@ -410,13 +418,6 @@ class Meta:
}

def test_qs_methods_on_read_only_model(self):
class MyReadOnlyModel(hc_models.HerokuConnectModel):
sf_object_name = "My_Object__c"
date = hc_models.DateTime(sf_field_name="Date1__c")

class Meta:
app_label = "test"

data_instance = MyReadOnlyModel(date=timezone.now())
with pytest.raises(WriteNotSupportedError) as e:
data_instance.save()
Expand All @@ -428,13 +429,6 @@ class Meta:
assert "is a read-only model." in str(e.value)

def test_write_methods_on_read_only_model(self):
class MyReadOnlyModel(hc_models.HerokuConnectModel):
sf_object_name = "My_Object__c"
date = hc_models.DateTime(sf_field_name="Date1__c")

class Meta:
app_label = "test"

with pytest.raises(WriteNotSupportedError) as e:
MyReadOnlyModel.objects.update(date=timezone.now())
assert "is a read-only model." in str(e.value)
Expand Down

0 comments on commit 20a6117

Please sign in to comment.