Skip to content

Commit

Permalink
Merge pull request #145 from open-zaak/issue/bio-zio-filter-internal-…
Browse files Browse the repository at this point in the history
…server-error

Issue/bio zio filter internal server error
  • Loading branch information
sergei-maertens committed Nov 7, 2019
2 parents ca2e7bd + a3994ac commit ec9a23c
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 39 deletions.
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ django-cors-middleware==1.3.1
django-extra-fields==1.2.4
django-filter==2.0
django-ipware==2.1.0 # via django-axes
django-loose-fk==0.5.4
django-loose-fk==0.5.5
django-markup==1.3
django-ordered-model==2.1.0 # via django-admin-index
django-privates==1.0.1.post0
Expand Down
2 changes: 1 addition & 1 deletion requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ django-cors-middleware==1.3.1
django-extra-fields==1.2.4
django-filter==2.0.0
django-ipware==2.1.0
django-loose-fk==0.5.4
django-loose-fk==0.5.5
django-markup==1.3
django-ordered-model==2.1.0
django-privates==1.0.1.post0
Expand Down
11 changes: 7 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ alabaster==0.7.12 # via sphinx
appdirs==1.4.3 # via black
attrs==19.1.0 # via black
babel==2.7.0 # via sphinx
black==19.3b0
black==19.10b0
certifi==2018.4.16
chardet==3.0.4
click==7.0 # via black, pip-tools
Expand All @@ -27,7 +27,7 @@ django-extensions==2.2.1
django-extra-fields==1.2.4
django-filter==2.0.0
django-ipware==2.1.0
django-loose-fk==0.5.4
django-loose-fk==0.5.5
django-markup==1.3
django-ordered-model==2.1.0
django-privates==1.0.1.post0
Expand Down Expand Up @@ -61,7 +61,8 @@ markdown==3.0.1
markupsafe==1.0
oyaml==0.7
packaging==19.2 # via sphinx
pip-tools==4.1.0
pathspec==0.6.0 # via black
pip-tools==4.2.0
psycopg2==2.8.3
pygments==2.4.2 # via sphinx
pyjwt==1.6.4
Expand All @@ -74,6 +75,7 @@ pyyaml==5.1
raven==6.9.0
recommonmark==0.6.0
redis==3.3.8
regex==2019.11.1 # via black
requests-mock==1.6.0
requests==2.21.0
ruamel.yaml==0.15.37
Expand All @@ -91,11 +93,12 @@ sqlparse==0.3.0
tblib==1.4.0
text-unidecode==1.2
toml==0.10.0 # via black
typed-ast==1.4.0 # via black
unidecode==1.0.22
uritemplate==3.0.0
urllib3==1.24.3
uwsgi==2.0.18
vng-api-common==1.0.27

# The following packages are considered to be unsafe in a requirements file:
# setuptools==41.4.0 # via sphinx
# setuptools==41.6.0 # via sphinx
8 changes: 8 additions & 0 deletions src/openzaak/components/besluiten/api/filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from vng_api_common.filters import URLModelChoiceFilter
from vng_api_common.filtersets import FilterSet

from openzaak.components.documenten.models import EnkelvoudigInformatieObjectCanonical

from ..models import Besluit, BesluitInformatieObject


Expand All @@ -15,6 +18,11 @@ class Meta:


class BesluitInformatieObjectFilter(FilterSet):
informatieobject = URLModelChoiceFilter(
queryset=EnkelvoudigInformatieObjectCanonical.objects.all(),
instance_path="canonical",
)

class Meta:
model = BesluitInformatieObject
fields = ("besluit", "informatieobject")
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from rest_framework.test import APITestCase
from vng_api_common.tests import TypeCheckMixin, get_validation_errors, reverse

from openzaak.components.catalogi.tests.factories import (
BesluitTypeFactory,
CatalogusFactory,
)
from openzaak.components.catalogi.tests.factories import BesluitTypeFactory
from openzaak.components.documenten.tests.factories import (
EnkelvoudigInformatieObjectFactory,
)
Expand Down Expand Up @@ -129,12 +126,12 @@ def test_opvragen_informatieobjecten_besluit(self):
base_uri = get_operation_url("besluitinformatieobject_list")

response1 = self.client.get(
base_uri, {"besluit": f"http://testserver.com{besluit1_uri}"}
base_uri, {"besluit": f"http://openzaak.nl{besluit1_uri}"}
)
self.assertEqual(len(response1.data), 3)

response2 = self.client.get(
base_uri, {"besluit": f"http://testserver.com{besluit2_uri}"}
base_uri, {"besluit": f"http://openzaak.nl{besluit2_uri}"}
)
self.assertEqual(len(response2.data), 2)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,36 @@ def test_read_besluit(self):

self.assertEqual(response.json(), expected)

def test_filter(self):
def test_filter_by_besluit(self):
bio = BesluitInformatieObjectFactory.create()
besluit_url = reverse(bio.besluit)
bio_list_url = reverse("besluitinformatieobject-list")

response = self.client.get(
bio_list_url, {"besluit": f"http://testserver.com{besluit_url}"}
bio_list_url, {"besluit": f"http://openzaak.nl{besluit_url}"}
)

self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 1)
self.assertEqual(response.data[0]["besluit"], f"http://testserver{besluit_url}")

def test_filter_by_informatieobject(self):
bio = BesluitInformatieObjectFactory.create()
io_url = reverse(bio.informatieobject.latest_version)
bio_list_url = reverse("besluitinformatieobject-list")

response = self.client.get(
bio_list_url,
{"informatieobject": f"http://openzaak.nl{io_url}"},
HTTP_HOST="openzaak.nl",
)

self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data), 1)
self.assertEqual(
response.data[0]["informatieobject"], f"http://openzaak.nl{io_url}"
)

def test_update_besluit(self):
bio = BesluitInformatieObjectFactory.create()
bio_detail_url = reverse(bio)
Expand Down
6 changes: 3 additions & 3 deletions src/openzaak/components/catalogi/tests/test_besluittype.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework import status
from vng_api_common.constants import ComponentTypes
from vng_api_common.tests import get_operation_url, get_validation_errors, reverse
from vng_api_common.tests import get_validation_errors, reverse

from ..api.scopes import SCOPE_ZAAKTYPES_READ, SCOPE_ZAAKTYPES_WRITE
from ..api.validators import (
Expand Down Expand Up @@ -729,7 +729,7 @@ def test_filter_zaaktypes(self):
besluittype1 = BesluitTypeFactory.create(concept=False)
besluittype2 = BesluitTypeFactory.create(concept=False)
zaaktype1 = besluittype1.zaaktypes.get()
zaaktype1_url = f"http://testserver.com{reverse(zaaktype1)}"
zaaktype1_url = f"http://openzaak.nl{reverse(zaaktype1)}"
besluittype_list_url = reverse("besluittype-list")
besluittype1_url = reverse(besluittype1)

Expand All @@ -749,7 +749,7 @@ def test_filter_informatieobjecttypen(self):
besluittype1.informatieobjecttypen.add(iot1)
besluittype_list_url = reverse("besluittype-list")
besluittype1_url = reverse(besluittype1)
iot1_url = f"http://testserver.com{reverse(iot1)}"
iot1_url = f"http://openzaak.nl{reverse(iot1)}"

response = self.client.get(
besluittype_list_url, {"informatieobjecttypen": iot1_url}
Expand Down
5 changes: 2 additions & 3 deletions src/openzaak/components/catalogi/tests/test_relatieklassen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from ..models import ZaakInformatieobjectType
from .base import APITestCase
from .factories import (
CatalogusFactory,
InformatieObjectTypeFactory,
ZaakInformatieobjectTypeArchiefregimeFactory,
ZaakInformatieobjectTypeFactory,
Expand Down Expand Up @@ -224,7 +223,7 @@ def test_filter_zaaktype(self):
url = f"http://testserver{reverse(ztiot1)}"
zaaktype1_uri = reverse(ztiot1.zaaktype)
zaaktype2_uri = reverse(ztiot2.zaaktype)
zaaktype1_url = f"http://testserver.com{zaaktype1_uri}"
zaaktype1_url = f"http://openzaak.nl{zaaktype1_uri}"

response = self.client.get(self.list_url, {"zaaktype": zaaktype1_url})

Expand All @@ -243,7 +242,7 @@ def test_filter_informatieobjecttype(self):
url = f"http://testserver{reverse(ztiot1)}"
informatieobjecttype1_uri = reverse(ztiot1.informatieobjecttype)
informatieobjecttype2_uri = reverse(ztiot2.informatieobjecttype)
informatieobjecttype1_url = f"http://testserver.com{informatieobjecttype1_uri}"
informatieobjecttype1_url = f"http://openzaak.nl{informatieobjecttype1_uri}"

response = self.client.get(
self.list_url, {"informatieobjecttype": informatieobjecttype1_url}
Expand Down
8 changes: 4 additions & 4 deletions src/openzaak/components/catalogi/tests/test_resultaattype.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,13 @@ def test_filter_on_zaaktype(self):

rt1_uri = reverse(rt1)
rt2_uri = reverse(rt2)
rt1_url = f"http://testserver.com{rt1_uri}"
rt2_url = f"http://testserver.com{rt2_uri}"
rt1_url = f"http://openzaak.nl{rt1_uri}"
rt2_url = f"http://openzaak.nl{rt2_uri}"

zt1_uri = reverse("zaaktype-detail", kwargs={"uuid": zt1.uuid})
zt2_uri = reverse("zaaktype-detail", kwargs={"uuid": zt2.uuid})
zt1_url = "http://testserver.com{}".format(zt1_uri)
zt2_url = "http://testserver.com{}".format(zt2_uri)
zt1_url = "http://openzaak.nl{}".format(zt1_uri)
zt2_url = "http://openzaak.nl{}".format(zt2_uri)
list_url = reverse("resultaattype-list")

response = self.client.get(list_url, {"zaaktype": zt1_url})
Expand Down
2 changes: 1 addition & 1 deletion src/openzaak/components/catalogi/tests/test_roltype.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def test_filter_zaaktype(self):
zaaktype1_url = reverse(zaaktype1)

response = self.client.get(
roltype_list_url, {"zaaktype": f"http://testserver.com{zaaktype1_url}"}
roltype_list_url, {"zaaktype": f"http://openzaak.nl{zaaktype1_url}"}
)

self.assertEqual(response.status_code, 200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ def test_filter_eio(self):
eio_detail_url = reverse(bio.informatieobject.latest_version)

response = self.client.get(
self.list_url,
{"informatieobject": f"http://testserver.com{eio_detail_url}"},
self.list_url, {"informatieobject": f"http://openzaak.nl{eio_detail_url}"},
)

self.assertEqual(response.status_code, 200)
Expand All @@ -219,7 +218,7 @@ def test_filter_zaak(self):
zaak_url = reverse(zio.zaak)

response = self.client.get(
self.list_url, {"object": f"http://testserver.com{zaak_url}"}
self.list_url, {"object": f"http://openzaak.nl{zaak_url}"}
)

self.assertEqual(response.status_code, 200)
Expand All @@ -235,7 +234,7 @@ def test_filter_besluit(self):
besluit_url = reverse(bio.besluit)

response = self.client.get(
self.list_url, {"object": f"http://testserver.com{besluit_url}"}
self.list_url, {"object": f"http://openzaak.nl{besluit_url}"}
)

self.assertEqual(response.status_code, 200)
Expand Down
5 changes: 5 additions & 0 deletions src/openzaak/components/zaken/api/filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django_filters import filters
from django_loose_fk.filters import FkOrUrlFieldFilter
from vng_api_common.filtersets import FilterSet
from vng_api_common.utils import get_help_text

Expand Down Expand Up @@ -86,6 +87,10 @@ class Meta:


class ZaakInformatieObjectFilter(FilterSet):
informatieobject = FkOrUrlFieldFilter(
queryset=ZaakInformatieObject.objects.all(), instance_path="canonical"
)

class Meta:
model = ZaakInformatieObject
fields = ("zaak", "informatieobject")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_ophalen_alle_betrokkenen(self):
rollen_list_url = get_operation_url("rol_list")

response = self.client.get(
rollen_list_url, {"zaak": f"http://testserver.com{zaak_url}"}
rollen_list_url, {"zaak": f"http://openzaak.nl{zaak_url}"}
)

self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand Down
4 changes: 1 addition & 3 deletions src/openzaak/components/zaken/tests/test_statussen.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def test_filter_statussen_op_zaak(self):

zaak_url = reverse("zaak-detail", kwargs={"uuid": status1.zaak.uuid})

response = self.client.get(
list_url, {"zaak": f"http://testserver.com{zaak_url}"}
)
response = self.client.get(list_url, {"zaak": f"http://openzaak.nl{zaak_url}"})

self.assertEqual(response.status_code, status.HTTP_200_OK)

Expand Down
2 changes: 1 addition & 1 deletion src/openzaak/components/zaken/tests/test_zaak_zoek.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_filter_ook_zaaktype(self):
"coordinates": [POLYGON_AMSTERDAM_CENTRUM],
}
},
"zaaktype": f"http://testserver.com{zaaktype1_url}",
"zaaktype": f"http://openzaak.nl{zaaktype1_url}",
},
**ZAAK_WRITE_KWARGS,
)
Expand Down

0 comments on commit ec9a23c

Please sign in to comment.