From 3f070ded91328b4e1da846211de1a8d189c153a8 Mon Sep 17 00:00:00 2001 From: Will Barton Date: Fri, 1 Mar 2024 15:55:51 -0500 Subject: [PATCH] Update dependencies and support Django 4.2 --- complaint_search/tests/test_es_interface.py | 2 +- .../tests/test_es_interface_states.py | 3 ++- .../tests/test_es_interface_trends.py | 3 ++- .../tests/test_view_search_renderers.py | 3 ++- .../tests/test_view_suggest_company.py | 3 ++- complaint_search/tests/test_views_document.py | 3 ++- complaint_search/tests/test_views_search.py | 17 ++++++++++++++--- complaint_search/tests/test_views_states.py | 2 +- complaint_search/tests/test_views_suggest.py | 3 ++- .../tests/test_views_suggest_company.py | 3 ++- .../tests/test_views_suggest_zip.py | 3 ++- complaint_search/tests/test_views_trends.py | 2 +- setup.py | 17 ++++++++--------- tox.ini | 6 +++--- 14 files changed, 44 insertions(+), 26 deletions(-) diff --git a/complaint_search/tests/test_es_interface.py b/complaint_search/tests/test_es_interface.py index 4480c65..b68e880 100644 --- a/complaint_search/tests/test_es_interface.py +++ b/complaint_search/tests/test_es_interface.py @@ -1,10 +1,10 @@ import copy from datetime import datetime +from unittest import mock from django.http import StreamingHttpResponse from django.test import SimpleTestCase, TestCase -import mock from elasticsearch import Elasticsearch from parameterized import parameterized diff --git a/complaint_search/tests/test_es_interface_states.py b/complaint_search/tests/test_es_interface_states.py index d184704..071995b 100644 --- a/complaint_search/tests/test_es_interface_states.py +++ b/complaint_search/tests/test_es_interface_states.py @@ -1,6 +1,7 @@ +from unittest import mock + from django.test import TestCase -import mock from elasticsearch import Elasticsearch from complaint_search.es_interface import states_agg diff --git a/complaint_search/tests/test_es_interface_trends.py b/complaint_search/tests/test_es_interface_trends.py index 4942eda..2be6b96 100644 --- a/complaint_search/tests/test_es_interface_trends.py +++ b/complaint_search/tests/test_es_interface_trends.py @@ -1,6 +1,7 @@ +from unittest import mock + from django.test import TestCase -import mock from elasticsearch import Elasticsearch from complaint_search.es_interface import trends diff --git a/complaint_search/tests/test_view_search_renderers.py b/complaint_search/tests/test_view_search_renderers.py index b83b084..cc9246c 100644 --- a/complaint_search/tests/test_view_search_renderers.py +++ b/complaint_search/tests/test_view_search_renderers.py @@ -1,4 +1,5 @@ -import mock +from unittest import mock + from rest_framework import status from rest_framework.test import APITestCase diff --git a/complaint_search/tests/test_view_suggest_company.py b/complaint_search/tests/test_view_suggest_company.py index f88b495..8f776dd 100644 --- a/complaint_search/tests/test_view_suggest_company.py +++ b/complaint_search/tests/test_view_suggest_company.py @@ -1,7 +1,8 @@ +from unittest import mock + from django.conf import settings from django.urls import reverse -import mock from elasticsearch import TransportError from rest_framework import status from rest_framework.test import APITestCase diff --git a/complaint_search/tests/test_views_document.py b/complaint_search/tests/test_views_document.py index 75d921b..039a8fe 100644 --- a/complaint_search/tests/test_views_document.py +++ b/complaint_search/tests/test_views_document.py @@ -1,7 +1,8 @@ +from unittest import mock + from django.core.cache import cache from django.test import override_settings -import mock from elasticsearch import TransportError from rest_framework import status from rest_framework.test import APITestCase diff --git a/complaint_search/tests/test_views_search.py b/complaint_search/tests/test_views_search.py index 48e47a5..c0b7b1f 100644 --- a/complaint_search/tests/test_views_search.py +++ b/complaint_search/tests/test_views_search.py @@ -1,12 +1,12 @@ import copy from datetime import date, datetime +from unittest import mock from django.conf import settings from django.core.cache import cache from django.http import StreamingHttpResponse from django.test import override_settings -import mock from elasticsearch import TransportError from rest_framework import status from rest_framework.exceptions import ErrorDetail @@ -103,8 +103,19 @@ def test_search_with_format(self, mock_essearch, mock_dt): ), ) self.assertTrue(isinstance(response, StreamingHttpResponse)) - mock_essearch.has_calls( - [mock.call(format=k) for k in FORMAT_CONTENT_TYPE_MAP], + + mock_essearch.assert_has_calls( + [mock.call( + format=k, + agg_exclude=mock.ANY, + field=mock.ANY, + size=mock.ANY, + frm=mock.ANY, + sort=mock.ANY, + page=mock.ANY, + no_aggs=mock.ANY, + no_highlight=mock.ANY, + ) for k in FORMAT_CONTENT_TYPE_MAP], any_order=True, ) self.assertEqual( diff --git a/complaint_search/tests/test_views_states.py b/complaint_search/tests/test_views_states.py index 7b460e8..48ad34d 100644 --- a/complaint_search/tests/test_views_states.py +++ b/complaint_search/tests/test_views_states.py @@ -1,6 +1,6 @@ import copy +from unittest import mock -import mock from parameterized import parameterized from rest_framework import status from rest_framework.test import APITestCase diff --git a/complaint_search/tests/test_views_suggest.py b/complaint_search/tests/test_views_suggest.py index 47b6859..26f11ed 100644 --- a/complaint_search/tests/test_views_suggest.py +++ b/complaint_search/tests/test_views_suggest.py @@ -1,6 +1,7 @@ +from unittest import mock + from django.conf import settings -import mock from elasticsearch import TransportError from rest_framework import status from rest_framework.test import APITestCase diff --git a/complaint_search/tests/test_views_suggest_company.py b/complaint_search/tests/test_views_suggest_company.py index c03c05b..7a9a9cb 100644 --- a/complaint_search/tests/test_views_suggest_company.py +++ b/complaint_search/tests/test_views_suggest_company.py @@ -1,6 +1,7 @@ +from unittest import mock + from django.conf import settings -import mock from elasticsearch import TransportError from rest_framework import status from rest_framework.test import APITestCase diff --git a/complaint_search/tests/test_views_suggest_zip.py b/complaint_search/tests/test_views_suggest_zip.py index 51f2cf5..101ddff 100644 --- a/complaint_search/tests/test_views_suggest_zip.py +++ b/complaint_search/tests/test_views_suggest_zip.py @@ -1,6 +1,7 @@ +from unittest import mock + from django.conf import settings -import mock from elasticsearch import TransportError from rest_framework import status from rest_framework.test import APITestCase diff --git a/complaint_search/tests/test_views_trends.py b/complaint_search/tests/test_views_trends.py index eefb9f2..2a8be07 100644 --- a/complaint_search/tests/test_views_trends.py +++ b/complaint_search/tests/test_views_trends.py @@ -1,6 +1,6 @@ import copy +from unittest import mock -import mock from rest_framework import status from rest_framework.test import APITestCase diff --git a/setup.py b/setup.py index 9b07a43..f20e4a6 100644 --- a/setup.py +++ b/setup.py @@ -48,23 +48,22 @@ def get_git_version(): install_requires = [ - "Django>=3.2,<3.3", - "djangorestframework>=3.9.1,<4.0", + "Django>=3.2,<4.3", + "djangorestframework>=3.14,<4.0", "django-rest-swagger>=2.2.0", - "requests>=2.18,<3", + "requests>=2.31,<3", "elasticsearch>=7.0.0,<7.11", - "django-localflavor>=1.1,<3.1", + "django-localflavor>=4.0,<5.0", "django-flags>=4.0.1,<5.1", "requests-aws4auth", ] testing_extras = [ - "coverage>=4.5.1,<5", - "mock==2.0.0", + "coverage>=7.4,<8", "deep==0.10", - "deepdiff>=3.3,<5.0", - "django-nose==1.4.1", - "parameterized==0.6.1", + "deepdiff>=6.7,<7", + "django-nose==1.4.7", + "parameterized==0.9.0", "elasticsearch7>=7.0.0,<8.0.0", "requests-aws4auth", ] diff --git a/tox.ini b/tox.ini index 5c122fe..d2d1f22 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] skipsdist=True -envlist=lint,py{38}-dj{32} +envlist=lint,py38-dj{32,42} [testenv] -basepython= - py38: python3.8 +basepython=python3.8 deps= dj32: Django>=3.2,<3.3 + dj42: Django>=4.2,<4.3 install_command=pip install -e ".[testing]" -U {opts} {packages} setenv=