diff --git a/config/settings/base.py b/config/settings/base.py index e7c65ba..4a7a683 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -24,7 +24,6 @@ env = environ.Env(DEBUG=(bool, False)) ROOT_DIR = root() -environ.Env.read_env(join(ROOT_DIR, ".env")) ALLOWED_HOSTS = [] @@ -100,8 +99,6 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True @@ -115,7 +112,14 @@ STATIC_ROOT = join(ROOT_DIR, "staticfiles") STATIC_URL = "/static/" -STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" +STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, + "staticfiles": { + "BACKEND": "whitenoise.storage.CompressedManifestStaticFilesStorage", + }, +} COMPRESS_ENABLED = True MEDIA_ROOT = join(ROOT_DIR, "media") @@ -147,7 +151,6 @@ ), "DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",), "DEFAULT_FILTER_BACKENDS": ("django_filters.rest_framework.DjangoFilterBackend",), - "DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema", } AWS_ACCESS_KEY_ID = env.str("AWS_ACCESS_KEY_ID", "") diff --git a/rp_recruit/tests/test_views.py b/rp_recruit/tests/test_views.py index 33ffe18..7ea1195 100644 --- a/rp_recruit/tests/test_views.py +++ b/rp_recruit/tests/test_views.py @@ -55,7 +55,7 @@ def test_recruit_view_post_500(self, fake_get_whatsapp_contact_id): url, {"msisdn": "+27821111111", "name": "test user"} ) self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) - self.assertFormError(response, "form", None, [WA_CHECK_FORM_ERROR]) + self.assertFormError(response.context["form"], None, [WA_CHECK_FORM_ERROR]) @patch("rp_recruit.views.get_whatsapp_contact_id", autospec=True, return_value=None) def test_recruit_view_post_400(self, mock_get_whatsapp_contact_id): @@ -69,8 +69,7 @@ def test_recruit_view_post_400(self, mock_get_whatsapp_contact_id): url, {"msisdn": "+27821111111", "name": "test user"} ) self.assertFormError( - response, - "form", + response.context["form"], "msisdn", [f"{msisdn} is not a valid WhatsApp contact number"], ) @@ -95,7 +94,9 @@ def test_recruit_view_post_400_rp_contact_exists( ) self.assertFormError( - response, "form", "msisdn", [f"{msisdn} is not a valid contact number"] + response.context["form"], + "msisdn", + [f"{msisdn} is not a valid contact number"], ) self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) assertCallMadeWith(mock_get_contacts.call_args, urn=f"whatsapp:{wa_id}") @@ -134,7 +135,9 @@ def test_recruit_view_post_500_rp_create_failure( mock_capture_exception.assert_called_once() - self.assertFormError(response, "form", None, [RAPIDPRO_CREATE_OR_START_FAILURE]) + self.assertFormError( + response.context["form"], None, [RAPIDPRO_CREATE_OR_START_FAILURE] + ) self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR) assertCallMadeWith(mock_get_contacts.call_args, urn=f"whatsapp:{wa_id}") diff --git a/rp_transferto/migrations/0005_alter_msisdninformation_data_and_more.py b/rp_transferto/migrations/0005_alter_msisdninformation_data_and_more.py new file mode 100644 index 0000000..56510a1 --- /dev/null +++ b/rp_transferto/migrations/0005_alter_msisdninformation_data_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.11 on 2024-04-11 14:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("rp_transferto", "0004_add_topup_model"), + ] + + operations = [ + migrations.AlterField( + model_name="msisdninformation", + name="data", + field=models.JSONField(), + ), + migrations.AlterField( + model_name="topupattempt", + name="response", + field=models.JSONField(null=True), + ), + ] diff --git a/rp_transferto/models.py b/rp_transferto/models.py index cba6fa6..c928f1a 100644 --- a/rp_transferto/models.py +++ b/rp_transferto/models.py @@ -1,8 +1,8 @@ import json import pkg_resources -from django.contrib.postgres.fields import JSONField from django.db import models +from django.db.models import JSONField from django.utils import timezone from sidekick.models import Organization diff --git a/setup.cfg b/setup.cfg index b312604..534c8a4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [flake8] -exclude = */migrations/*.py,*/manage.py,ve/* +exclude = */migrations/*.py,*/manage.py,ve/*,env/* ignore = D100, D101, D102, D103, D104, D105, W503, E501, F405 line_length = 88 @@ -15,5 +15,5 @@ line_length = 88 # Vertical hanging indent, for black multi_line_output = 3 include_trailing_comma = True -skip = ve/ +skip = ve/,env/ known_third_party = boto3,celery,dj_database_url,django,environ,freezegun,hashids,json2html,kombu,moto,phonenumber_field,pkg_resources,prometheus_client,pytest,raven,recommonmark,requests,responses,rest_framework,sentry_sdk,setuptools,six,temba_client diff --git a/setup.py b/setup.py index ce477c2..764dc50 100644 --- a/setup.py +++ b/setup.py @@ -11,13 +11,12 @@ include_package_data=True, install_requires=[ "celery==5.2.3", - "coreapi==2.3.3", - "Django==3.2.25", + "Django==4.2.11", "django-environ==0.4.5", "django-extensions==3.1.5", "django-phonenumber-field==3.0.1", "django-prometheus==2.2.0", - "djangorestframework==3.13.1", + "djangorestframework==3.15.1", "json2html==1.3.0", "phonenumbers==8.10.23", "psycopg2-binary==2.8.6", diff --git a/sidekick/tests/test_views.py b/sidekick/tests/test_views.py index 53f4acb..8d65273 100644 --- a/sidekick/tests/test_views.py +++ b/sidekick/tests/test_views.py @@ -68,7 +68,6 @@ def mock_queue_lookup(self, name="rp_sidekick", messages=1256, rate=1.25): "name": name, }, status=200, - match_querystring=True, ) @responses.activate @@ -136,7 +135,6 @@ def add_whatsapp_messages_200_response(self): "meta": {"api_status": "stable", "version": "2.19.4"}, }, status=201, - match_querystring=True, ) @responses.activate @@ -278,7 +276,6 @@ def test_wa_check_contact_valid(self): ] }, status=201, - match_querystring=True, ) # get result @@ -313,7 +310,6 @@ def test_wa_check_contact_invalid(self): "{}/v1/contacts".format(FAKE_ENGAGE_URL), json={"contacts": [{"input": telephone_number, "status": "invalid"}]}, status=201, - match_querystring=True, ) # get result @@ -348,7 +344,6 @@ def test_wa_check_contact_error(self): "{}/v1/contacts".format(FAKE_ENGAGE_URL), "Invalid WhatsApp Token", status=status.HTTP_403_FORBIDDEN, - match_querystring=True, ) # get result @@ -901,7 +896,6 @@ def test_get_rapidpro_flows(self): "http://localhost:8002/api/v2/flows.json", json=response_body, status=200, - match_querystring=True, ) self.client.force_authenticate(self.user) @@ -950,7 +944,6 @@ def test_start_rapidpro_flow(self): "http://localhost:8002/api/v2/flow_starts.json", json=response_body, status=200, - match_querystring=True, ) self.client.force_authenticate(self.user) @@ -1010,7 +1003,6 @@ def test_get_rapidpro_contact(self): "http://localhost:8002/api/v2/contacts.json", json=response_body, status=200, - match_querystring=True, ) self.client.force_authenticate(self.user) @@ -1049,7 +1041,6 @@ def test_get_rapidpro_contact_with_field_filter(self): "http://localhost:8002/api/v2/contacts.json", json=response_body, status=200, - match_querystring=True, ) self.client.force_authenticate(self.user) diff --git a/staticfiles/.gitkeep b/staticfiles/.gitkeep new file mode 100644 index 0000000..e69de29