Skip to content

Commit 20a42de

Browse files
committed
Update dependencies and support Django 4.2
1 parent c3791ad commit 20a42de

File tree

13 files changed

+64
-70
lines changed

13 files changed

+64
-70
lines changed

countylimits/data_collection/gather_county_data.py

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

5252

5353
def load_FIPS():
54-
with open("{}/county_FIPS.csv".format(CSV_DIR), "rU") as f:
54+
with open(f"{CSV_DIR}/county_FIPS.csv", "r", newline="") as f:
5555
reader = DictReader(f)
5656
return [row for row in reader]
5757

countylimits/management/commands/load_county_limits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def handle(self, *args, **options):
9393
# Users can pass in `latest` or their own CSV path
9494
csv_file = DEFAULT_CSV.get(options.get("csv"), options.get("csv"))
9595
try:
96-
with open(csv_file, "rU") as csvfile:
96+
with open(csv_file, "r", newline="") as csvfile:
9797
csvreader = csv.reader(
9898
csvfile, delimiter=",", quotechar='"'
9999
)

countylimits/tests.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from django.core.management.base import CommandError
1010
from django.test import TestCase
1111

12-
import mock
13-
from model_mommy import mommy
12+
from unittest import mock
13+
from model_bakery import baker
1414
from rest_framework import status
1515

1616
from countylimits.data_collection.county_data_monitor import (
@@ -271,50 +271,50 @@ def test_county_data_monitor_with_change_and_email(
271271

272272
class CountyLimitTest(TestCase):
273273
def setUp(self):
274-
self.AL = mommy.make(State, state_fips="01", state_abbr="AL")
274+
self.AL = baker.make(State, state_fips="01", state_abbr="AL")
275275

276-
self.ALCO = mommy.make(
276+
self.ALCO = baker.make(
277277
County,
278278
county_fips="001",
279279
county_name="Autauga County",
280280
state=State.objects.get(state_fips="01"),
281281
)
282282

283-
self.ALLIM = mommy.make(
283+
self.ALLIM = baker.make(
284284
CountyLimit,
285285
fha_limit=Decimal("294515.00"),
286286
gse_limit=Decimal("453100.00"),
287287
va_limit=Decimal("453100.00"),
288288
county=County.objects.get(county_name="Autauga County"),
289289
)
290290

291-
self.DC = mommy.make(State, state_fips="11", state_abbr="DC")
291+
self.DC = baker.make(State, state_fips="11", state_abbr="DC")
292292

293-
self.DCCO = mommy.make(
293+
self.DCCO = baker.make(
294294
County,
295295
county_fips="001",
296296
county_name="District of Columbia",
297297
state=State.objects.get(state_fips="11"),
298298
)
299299

300-
self.DCLIM = mommy.make(
300+
self.DCLIM = baker.make(
301301
CountyLimit,
302302
fha_limit=Decimal("294515.00"),
303303
gse_limit=Decimal("453100.00"),
304304
va_limit=Decimal("453100.00"),
305305
county=County.objects.get(county_name="District of Columbia"),
306306
)
307307

308-
self.VA = mommy.make(State, state_fips="51", state_abbr="VA")
308+
self.VA = baker.make(State, state_fips="51", state_abbr="VA")
309309

310-
self.VACO = mommy.make(
310+
self.VACO = baker.make(
311311
County,
312312
county_fips="001",
313313
county_name="Accomack County",
314314
state=State.objects.get(state_fips="51"),
315315
)
316316

317-
self.VALIM = mommy.make(
317+
self.VALIM = baker.make(
318318
CountyLimit,
319319
fha_limit=Decimal("294515.00"),
320320
gse_limit=Decimal("453100.00"),

ratechecker/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def date(self):
8585
def expected_scenario_results(self):
8686
results = OrderedDict()
8787

88-
for scenario in self.tree.getiterator(tag="Scenario"):
88+
for scenario in self.tree.iter(tag="Scenario"):
8989
scenario_data = {elem.tag: elem.text for elem in scenario}
9090
scenario_id = int(scenario_data["ScenarioNo"])
9191

ratechecker/tests/management/commands/test_load_daily_data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import os
22
import shutil
33
import tempfile
4+
from unittest.mock import patch
45

56
from django.core.management import call_command
67
from django.core.management.base import CommandError
78
from django.test import TestCase
89

9-
from mock import patch
10-
1110
from ratechecker.tests.helpers import write_sample_dataset
1211

1312

ratechecker/tests/test_dataset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
from datetime import date, datetime
22
from unittest import TestCase
3+
from unittest.mock import Mock
34
from xml.etree.cElementTree import ParseError
45

56
from django.core.files.base import ContentFile
67
from django.utils import timezone
78

8-
from mock import Mock
9-
109
from ratechecker.dataset import CoverSheet
1110
from ratechecker.tests.helpers import get_sample_dataset
1211

ratechecker/tests/test_loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.test import TestCase
66
from django.utils import timezone
77

8-
from model_mommy import mommy
8+
from model_bakery import baker
99

1010
from ratechecker.loader import (
1111
AdjustmentLoader,
@@ -352,7 +352,7 @@ class TestRateLoader(LoaderTestCaseMixin, TestCase):
352352
loader_cls = RateLoader
353353

354354
def setUp(self):
355-
self.product = mommy.make(Product, plan_id=3)
355+
self.product = baker.make(Product, plan_id=3)
356356

357357
self.row = {
358358
"ratesid": "123",

ratechecker/tests/test_validation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import json
22
from unittest import TestCase
3+
from unittest.mock import patch
34

45
from django.core.files.base import ContentFile
56

6-
from mock import patch
7-
87
from ratechecker.tests.helpers import get_sample_dataset
98
from ratechecker.validation import (
109
ScenarioLoader,

ratechecker/tests/test_views.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from django.test import override_settings
55
from django.utils import timezone
66

7-
from model_mommy import mommy
7+
from model_bakery import baker
88
from rest_framework import status
99
from rest_framework.test import APITestCase
1010

@@ -494,17 +494,17 @@ def test_no_data_returns_none(self):
494494
self.assertEqual(json.loads(response.content), {"load": None})
495495

496496
def test_data_returns_200(self):
497-
mommy.make(Region)
497+
baker.make(Region)
498498
response = self.get()
499499
self.assertEqual(response.status_code, 200)
500500

501501
def test_data_returns_json(self):
502-
mommy.make(Region)
502+
baker.make(Region)
503503
response = self.get()
504504
self.assertEqual(response["Content-type"], "application/json")
505505

506506
def test_data_returns_timestamp(self):
507-
region = mommy.make(Region)
507+
region = baker.make(Region)
508508
response = self.get()
509509
ts = datetime.strptime(
510510
json.loads(response.content)["load"], "%Y-%m-%dT%H:%M:%S.%fZ"
@@ -516,6 +516,6 @@ def test_data_returns_timestamp(self):
516516

517517
def test_data_format_iso8601(self):
518518
timestamp = datetime(2017, 1, 2, 3, 4, 56, tzinfo=timezone.utc)
519-
mommy.make(Region, data_timestamp=timestamp)
519+
baker.make(Region, data_timestamp=timestamp)
520520
response = self.get()
521521
self.assertContains(response, "2017-01-02T03:04:56Z")

ratechecker/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def get_rates(params_data, data_load_testing=False, return_fees=False):
6666
products = {}
6767
for rate in rates:
6868
all_rates.append(rate)
69-
products[
70-
"{}{}".format(rate.product_id, rate.region_id)
71-
] = rate.product_id
69+
products["{}{}".format(rate.product_id, rate.region_id)] = (
70+
rate.product_id
71+
)
7272
product_ids = products.values()
7373

7474
adjustments = (

settings_for_testing.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,52 @@
44
import dj_database_url
55

66
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
7-
sys.path.append(os.path.abspath(os.path.join(BASE_DIR, '..')))
7+
sys.path.append(os.path.abspath(os.path.join(BASE_DIR, "..")))
88

99
INSTALLED_APPS = (
10-
'oahapi',
11-
'ratechecker',
12-
'countylimits',
13-
'rest_framework',
14-
'django.contrib.auth',
15-
'django.contrib.contenttypes',
16-
'django.contrib.sessions',
17-
'django.contrib.messages',
18-
'django.contrib.staticfiles',
10+
"oahapi",
11+
"ratechecker",
12+
"countylimits",
13+
"rest_framework",
14+
"django.contrib.auth",
15+
"django.contrib.contenttypes",
16+
"django.contrib.sessions",
17+
"django.contrib.messages",
18+
"django.contrib.staticfiles",
1919
)
2020

2121
MIDDLEWARE = (
22-
'django.contrib.sessions.middleware.SessionMiddleware',
23-
'django.middleware.common.CommonMiddleware',
24-
'django.contrib.auth.middleware.AuthenticationMiddleware',
25-
'django.contrib.messages.middleware.MessageMiddleware',
26-
'django.middleware.clickjacking.XFrameOptionsMiddleware',
22+
"django.contrib.sessions.middleware.SessionMiddleware",
23+
"django.middleware.common.CommonMiddleware",
24+
"django.contrib.auth.middleware.AuthenticationMiddleware",
25+
"django.contrib.messages.middleware.MessageMiddleware",
26+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
2727
)
2828

2929
SECRET_KEY = "django_tests_secret_key"
3030
DEBUG = True
3131
TEMPLATE_DEBUG = False
32-
ROOT_URLCONF = 'oahapi.urls'
32+
ROOT_URLCONF = "oahapi.urls"
3333
DATABASES = {
34-
'default': {
35-
'ENGINE': 'django.db.backends.sqlite3',
36-
'NAME': 'oah.sqlite3',
34+
"default": {
35+
"ENGINE": "django.db.backends.sqlite3",
36+
"NAME": "oah.sqlite3",
3737
}
3838
}
3939

40-
if 'DATABASE_URL' in os.environ:
41-
DATABASES['default'] = dj_database_url.config()
40+
if "DATABASE_URL" in os.environ:
41+
DATABASES["default"] = dj_database_url.config()
4242

4343

44-
LANGUAGE_CODE = 'en-us'
45-
TIME_ZONE = 'UTC'
44+
LANGUAGE_CODE = "en-us"
45+
TIME_ZONE = "UTC"
4646
USE_I18N = True
4747
USE_L10N = True
4848
USE_TZ = True
49-
STATIC_URL = '/static/'
49+
STATIC_URL = "/static/"
5050
TEMPLATES = [
5151
{
52-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
53-
'APP_DIRS': True,
52+
"BACKEND": "django.template.backends.django.DjangoTemplates",
53+
"APP_DIRS": True,
5454
}
5555
]

setup.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44

55
install_requires = [
6-
"beautifulsoup4>=4.5.0,<4.9",
7-
"Django>=1.11,<3.3",
6+
"beautifulsoup4>=4.11.0,<5.0",
7+
"Django>=3.2,<4.3",
88
"django-cors-headers",
9-
"dj-database-url>=0.4.2,<1",
10-
"django-localflavor>=1.1,<3.1",
11-
"djangorestframework>=3.9.1,<4.0",
12-
"requests>=2.18,<3",
9+
"dj-database-url>=2.1,<3",
10+
"django-localflavor>=4.0,<5.0",
11+
"djangorestframework>=3.14,<4.0",
12+
"requests>=2.31,<3",
1313
]
1414

1515
setup_requires = [
@@ -18,9 +18,8 @@
1818
]
1919

2020
testing_extras = [
21-
"coverage>=5.0,<6",
22-
"mock==2.0.0",
23-
"model_mommy>=1.6.0,<1.7",
21+
"coverage>=7.4,<8",
22+
"model_bakery>=1.17.0,<2",
2423
]
2524

2625
docs_extras = [

tox.ini

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tox]
22
skipsdist=True
3-
envlist=lint,py{38}-dj{22,32}
3+
envlist=lint,py38-dj{32,42}
44

55
[testenv]
66
install_command=pip install -e ".[testing]" -U {opts} {packages}
@@ -9,13 +9,11 @@ commands=
99
coverage run manage.py test {posargs}
1010
coverage report --skip-covered -m
1111

12-
basepython=
13-
py38: python3.8
12+
basepython=python3.8
1413

1514
deps=
16-
dj22: Django>=2.2,<2.3
17-
dj31: Django>=3.1,<3.2
1815
dj32: Django>=3.2,<3.3
16+
dj42: Django>=4.2,<4.3
1917

2018
[testenv:lint]
2119
recreate=False

0 commit comments

Comments
 (0)