diff --git a/Dockerfile b/Dockerfile index f5c7285..9565e3a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN apk --no-cache add \ WORKDIR /app COPY ./requirements /app/requirements -RUN pip install pip setuptools -U +RUN pip install pip setuptools==47.1.1 RUN pip install -r requirements/production.txt diff --git a/bin/docker_start.sh b/bin/docker_start.sh index e286650..a4177f3 100755 --- a/bin/docker_start.sh +++ b/bin/docker_start.sh @@ -2,12 +2,21 @@ set -ex +# Wait for the database container +# See: https://docs.docker.com/compose/startup-order/ +export PGHOST=${DB_HOST:-db} +export PGPORT=${DB_PORT:-5432} + fixtures_dir=${FIXTURES_DIR:-/app/fixtures} uwsgi_port=${UWSGI_PORT:-8000} -# Wait for required services -${SCRIPTPATH}/wait_for_db.sh +until pg_isready; do + >&2 echo "Waiting for database connection..." + sleep 1 +done + +>&2 echo "Database is up." # Apply database migrations >&2 echo "Apply database migrations" diff --git a/bin/wait_for_db.sh b/bin/wait_for_db.sh deleted file mode 100644 index 8cdf20d..0000000 --- a/bin/wait_for_db.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -e - -# Wait for the database container -# See: https://docs.docker.com/compose/startup-order/ -db_host=${DB_HOST:-db} -db_user=${DB_USER:-postgres} -db_password=${DB_PASSWORD} -db_port=${DB_PORT:-5432} - -until PGPORT=$db_port PGPASSWORD=$db_password psql -h "$db_host" -U "$db_user" -c '\q'; do - >&2 echo "Waiting for database connection..." - sleep 1 -done - ->&2 echo "Database is up." diff --git a/requirements/base.txt b/requirements/base.txt index 7b26144..c914d7d 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -6,7 +6,7 @@ # certifi==2019.9.11 # via requests chardet==3.0.4 # via requests -click==7.0 # via pip-tools +click==7.1.2 # via pip-tools coreapi==2.3.3 # via drf-yasg coreschema==0.0.4 # via coreapi, drf-yasg django-better-admin-arrayfield==1.0.4 @@ -32,7 +32,7 @@ jinja2==2.10.3 # via coreschema markdown==3.1.1 markupsafe==1.1.1 # via jinja2 oyaml==0.9 # via vng-api-common -pip-tools==4.2.0 +pip-tools==5.3.1 psycopg2==2.8.3 pyjwt==1.7.1 # via gemma-zds-client, vng-api-common python-dateutil==2.8.0 diff --git a/requirements/ci.txt b/requirements/ci.txt index 1705dba..77a198c 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -5,15 +5,15 @@ # pip-compile --no-index --output-file requirements/ci.txt requirements/base.txt requirements/dev.txt requirements/ci.in # appdirs==1.4.3 -attrs==19.3.0 beautifulsoup4==4.8.1 -black==19.10b0 +black==20.8b1 certifi==2019.9.11 chardet==3.0.4 -click==7.0 +click==7.1.2 coreapi==2.3.3 coreschema==0.0.4 coverage==4.5.4 +dataclasses==0.6 django-better-admin-arrayfield==1.0.4 django-choices==1.7.0 django-cors-middleware==1.4.0 @@ -44,9 +44,10 @@ itypes==1.1.0 jinja2==2.10.3 markdown==3.1.1 markupsafe==1.1.1 +mypy-extensions==0.4.3 oyaml==0.9 pathspec==0.6.0 -pip-tools==4.2.0 +pip-tools==5.3.1 psycopg2==2.8.3 pyjwt==1.7.1 python-dateutil==2.8.0 @@ -55,7 +56,7 @@ pytz==2019.3 pyyaml==5.1.2 raven==6.10.0 redis==3.3.11 -regex==2019.11.1 +regex==2020.7.14 requests==2.22.0 ruamel.yaml.clib==0.2.0 ruamel.yaml==0.16.5 @@ -64,8 +65,9 @@ soupsieve==1.9.4 sqlparse==0.3.0 tblib==1.4.0 text-unidecode==1.3 -toml==0.10.0 +toml==0.10.1 typed-ast==1.4.0 +typing-extensions==3.7.4.3 unidecode==1.1.1 uritemplate==3.0.0 urllib3==1.25.6 diff --git a/requirements/dev.txt b/requirements/dev.txt index 35d8b88..6975c71 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -2,18 +2,18 @@ # This file is autogenerated by pip-compile # To update, run: # -# pip-compile --no-index --output-file requirements/dev.txt requirements/base.txt requirements/dev.in requirements/testing.in +# pip-compile --no-index --output-file requirements/dev.txt requirements/base.txt requirements/testing.in requirements/dev.in # appdirs==1.4.3 # via black -attrs==19.3.0 # via black beautifulsoup4==4.8.1 # via webtest -black==19.10b0 +black==20.8b1 certifi==2019.9.11 chardet==3.0.4 -click==7.0 +click==7.1.2 coreapi==2.3.3 coreschema==0.0.4 coverage==4.5.4 +dataclasses==0.6 django-better-admin-arrayfield==1.0.4 django-choices==1.7.0 django-cors-middleware==1.4.0 @@ -43,9 +43,10 @@ itypes==1.1.0 jinja2==2.10.3 markdown==3.1.1 markupsafe==1.1.1 +mypy-extensions==0.4.3 # via black oyaml==0.9 pathspec==0.6.0 # via black -pip-tools==4.2.0 +pip-tools==5.3.1 psycopg2==2.8.3 pyjwt==1.7.1 python-dateutil==2.8.0 @@ -54,7 +55,7 @@ pytz==2019.3 pyyaml==5.1.2 raven==6.10.0 redis==3.3.11 -regex==2019.11.1 # via black +regex==2020.7.14 # via black requests==2.22.0 ruamel.yaml.clib==0.2.0 ruamel.yaml==0.16.5 @@ -63,8 +64,9 @@ soupsieve==1.9.4 # via beautifulsoup4 sqlparse==0.3.0 tblib==1.4.0 text-unidecode==1.3 # via faker -toml==0.10.0 # via black +toml==0.10.1 # via black typed-ast==1.4.0 # via black +typing-extensions==3.7.4.3 # via black unidecode==1.1.1 uritemplate==3.0.0 urllib3==1.25.6 diff --git a/requirements/testing.in b/requirements/testing.in index 08426cb..61f474c 100644 --- a/requirements/testing.in +++ b/requirements/testing.in @@ -1,6 +1,7 @@ # Shared between dev and jenkins requirements to run our tests black coverage +dataclasses==0.6 django-webtest factory_boy freezegun diff --git a/src/verzoeken/accounts/migrations/0001_initial.py b/src/verzoeken/accounts/migrations/0001_initial.py index 827dc3a..5d5b2c0 100644 --- a/src/verzoeken/accounts/migrations/0001_initial.py +++ b/src/verzoeken/accounts/migrations/0001_initial.py @@ -116,7 +116,12 @@ class Migration(migrations.Migration): ), ), ], - options={"verbose_name": "user", "verbose_name_plural": "users",}, - managers=[("objects", verzoeken.accounts.managers.UserManager()),], + options={ + "verbose_name": "user", + "verbose_name_plural": "users", + }, + managers=[ + ("objects", verzoeken.accounts.managers.UserManager()), + ], ), ] diff --git a/src/verzoeken/api/serializers.py b/src/verzoeken/api/serializers.py index 8842705..63f2e60 100644 --- a/src/verzoeken/api/serializers.py +++ b/src/verzoeken/api/serializers.py @@ -113,7 +113,9 @@ class Meta: "lookup_field": "uuid", "validators": [IsImmutableValidator()], }, - "object": {"validators": [IsImmutableValidator()],}, + "object": { + "validators": [IsImmutableValidator()], + }, "object_type": {"validators": [IsImmutableValidator()]}, } validators = [ObjectVerzoekCreateValidator()] @@ -213,9 +215,15 @@ class Meta: "url": {"lookup_field": "uuid"}, "verzoek": { "lookup_field": "uuid", - "validators": [IsImmutableValidator(),], + "validators": [ + IsImmutableValidator(), + ], + }, + "product": { + "validators": [ + IsImmutableValidator(), + ], }, - "product": {"validators": [IsImmutableValidator(),],}, } def validate(self, attrs): @@ -238,7 +246,8 @@ class Meta: fields = ("url", "klant", "verzoek", "rol", "indicatie_machtiging") validators = [ UniqueTogetherValidator( - queryset=KlantVerzoek.objects.all(), fields=["verzoek", "klant"], + queryset=KlantVerzoek.objects.all(), + fields=["verzoek", "klant"], ), ] extra_kwargs = { diff --git a/src/verzoeken/api/tests/test_klantverzoek.py b/src/verzoeken/api/tests/test_klantverzoek.py index 7c48696..16e505d 100644 --- a/src/verzoeken/api/tests/test_klantverzoek.py +++ b/src/verzoeken/api/tests/test_klantverzoek.py @@ -39,7 +39,9 @@ def test_list_filter_klantverzoek(self): self.assertEqual(len(data["results"]), 1) response = self.client.get( - list_url, {"klant": vc2.klant}, HTTP_HOST="testserver.com", + list_url, + {"klant": vc2.klant}, + HTTP_HOST="testserver.com", ) self.assertEqual(response.status_code, status.HTTP_200_OK) diff --git a/src/verzoeken/api/tests/test_objectverzoek.py b/src/verzoeken/api/tests/test_objectverzoek.py index ca7d632..f47fc51 100644 --- a/src/verzoeken/api/tests/test_objectverzoek.py +++ b/src/verzoeken/api/tests/test_objectverzoek.py @@ -51,9 +51,12 @@ def test_read_objectverzoek(self): }, ) - @override_settings(LINK_FETCHER="vng_api_common.mocks.link_fetcher_200",) + @override_settings( + LINK_FETCHER="vng_api_common.mocks.link_fetcher_200", + ) @patch( - "zds_client.client.get_operation_url", return_value="/api/v1/zaakverzoeken", + "zds_client.client.get_operation_url", + return_value="/api/v1/zaakverzoeken", ) @patch("zds_client.tests.mocks.MockClient.fetch_schema", return_value={}) @patch("vng_api_common.validators.obj_has_shape", return_value=True) @@ -86,9 +89,12 @@ def test_create_objectverzoek(self, *mocks): self.assertEqual(objectverzoek.object_type, ObjectTypes.zaak) self.assertEqual(objectverzoek.object, ZAAK) - @override_settings(LINK_FETCHER="vng_api_common.mocks.link_fetcher_200",) + @override_settings( + LINK_FETCHER="vng_api_common.mocks.link_fetcher_200", + ) @patch( - "zds_client.client.get_operation_url", return_value="/api/v1/zaakverzoeken", + "zds_client.client.get_operation_url", + return_value="/api/v1/zaakverzoeken", ) @patch("zds_client.tests.mocks.MockClient.fetch_schema", return_value={}) @patch("vng_api_common.validators.obj_has_shape", return_value=True) @@ -112,7 +118,8 @@ def test_create_objectverzoek_fail_no_remote_relation(self, *mocks): self.assertEqual(error["code"], "inconsistent-relation") @patch( - "zds_client.client.get_operation_url", return_value="/api/v1/zaakverzoeken", + "zds_client.client.get_operation_url", + return_value="/api/v1/zaakverzoeken", ) @patch("zds_client.tests.mocks.MockClient.fetch_schema", return_value={}) def test_destroy_objectverzoek(self, *mocks): @@ -129,7 +136,8 @@ def test_destroy_objectverzoek(self, *mocks): self.assertEqual(ObjectVerzoek.objects.count(), 0) @patch( - "zds_client.client.get_operation_url", return_value="/api/v1/zaakverzoeken", + "zds_client.client.get_operation_url", + return_value="/api/v1/zaakverzoeken", ) @patch("zds_client.tests.mocks.MockClient.fetch_schema", return_value={}) def test_destroy_fail_existing_relation(self, *mocks): diff --git a/src/verzoeken/api/tests/test_verzoekcontactmoment.py b/src/verzoeken/api/tests/test_verzoekcontactmoment.py index e436066..1aa6afc 100644 --- a/src/verzoeken/api/tests/test_verzoekcontactmoment.py +++ b/src/verzoeken/api/tests/test_verzoekcontactmoment.py @@ -42,7 +42,9 @@ def test_list_filter_verzoekcontactmoment(self): self.assertEqual(len(data["results"]), 1) response = self.client.get( - list_url, {"contactmoment": vc2.contactmoment}, HTTP_HOST="testserver.com", + list_url, + {"contactmoment": vc2.contactmoment}, + HTTP_HOST="testserver.com", ) self.assertEqual(response.status_code, status.HTTP_200_OK) diff --git a/src/verzoeken/datamodel/migrations/0004_auto_20200528_1324.py b/src/verzoeken/datamodel/migrations/0004_auto_20200528_1324.py index bdf00f3..0979a9c 100644 --- a/src/verzoeken/datamodel/migrations/0004_auto_20200528_1324.py +++ b/src/verzoeken/datamodel/migrations/0004_auto_20200528_1324.py @@ -11,7 +11,10 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RemoveField(model_name="verzoek", name="klant",), + migrations.RemoveField( + model_name="verzoek", + name="klant", + ), migrations.AlterField( model_name="verzoek", name="registratiedatum", diff --git a/src/verzoeken/datamodel/migrations/0005_auto_20200528_1628.py b/src/verzoeken/datamodel/migrations/0005_auto_20200528_1628.py index b29e6ff..18f8f10 100644 --- a/src/verzoeken/datamodel/migrations/0005_auto_20200528_1628.py +++ b/src/verzoeken/datamodel/migrations/0005_auto_20200528_1628.py @@ -43,6 +43,7 @@ class Migration(migrations.Migration): ), ), migrations.AlterUniqueTogether( - name="klantverzoek", unique_together={("verzoek", "klant")}, + name="klantverzoek", + unique_together={("verzoek", "klant")}, ), ] diff --git a/src/verzoeken/datamodel/models.py b/src/verzoeken/datamodel/models.py index 40fe46a..ff8b34f 100644 --- a/src/verzoeken/datamodel/models.py +++ b/src/verzoeken/datamodel/models.py @@ -233,7 +233,8 @@ class KlantVerzoek(models.Model): help_text="URL-referentie naar het VERZOEK.", ) klant = models.URLField( - max_length=1000, help_text=_("URL-referentie naar een KLANT (in Klanten API)"), + max_length=1000, + help_text=_("URL-referentie naar een KLANT (in Klanten API)"), ) rol = models.CharField( max_length=100, diff --git a/src/verzoeken/datamodel/tests/test_audittrail_unique_representation.py b/src/verzoeken/datamodel/tests/test_audittrail_unique_representation.py index 9493606..3d627dd 100644 --- a/src/verzoeken/datamodel/tests/test_audittrail_unique_representation.py +++ b/src/verzoeken/datamodel/tests/test_audittrail_unique_representation.py @@ -35,7 +35,8 @@ def test_verzoekproduct(self): @override_settings(ZDS_CLIENT_CLASS="vng_api_common.mocks.MockClient") def test_verzoekinformatieobject(self): vio = VerzoekInformatieObjectFactory.create( - verzoek__bronorganisatie="154760924", verzoek__identificatie="12345", + verzoek__bronorganisatie="154760924", + verzoek__identificatie="12345", ) responses = { vio.informatieobject: {