diff --git a/crabpy_pyramid/renderers/adressenregister.py b/crabpy_pyramid/renderers/adressenregister.py index e3fa218..aaed5b6 100644 --- a/crabpy_pyramid/renderers/adressenregister.py +++ b/crabpy_pyramid/renderers/adressenregister.py @@ -50,6 +50,7 @@ def list_gemeente_adapter(obj, request): "niscode": obj.niscode, "naam": obj.naam(), "provincie": {"niscode": obj.provincie_niscode}, + "status": obj.status, } diff --git a/crabpy_pyramid/views/adressenregister.py b/crabpy_pyramid/views/adressenregister.py index 7d6ce57..69eff0b 100644 --- a/crabpy_pyramid/views/adressenregister.py +++ b/crabpy_pyramid/views/adressenregister.py @@ -118,8 +118,11 @@ def list_gemeenten_by_provincie(request): request = set_http_caching(request, "adressenregister", "long") Gateway = request.adressenregister_gateway() provincie_id = request.matchdict.get("provincie_niscode") + kwargs = extract_valid_params(Gateway.list_gemeenten_by_provincie, request) provincie = handle_gateway_response(Gateway.get_provincie_by_niscode, provincie_id) - gemeenten = handle_gateway_response(Gateway.list_gemeenten_by_provincie, provincie) + gemeenten = handle_gateway_response( + Gateway.list_gemeenten_by_provincie, provincie, **kwargs + ) return range_return(request, gemeenten) diff --git a/pyproject.toml b/pyproject.toml index 683f70b..4397402 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ classifiers = [ ] dependencies = [ "pyramid>=2.0.0", - "crabpy>=1.3.2", + "crabpy>=1.5.0", "pycountry>=23.12.11", ] diff --git a/requirements-dev.txt b/requirements-dev.txt index 5262c48..8b3742d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -14,7 +14,7 @@ coverage==7.6.3 # via coveralls coveralls==4.0.1 # via crabpy_pyramid (pyproject.toml) -crabpy==1.3.2 +crabpy==1.5.0 # via crabpy_pyramid (pyproject.toml) decorator==5.1.1 # via dogpile-cache diff --git a/requirements.txt b/requirements.txt index c9f9a52..87b2b31 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ certifi==2024.8.30 # via requests charset-normalizer==3.4.0 # via requests -crabpy==1.3.2 +crabpy==1.5.0 # via crabpy_pyramid (pyproject.toml) decorator==5.1.1 # via dogpile-cache diff --git a/tests/test_functional.py b/tests/test_functional.py index 1f34b07..c862647 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -3,6 +3,7 @@ .. versionadded:: 0.1.0 """ + import os import shutil import unittest @@ -220,7 +221,9 @@ def test_list_deelgemeenten_by_unexisting_gemeente(self): self.assertEqual("404 Not Found", res.status) def test_list_gemeenten_by_provincie(self): - res = self.testapp.get("/adressenregister/provincies/10000/gemeenten") + res = self.testapp.get( + "/adressenregister/provincies/10000" "/gemeenten?gemeente_status=inGebruik" + ) self.assertEqual("200 OK", res.status) self.assertEqual(len(res.json), 69) self.assertDictEqual( @@ -228,6 +231,21 @@ def test_list_gemeenten_by_provincie(self): "naam": "Aartselaar", "niscode": "11001", "provincie": {"niscode": "10000"}, + "status": "inGebruik", + }, + res.json[0], + ) + res = self.testapp.get( + "/adressenregister/provincies/10000/gemeenten?gemeente_status=voorgesteld" + ) + self.assertEqual("200 OK", res.status) + self.assertEqual(len(res.json), 1) + self.assertDictEqual( + { + "naam": "Beveren-Kruibeke-Zwijndrecht", + "niscode": "46030", + "provincie": {"niscode": "10000"}, + "status": "voorgesteld", }, res.json[0], ) @@ -239,8 +257,16 @@ def test_list_gemeenten_by_provincie_404(self): self.assertEqual("404 Not Found", res.status) def test_list_gemeenten_adressenregister(self): - res = self.testapp.get("/adressenregister/gewesten/2000/gemeenten") + res = self.testapp.get( + "/adressenregister/gewesten/2000/gemeenten?gemeente_status=inGebruik" + ) + self.assertEqual("200 OK", res.status) + self.assertEqual(300, len(res.json)) + res = self.testapp.get( + "/adressenregister/gewesten/2000/gemeenten?gemeente_status=voorgesteld" + ) self.assertEqual("200 OK", res.status) + self.assertEqual(12, len(res.json)) def test_list_gemeenten_adressenregister_404(self): res = self.testapp.get("/adressenregister/gewesten/20000/gemeenten", status=404)