Skip to content

Commit

Permalink
Merge pull request #223 from OnroerendErfgoed/feature/222_aanpassinge…
Browse files Browse the repository at this point in the history
…n_gemeente_fusies

#222 aanpassingen gemeentefusies
  • Loading branch information
claeyswo authored Nov 26, 2024
2 parents 35abdbd + 649928f commit 4934615
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions crabpy_pyramid/renderers/adressenregister.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def list_gemeente_adapter(obj, request):
"niscode": obj.niscode,
"naam": obj.naam(),
"provincie": {"niscode": obj.provincie_niscode},
"status": obj.status,
}


Expand Down
5 changes: 4 additions & 1 deletion crabpy_pyramid/views/adressenregister.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
]
dependencies = [
"pyramid>=2.0.0",
"crabpy>=1.3.2",
"crabpy>=1.5.0",
"pycountry>=23.12.11",
]

Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 28 additions & 2 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.. versionadded:: 0.1.0
"""

import os
import shutil
import unittest
Expand Down Expand Up @@ -220,14 +221,31 @@ 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(
{
"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],
)
Expand All @@ -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)
Expand Down

0 comments on commit 4934615

Please sign in to comment.