Skip to content

Commit

Permalink
Merge pull request #203 from OnroerendErfgoed/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
claeyswo authored Nov 24, 2023
2 parents 1a77324 + b4365ed commit 06e05f3
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 58 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.7.0 (24-11-2023)
------------------

- Homoniemen toevoegen bij straten (#200)

1.6.0 (30-05-2023)
------------------

Expand Down
2 changes: 1 addition & 1 deletion crabpy_pyramid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _parse_settings(settings):
'cache.file.root': '/tmp/dogpile_data',
}
args = defaults.copy()
if 'adressenregister.api_key' not in settings:
if 'crabpy.adressenregister.api_key' not in settings:
log.warning(
"No adressenregister.api_key set in settings. "
"The api might stop working after reaching the limit of x requests per day."
Expand Down
43 changes: 15 additions & 28 deletions crabpy_pyramid/renderers/adressenregister.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ def list_gewesten_adapter(obj, request):
Adapter for rendering a list of
:class:`crabpy.gateway.adressenregister.Gewest` to json.
"""
return {
"naam": obj.naam,
"niscode": obj.niscode
}
return {"naam": obj.naam, "niscode": obj.niscode}


def list_provincie_adapter(obj, request):
Expand All @@ -39,9 +36,7 @@ def list_deelgemeente_adapter(obj, request):
return {
"niscode": obj.id,
"naam": obj.naam,
"gemeente": {
"niscode": obj.gemeente_niscode
},
"gemeente": {"niscode": obj.gemeente_niscode},
}


Expand All @@ -53,9 +48,7 @@ def list_gemeente_adapter(obj, request):
return {
"niscode": obj.niscode,
"naam": obj.naam(),
"provincie": {
"niscode": obj.provincie_niscode
}
"provincie": {"niscode": obj.provincie_niscode},
}


Expand All @@ -66,9 +59,10 @@ def list_straten_adapter(obj, request):
"""
return {
"id": obj.id,
"naam": obj.naam,
"naam": obj.naam(),
"homoniem": obj.homoniem(),
"status": obj.status,
"uri": obj.uri
"uri": obj.uri,
}


Expand All @@ -92,11 +86,7 @@ def list_percelen_adapter(obj, request):
Adapter for rendering a list of
:class:`crabpy.gateway.adressenregister.Perceel` to json.
"""
return {
"id": obj.id,
"uri": obj.uri,
"status": obj.status
}
return {"id": obj.id, "uri": obj.uri, "status": obj.status}


def list_postinfo_adapter(obj, request):
Expand All @@ -116,10 +106,7 @@ def list_landen_adapter(obj, request):
"""
Adapter for rendering a list of landen to json.
"""
return {
"code": obj.alpha_2,
"naam": _(obj.name)
}
return {"code": obj.alpha_2, "naam": _(obj.name)}


json_list_renderer.add_adapter(adressenregister.Gewest, list_gewesten_adapter)
Expand Down Expand Up @@ -169,7 +156,7 @@ def item_gemeente_adapter(obj, request):
"niscode": obj.niscode,
"naam": obj.naam(),
"provincie": {"niscode": obj.provincie_niscode},
"gewest": {"niscode": obj.gewest.niscode}
"gewest": {"niscode": obj.gewest.niscode},
}


Expand All @@ -181,10 +168,7 @@ def item_deelgemeente_adapter(obj, request):
return {
"niscode": obj.id,
"naam": obj.naam,
"gemeente": {
"niscode": obj.gemeente.niscode,
"naam": obj.gemeente.naam()
},
"gemeente": {"niscode": obj.gemeente.niscode, "naam": obj.gemeente.naam()},
}


Expand All @@ -195,9 +179,12 @@ def item_straat_adapter(obj, request):
"""
return {
"id": obj.id,
"naam": obj.naam(),
"naam": obj.naam(
include_homoniem=True if request.params.get("include_homoniem") else False
),
"homoniem": obj.homoniem(),
"status": obj.status,
"uri": obj.uri
"uri": obj.uri,
}


Expand Down
64 changes: 38 additions & 26 deletions crabpy_pyramid/tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,41 @@ def run_integration_tests(section):


settings = {
'crabpy.cache.file.root': os.path.join(os.path.dirname(__file__), 'dogpile_data'),
'crabpy.capakey.cache_config.permanent.backend': 'dogpile.cache.dbm',
'crabpy.capakey.cache_config.permanent.expiration_time': 604800,
'crabpy.capakey.cache_config.permanent.arguments.filename': os.path.join(os.path.dirname(__file__), 'dogpile_data', 'capakey_permanent.dbm'),
'crabpy.capakey.cache_config.long.backend': 'dogpile.cache.dbm',
'crabpy.capakey.cache_config.long.expiration_time': 86400,
'crabpy.capakey.cache_config.long.arguments.filename': os.path.join(os.path.dirname(__file__), 'dogpile_data', 'capakey_long.dbm'),
'crabpy.capakey.cache_config.short.backend': 'dogpile.cache.dbm',
'crabpy.capakey.cache_config.short.expiration_time': 3600,
'crabpy.capakey.cache_config.short.arguments.filename': os.path.join(os.path.dirname(__file__), 'dogpile_data', 'capakey_short.dbm'),
'crabpy.crab.include': True,
'crabpy.crab.cache_config.permanent.backend': 'dogpile.cache.dbm',
'crabpy.crab.cache_config.permanent.expiration_time': 604800,
'crabpy.crab.cache_config.permanent.arguments.filename': os.path.join(
os.path.dirname(__file__), 'dogpile_data', 'crab_permanent.dbm'),
'crabpy.crab.cache_config.long.backend': 'dogpile.cache.dbm',
'crabpy.crab.cache_config.long.expiration_time': 86400,
'crabpy.crab.cache_config.long.arguments.filename': os.path.join(
os.path.dirname(__file__), 'dogpile_data', 'crab_long.dbm'),
'crabpy.crab.cache_config.short.backend': 'dogpile.cache.dbm',
'crabpy.crab.cache_config.short.expiration_time': 3600,
'crabpy.crab.cache_config.short.arguments.filename': os.path.join(
os.path.dirname(__file__), 'dogpile_data', 'crab_short.dbm'),
'crabpy.adressenregister.include': True,
'crabpy.adressenregister.base_url': 'https://api.basisregisters.vlaanderen.be',
'crabpy.adressenregister.api_key': '',
"crabpy.cache.file.root": os.path.join(os.path.dirname(__file__), "dogpile_data"),
"crabpy.capakey.cache_config.permanent.backend": "dogpile.cache.dbm",
"crabpy.capakey.cache_config.permanent.expiration_time": 604800,
"crabpy.capakey.cache_config.permanent.arguments.filename": os.path.join(
os.path.dirname(__file__), "dogpile_data", "capakey_permanent.dbm"
),
"crabpy.capakey.cache_config.long.backend": "dogpile.cache.dbm",
"crabpy.capakey.cache_config.long.expiration_time": 86400,
"crabpy.capakey.cache_config.long.arguments.filename": os.path.join(
os.path.dirname(__file__), "dogpile_data", "capakey_long.dbm"
),
"crabpy.capakey.cache_config.short.backend": "dogpile.cache.dbm",
"crabpy.capakey.cache_config.short.expiration_time": 3600,
"crabpy.capakey.cache_config.short.arguments.filename": os.path.join(
os.path.dirname(__file__), "dogpile_data", "capakey_short.dbm"
),
"crabpy.crab.include": True,
"crabpy.crab.cache_config.permanent.backend": "dogpile.cache.dbm",
"crabpy.crab.cache_config.permanent.expiration_time": 604800,
"crabpy.crab.cache_config.permanent.arguments.filename": os.path.join(
os.path.dirname(__file__), "dogpile_data", "crab_permanent.dbm"
),
"crabpy.crab.cache_config.long.backend": "dogpile.cache.dbm",
"crabpy.crab.cache_config.long.expiration_time": 86400,
"crabpy.crab.cache_config.long.arguments.filename": os.path.join(
os.path.dirname(__file__), "dogpile_data", "crab_long.dbm"
),
"crabpy.crab.cache_config.short.backend": "dogpile.cache.dbm",
"crabpy.crab.cache_config.short.expiration_time": 3600,
"crabpy.crab.cache_config.short.arguments.filename": os.path.join(
os.path.dirname(__file__), "dogpile_data", "crab_short.dbm"
),
"crabpy.adressenregister.include": True,
"crabpy.adressenregister.base_url": "https://api.basisregisters.vlaanderen.be",
"crabpy.adressenregister.api_key": "",
}


Expand Down Expand Up @@ -526,12 +535,14 @@ def test_list_straten(self):
{
"id": "1",
"naam": "Acacialaan",
"homoniem": None,
"status": "inGebruik",
"uri": "https://data.vlaanderen.be/id/straatnaam/1",
},
{
"id": "2",
"naam": "Adriaan Sanderslei",
"homoniem": None,
"status": "inGebruik",
"uri": "https://data.vlaanderen.be/id/straatnaam/2",
},
Expand All @@ -558,6 +569,7 @@ def test_get_straat_by_id(self):
{
"id": "1",
"naam": "Acacialaan",
"homoniem": None,
"status": "inGebruik",
"uri": "https://data.vlaanderen.be/id/straatnaam/1",
},
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 @@ -177,7 +177,10 @@ def list_straten(request):
request = set_http_caching(request, "adressenregister", "short")
Gateway = request.adressenregister_gateway()
gemeente_niscode = request.matchdict.get("niscode")
straten = handle_gateway_response(Gateway.list_straten, gemeente_niscode)
include_homoniem = True if request.params.get("include_homoniem") else False
straten = handle_gateway_response(
Gateway.list_straten, gemeente_niscode, include_homoniem=include_homoniem
)

return range_return(request, straten)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tested and approved with these versions
pyramid==2.0.0
crabpy==1.2.4
crabpy==1.3.1
pycountry==18.12.8 ; python_version < '3.0'
pycountry==22.3.5 ; python_version >= '3.4'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
testing_extras = tests_requires + []

setup(name='crabpy_pyramid',
version='1.6.0',
version='1.7.0',
description='Bindings for the CRABpy webservices and the Pyramid framework.',
long_description=README + '\n\n' + CHANGES,
classifiers=[
Expand Down

0 comments on commit 06e05f3

Please sign in to comment.