Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #11 from VNG-Realisatie/issue/docker-fixes
Browse files Browse the repository at this point in the history
Use pg_isready instead of wait_for_db.sh for docker
  • Loading branch information
joeribekker authored Sep 9, 2020
2 parents 1945f5b + 8afef04 commit fc27f8b
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
13 changes: 11 additions & 2 deletions bin/docker_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 0 additions & 17 deletions bin/wait_for_db.sh

This file was deleted.

4 changes: 2 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 8 additions & 6 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
16 changes: 9 additions & 7 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements/testing.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Shared between dev and jenkins requirements to run our tests
black
coverage
dataclasses==0.6
django-webtest
factory_boy
freezegun
Expand Down
9 changes: 7 additions & 2 deletions src/verzoeken/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
],
),
]
17 changes: 13 additions & 4 deletions src/verzoeken/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ class Meta:
"lookup_field": "uuid",
"validators": [IsImmutableValidator()],
},
"object": {"validators": [IsImmutableValidator()],},
"object": {
"validators": [IsImmutableValidator()],
},
"object_type": {"validators": [IsImmutableValidator()]},
}
validators = [ObjectVerzoekCreateValidator()]
Expand Down Expand Up @@ -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):
Expand All @@ -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 = {
Expand Down
4 changes: 3 additions & 1 deletion src/verzoeken/api/tests/test_klantverzoek.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 14 additions & 6 deletions src/verzoeken/api/tests/test_objectverzoek.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion src/verzoeken/api/tests/test_verzoekcontactmoment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Migration(migrations.Migration):
),
),
migrations.AlterUniqueTogether(
name="klantverzoek", unique_together={("verzoek", "klant")},
name="klantverzoek",
unique_together={("verzoek", "klant")},
),
]
3 changes: 2 additions & 1 deletion src/verzoeken/datamodel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit fc27f8b

Please sign in to comment.