-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from open-zaak/issue/filtering-on-non-existen…
…t-gives-400 Issue/filtering on non existent gives 400
- Loading branch information
Showing
22 changed files
with
578 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
from rest_framework import status | ||
from rest_framework.test import APITestCase | ||
from vng_api_common.tests import get_validation_errors, reverse | ||
|
||
from openzaak.utils.tests import JWTAuthMixin | ||
|
||
from ..models import ( | ||
BesluitType, | ||
Eigenschap, | ||
InformatieObjectType, | ||
ResultaatType, | ||
RolType, | ||
StatusType, | ||
ZaakInformatieobjectType, | ||
ZaakType, | ||
) | ||
from .factories import ( | ||
BesluitTypeFactory, | ||
EigenschapFactory, | ||
InformatieObjectTypeFactory, | ||
ResultaatTypeFactory, | ||
RolTypeFactory, | ||
StatusTypeFactory, | ||
ZaakInformatieobjectTypeFactory, | ||
ZaakTypeFactory, | ||
) | ||
|
||
|
||
class BesluitTypeFilterTests(JWTAuthMixin, APITestCase): | ||
heeft_alle_autorisaties = True | ||
|
||
def test_filter_by_invalid_url(self): | ||
for query_param in ["catalogus", "zaaktypes", "informatieobjecttypen"]: | ||
with self.subTest(query_param=query_param): | ||
response = self.client.get(reverse(BesluitType), {query_param: "bla"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
error = get_validation_errors(response, query_param) | ||
self.assertEqual(error["code"], "invalid") | ||
|
||
def test_filter_by_valid_url_object_does_not_exist(self): | ||
besluittype = BesluitTypeFactory.create(concept=False) | ||
besluittype.zaaktypes.clear() | ||
besluittype.informatieobjecttypen.clear() | ||
for query_param in ["catalogus", "zaaktypes", "informatieobjecttypen"]: | ||
with self.subTest(query_param=query_param): | ||
response = self.client.get( | ||
reverse(BesluitType), {query_param: "https://google.com"} | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, | ||
{"count": 0, "next": None, "previous": None, "results": []}, | ||
) | ||
|
||
|
||
class EigenschapFilterTests(JWTAuthMixin, APITestCase): | ||
heeft_alle_autorisaties = True | ||
|
||
def test_filter_by_invalid_url(self): | ||
response = self.client.get(reverse(Eigenschap), {"zaaktype": "bla"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
error = get_validation_errors(response, "zaaktype") | ||
self.assertEqual(error["code"], "invalid") | ||
|
||
def test_filter_by_valid_url_object_does_not_exist(self): | ||
EigenschapFactory.create(zaaktype__concept=False) | ||
response = self.client.get( | ||
reverse(Eigenschap), {"zaaktype": "https://google.com"} | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, {"count": 0, "next": None, "previous": None, "results": []} | ||
) | ||
|
||
|
||
class InformatieObjectTypeFilterTests(JWTAuthMixin, APITestCase): | ||
heeft_alle_autorisaties = True | ||
|
||
def test_filter_by_invalid_url(self): | ||
response = self.client.get(reverse(InformatieObjectType), {"catalogus": "bla"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
error = get_validation_errors(response, "catalogus") | ||
self.assertEqual(error["code"], "invalid") | ||
|
||
def test_filter_by_valid_url_object_does_not_exist(self): | ||
informatieobjecttype = InformatieObjectTypeFactory.create(concept=False) | ||
informatieobjecttype.zaaktypes.clear() | ||
|
||
response = self.client.get( | ||
reverse(InformatieObjectType), {"catalogus": "https://google.com"} | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, {"count": 0, "next": None, "previous": None, "results": []} | ||
) | ||
|
||
|
||
class ResultaatTypeFilterTests(JWTAuthMixin, APITestCase): | ||
heeft_alle_autorisaties = True | ||
|
||
def test_filter_by_invalid_url(self): | ||
response = self.client.get(reverse(ResultaatType), {"zaaktype": "bla"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
error = get_validation_errors(response, "zaaktype") | ||
self.assertEqual(error["code"], "invalid") | ||
|
||
def test_filter_by_valid_url_object_does_not_exist(self): | ||
ResultaatTypeFactory.create(zaaktype__concept=False) | ||
response = self.client.get( | ||
reverse(ResultaatType), {"zaaktype": "https://google.com"} | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, {"count": 0, "next": None, "previous": None, "results": []} | ||
) | ||
|
||
|
||
class RolTypeFilterTests(JWTAuthMixin, APITestCase): | ||
heeft_alle_autorisaties = True | ||
|
||
def test_filter_by_invalid_url(self): | ||
response = self.client.get(reverse(RolType), {"zaaktype": "bla"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
error = get_validation_errors(response, "zaaktype") | ||
self.assertEqual(error["code"], "invalid") | ||
|
||
def test_filter_by_valid_url_object_does_not_exist(self): | ||
RolTypeFactory.create(zaaktype__concept=False) | ||
response = self.client.get(reverse(RolType), {"zaaktype": "https://google.com"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, {"count": 0, "next": None, "previous": None, "results": []} | ||
) | ||
|
||
|
||
class StatusTypeFilterTests(JWTAuthMixin, APITestCase): | ||
heeft_alle_autorisaties = True | ||
|
||
def test_filter_by_invalid_url(self): | ||
response = self.client.get(reverse(StatusType), {"zaaktype": "bla"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
error = get_validation_errors(response, "zaaktype") | ||
self.assertEqual(error["code"], "invalid") | ||
|
||
def test_filter_by_valid_url_object_does_not_exist(self): | ||
StatusTypeFactory.create(zaaktype__concept=False) | ||
response = self.client.get( | ||
reverse(StatusType), {"zaaktype": "https://google.com"} | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, {"count": 0, "next": None, "previous": None, "results": []} | ||
) | ||
|
||
|
||
class ZaakInformatieobjectTypeFilterTests(JWTAuthMixin, APITestCase): | ||
heeft_alle_autorisaties = True | ||
|
||
def test_filter_by_invalid_url(self): | ||
for query_param in ["zaaktype", "informatieobjecttype"]: | ||
with self.subTest(query_param=query_param): | ||
response = self.client.get( | ||
reverse(ZaakInformatieobjectType), {query_param: "bla"} | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
error = get_validation_errors(response, query_param) | ||
self.assertEqual(error["code"], "invalid") | ||
|
||
def test_filter_by_valid_url_object_does_not_exist(self): | ||
ZaakInformatieobjectTypeFactory.create( | ||
informatieobjecttype__concept=False, zaaktype__concept=False | ||
) | ||
for query_param in ["zaaktype", "informatieobjecttype"]: | ||
with self.subTest(query_param=query_param): | ||
response = self.client.get( | ||
reverse(ZaakInformatieobjectType), | ||
{query_param: "https://google.com"}, | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, | ||
{"count": 0, "next": None, "previous": None, "results": []}, | ||
) | ||
|
||
|
||
class ZaakTypeFilterTests(JWTAuthMixin, APITestCase): | ||
heeft_alle_autorisaties = True | ||
|
||
def test_filter_by_invalid_url(self): | ||
response = self.client.get(reverse(ZaakType), {"catalogus": "bla"}) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) | ||
|
||
error = get_validation_errors(response, "catalogus") | ||
self.assertEqual(error["code"], "invalid") | ||
|
||
def test_filter_by_valid_url_object_does_not_exist(self): | ||
zaaktype = ZaakTypeFactory.create(concept=False) | ||
zaaktype.informatieobjecttypen.clear() | ||
|
||
response = self.client.get( | ||
reverse(ZaakType), {"catalogus": "https://google.com"} | ||
) | ||
|
||
self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
self.assertEqual( | ||
response.data, {"count": 0, "next": None, "previous": None, "results": []} | ||
) |
Oops, something went wrong.