diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index f85c010..0000000 --- a/.coveragerc +++ /dev/null @@ -1,3 +0,0 @@ -[report] -omit = - */site-packages/* diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..c9b4124 --- /dev/null +++ b/.flake8 @@ -0,0 +1,12 @@ +[flake8] +application_import_names = crabpy_pyramid,tests +import-order-style = pycharm + +extend-exclude = + .pytest_cache +filename = + ./tests/**.py + ./crabpy_pyramid/**.py +max-line-length = 80 +extend-select = B950 +extend-ignore = E203,E501,E701 \ No newline at end of file diff --git a/.github/pr-labeler.yml b/.github/pr-labeler.yml new file mode 100644 index 0000000..8888cd4 --- /dev/null +++ b/.github/pr-labeler.yml @@ -0,0 +1,3 @@ +feature: ['feature/*', 'feat/*'] +fix: ['bugfix/*', 'fix/*'] +test: test/* diff --git a/.github/workflows/backend.yaml b/.github/workflows/backend.yaml new file mode 100644 index 0000000..a765946 --- /dev/null +++ b/.github/workflows/backend.yaml @@ -0,0 +1,42 @@ +name: crabpy_pyramid tests + +on: + push: + paths: + - crabpy_pyramid/** + - tests/** + - .github/workflows/backend.yaml + - pyproject.toml + - requirements*.txt + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ "3.10", "3.11", "3.12" ] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Display Python version + run: python -c "import sys; print(sys.version)" + + - name: Install python requirements + run: | + pip install pip-tools + pip-sync requirements-ci.txt + pip install -e . + + - name: Python tests + run: | + flake8 + coverage run --source=crabpy_pyramid -m pytest tests + + - name: Coveralls + uses: coverallsapp/github-action@v2 diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml new file mode 100644 index 0000000..6d41fc2 --- /dev/null +++ b/.github/workflows/pr-labeler.yml @@ -0,0 +1,22 @@ +name: PR Labeler +on: + pull_request: + types: [opened] + branches: + - 'develop' + - 'epic' + +permissions: + contents: read + +jobs: + pr-labeler: + permissions: + contents: read # for TimonVS/pr-labeler-action to read config file + pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR + runs-on: ubuntu-latest + steps: + - uses: TimonVS/pr-labeler-action@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + configuration-path: .github/pr-labeler.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2d3eee8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -dist: focal -sudo: false -language: python -python: - - 3.11 -install: - - pip install -r requirements-dev.txt - - pip install -e . -script: - cd crabpy_pyramid; python -m unittest discover -s tests -after_success: - coveralls diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 15de862..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include README.rst CHANGES.rst LICENSE diff --git a/README.md b/README.md new file mode 100644 index 0000000..df67388 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +# crabpy_pyramid + +Bindings for the crabpy library and the pyramid framework + +[![pypi](https://badge.fury.io/py/crabpy_pyramid.png)](http://badge.fury.io/py/crabpy_pyramid) +[![docs](https://readthedocs.org/projects/crabpy-pyramid/badge/?version=latest)](https://readthedocs.org/projects/crabpy-pyramid/?badge=latest) +[![CI](https://github.com/OnroerendErfgoed/crabpy_pyramid/actions/workflows/backend.yaml/badge.svg)](https://github.com/OnroerendErfgoed/crabpy_pyramid/actions/workflows/backend.yaml) +[![coverage](https://coveralls.io/repos/OnroerendErfgoed/crabpy_pyramid/badge.png?branch=master)](https://coveralls.io/r/OnroerendErfgoed/crabpy_pyramid?branch=master) +[![pypi](https://badge.fury.io/py/crabpy_pyramid.png)](http://badge.fury.io/py/crabpy_pyramid) + + +# Development +## Building the docs + +More information about this library can be found in `docs`. The docs can be +built using `Sphinx `_. + +Please make sure you have installed Sphinx in the same environment where +crabpy\_pyramid is present. + +```sh +pip install sphinx sphinxcontrib-httpdomain +pip install -e . +cd docs +make html +``` + +## Build wheel or sdist + +```sh +pip install hatch +hatch build +hatch build -t wheel +hatch build -t sdist +``` + + +## Work with pip-compile / pip-sync + +full docs: https://pip-tools.readthedocs.io/en/latest/ + +To start, first install pip-tools: +```sh +pip install pip-tools +``` + +### uv (optional) + +You can also use `uv` and for the remainder of the readme replace `pip`, `pip-compile` or +`pip-sync` by `uv pip`, `uv pip compile` and `uv pip sync`. + +`uv` is a very fast replacement for pip-toools. It's optional, but can save a lot of time. +```sh +pip install uv +``` + +### Install requirements: pip-sync + +Note, `pip-sync` also uninstalls everything from the virtualenv which does not belong +there according to the requirements file. This includes the project itself. You will +have to install `crabpy_pyramid` again after `pip-sync`. +Since the requirements file of pip-sync is still a normal requirements file you can also +use `pip install -r` to install all libraries defined in it. This will not cleanup your +virtualenv and uninstall other libraries. + +The compiled requirements files are made in a 3.11 environment. +```sh +pip-sync requirements-dev.txt +pip install -e . +``` +`requirements-dev.txt` contains all libraries uncluding those for testing and development. + +`requirements.txt` contains only the necessary libraries for running the library. + +### Update requirements: pip-compile + +```sh +echo -e "\nStarting" +PIP_COMPILE_ARGS="-q --strip-extras --no-header --resolver=backtracking --no-emit-options pyproject.toml" +pip-compile $PIP_COMPILE_ARGS -o requirements.txt; +echo "requirements.txt done" +pip-compile $PIP_COMPILE_ARGS --extra dev -o requirements-dev.txt; +echo "requirements-dev.txt done" +echo "Finished" +``` diff --git a/README.rst b/README.rst deleted file mode 100644 index c00c1b2..0000000 --- a/README.rst +++ /dev/null @@ -1,33 +0,0 @@ -crabpy_pyramid -============== - -Bindings for the crabpy library and the pyramid framework - -.. image:: https://badge.fury.io/py/crabpy_pyramid.png - :target: http://badge.fury.io/py/crabpy_pyramid -.. image:: https://readthedocs.org/projects/crabpy-pyramid/badge/?version=latest - :target: https://readthedocs.org/projects/crabpy-pyramid/?badge=latest - -.. image:: https://travis-ci.org/OnroerendErfgoed/crabpy_pyramid.png?branch=master - :target: https://travis-ci.org/OnroerendErfgoed/crabpy_pyramid -.. image:: https://coveralls.io/repos/OnroerendErfgoed/crabpy_pyramid/badge.png?branch=master - :target: https://coveralls.io/r/OnroerendErfgoed/crabpy_pyramid?branch=master -.. image:: https://scrutinizer-ci.com/g/OnroerendErfgoed/crabpy_pyramid/badges/quality-score.png?b=master - :target: https://scrutinizer-ci.com/g/OnroerendErfgoed/crabpy_pyramid/?branch=master - -Building the docs ------------------ - -More information about this library can be found in `docs`. The docs can be -built using `Sphinx `_. - -Please make sure you have installed Sphinx in the same environment where -crabpy\_pyramid is present. - -.. code-block:: bash - - # activate your virtual env - $ pip install sphinx sphinxcontrib-httpdomain - $ python setup.py develop - $ cd docs - $ make html diff --git a/crabpy_pyramid/renderers/capakey.py b/crabpy_pyramid/renderers/capakey.py index 4980169..f29b946 100644 --- a/crabpy_pyramid/renderers/capakey.py +++ b/crabpy_pyramid/renderers/capakey.py @@ -5,9 +5,9 @@ .. versionadded:: 0.1.0 """ from crabpy.gateway import capakey - from pyramid.renderers import JSON + json_list_renderer = JSON() json_item_renderer = JSON() @@ -17,10 +17,7 @@ def list_gemeente_adapter(obj, request): Adapter for rendering a list of :class: `crabpy.gateway.capakey.Gemeente` to json. """ - return { - 'id': obj.id, - 'naam': obj.naam - } + return {"id": obj.id, "naam": obj.naam} def list_afdeling_adapter(obj, request): @@ -28,11 +25,7 @@ def list_afdeling_adapter(obj, request): Adapter for rendering a list of :class: `crabpy.gateway.capakey.Afdeling` to json. """ - return { - 'id': obj.id, - 'naam': obj.naam, - 'gemeente': obj.gemeente - } + return {"id": obj.id, "naam": obj.naam, "gemeente": obj.gemeente} def list_sectie_adapter(obj, request): @@ -40,10 +33,7 @@ def list_sectie_adapter(obj, request): Adapter for rendering a list of :class: `crabpy.gateway.capakey.Sectie` to json. """ - return { - 'id': obj.id, - 'afdeling': obj.afdeling - } + return {"id": obj.id, "afdeling": obj.afdeling} def list_perceel_adapter(obj, request): @@ -52,10 +42,10 @@ def list_perceel_adapter(obj, request): :class: `crabpy.gateway.capakey.Perceel` to json. """ return { - 'id': obj.id, - 'sectie': obj.sectie, - 'capakey': obj.capakey, - 'percid': obj.percid + "id": obj.id, + "sectie": obj.sectie, + "capakey": obj.capakey, + "percid": obj.percid, } @@ -71,10 +61,10 @@ def item_gemeente_adapter(obj, request): :class: `crabpy.gateway.capakey.Gemeente` to json. """ return { - 'id': obj.id, - 'naam': obj.naam, - 'centroid': obj.centroid, - 'bounding_box': obj.bounding_box + "id": obj.id, + "naam": obj.naam, + "centroid": obj.centroid, + "bounding_box": obj.bounding_box, } @@ -84,14 +74,11 @@ def item_afdeling_adapter(obj, request): :class: `crabpy.gateway.capakey.Afdeling` to json. """ return { - 'id': obj.id, - 'naam': obj.naam, - 'gemeente': { - 'id': obj.gemeente.id, - 'naam': obj.gemeente.naam - }, - 'centroid': obj.centroid, - 'bounding_box': obj.bounding_box + "id": obj.id, + "naam": obj.naam, + "gemeente": {"id": obj.gemeente.id, "naam": obj.gemeente.naam}, + "centroid": obj.centroid, + "bounding_box": obj.bounding_box, } @@ -101,17 +88,17 @@ def item_sectie_adapter(obj, request): :class: `crabpy.gateway.capakey.Sectie` to json. """ return { - 'id': obj.id, - 'afdeling': { - 'id': obj.afdeling.id, - 'naam': obj.afdeling.naam, - 'gemeente': { - 'id': obj.afdeling.gemeente.id, - 'naam': obj.afdeling.gemeente.naam + "id": obj.id, + "afdeling": { + "id": obj.afdeling.id, + "naam": obj.afdeling.naam, + "gemeente": { + "id": obj.afdeling.gemeente.id, + "naam": obj.afdeling.gemeente.naam, }, }, - 'centroid': obj.centroid, - 'bounding_box': obj.bounding_box + "centroid": obj.centroid, + "bounding_box": obj.bounding_box, } @@ -121,23 +108,23 @@ def item_perceel_adapter(obj, request): :class: `crabpy.gateway.capakey.Perceel` to json. """ return { - 'id': obj.id, - 'sectie': { - 'id': obj.sectie.id, - 'afdeling': { - 'id': obj.sectie.afdeling.id, - 'naam': obj.sectie.afdeling.naam, - 'gemeente': { - 'id': obj.sectie.afdeling.gemeente.id, - 'naam': obj.sectie.afdeling.gemeente.naam + "id": obj.id, + "sectie": { + "id": obj.sectie.id, + "afdeling": { + "id": obj.sectie.afdeling.id, + "naam": obj.sectie.afdeling.naam, + "gemeente": { + "id": obj.sectie.afdeling.gemeente.id, + "naam": obj.sectie.afdeling.gemeente.naam, }, }, }, - 'capakey': obj.capakey, - 'percid': obj.percid, - 'centroid': obj.centroid, - 'bounding_box': obj.bounding_box, - 'shape': obj.shape + "capakey": obj.capakey, + "percid": obj.percid, + "centroid": obj.centroid, + "bounding_box": obj.bounding_box, + "shape": obj.shape, } diff --git a/crabpy_pyramid/tests/fixtures/adressenregister.py b/crabpy_pyramid/tests/fixtures/adressenregister.py deleted file mode 100644 index 295a1e0..0000000 --- a/crabpy_pyramid/tests/fixtures/adressenregister.py +++ /dev/null @@ -1,332 +0,0 @@ -gemeenten = { - "@context": "https://docs.basisregisters.vlaanderen.be/context" - "/gemeente/2023-02-28/gemeente_lijst.jsonld", - "gemeenten": [ - { - "@type": "Gemeente", - "identificator": { - "id": "https://data.vlaanderen.be/id/gemeente/11001", - "naamruimte": "https://data.vlaanderen.be/id/gemeente", - "objectId": "11001", - "versieId": "2002-08-13T16:33:18+02:00", - }, - "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/11001", - "gemeentenaam": { - "geografischeNaam": {"spelling": "Aartselaar", "taal": "nl"} - }, - "gemeenteStatus": "inGebruik", - } - ], -} - -gemeente = { - "@context": "https://docs.basisregisters.vlaanderen.be/context/gemeente" - "/2023-02-28/gemeente_detail.jsonld", - "@type": "Gemeente", - "identificator": { - "id": "https://data.vlaanderen.be/id/gemeente/11001", - "naamruimte": "https://data.vlaanderen.be/id/gemeente", - "objectId": "11001", - "versieId": "2002-08-13T16:33:18+02:00", - }, - "officieleTalen": ["nl"], - "faciliteitenTalen": [], - "gemeentenamen": [{"spelling": "Aartselaar", "taal": "nl"}], - "gemeenteStatus": "inGebruik", -} - -straten = { - "@context": "https://docs.basisregisters.vlaanderen.be/context/straatnaam" - "/2023-02-28/straatnaam_lijst.jsonld", - "straatnamen": [ - { - "@type": "Straatnaam", - "identificator": { - "id": "https://data.vlaanderen.be/id/straatnaam/1", - "naamruimte": "https://data.vlaanderen.be/id/straatnaam", - "objectId": "1", - "versieId": "2011-04-29T13:34:14+02:00", - }, - "detail": "https://api.basisregisters.vlaanderen.be/v2/straatnamen/1", - "straatnaam": { - "geografischeNaam": {"spelling": "Acacialaan", "taal": "nl"} - }, - "straatnaamStatus": "inGebruik", - }, - { - "@type": "Straatnaam", - "identificator": { - "id": "https://data.vlaanderen.be/id/straatnaam/2", - "naamruimte": "https://data.vlaanderen.be/id/straatnaam", - "objectId": "2", - "versieId": "2011-04-29T13:34:14+02:00", - }, - "detail": "https://api.basisregisters.vlaanderen.be/v2/straatnamen/2", - "straatnaam": { - "geografischeNaam": {"spelling": "Adriaan Sanderslei", "taal": "nl"} - }, - "straatnaamStatus": "inGebruik", - }, - ], -} - -straat = { - "@context": "https://docs.basisregisters.vlaanderen.be/context/straatnaam/2023-02-28" - "/straatnaam_detail.jsonld", - "@type": "Straatnaam", - "identificator": { - "id": "https://data.vlaanderen.be/id/straatnaam/1", - "naamruimte": "https://data.vlaanderen.be/id/straatnaam", - "objectId": "1", - "versieId": "2011-04-29T13:34:14+02:00", - }, - "gemeente": { - "objectId": "11001", - "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/11001", - "gemeentenaam": {"geografischeNaam": {"spelling": "Aartselaar", "taal": "nl"}}, - }, - "straatnamen": [{"spelling": "Acacialaan", "taal": "nl"}], - "homoniemToevoegingen": [], - "straatnaamStatus": "inGebruik", -} - -adressen = { - "@context": "https://docs.basisregisters.vlaanderen.be/context/adres/2023-02-28" - "/adres_lijst.jsonld", - "adressen": [ - { - "@type": "Adres", - "identificator": { - "id": "https://data.vlaanderen.be/id/adres/307106", - "naamruimte": "https://data.vlaanderen.be/id/adres", - "objectId": "307106", - "versieId": "2011-04-29T14:50:10+02:00", - }, - "detail": "https://api.basisregisters.vlaanderen.be/v2/adressen/307106", - "huisnummer": "4", - "volledigAdres": { - "geografischeNaam": { - "spelling": "Acacialaan 4, 2630 Aartselaar", - "taal": "nl", - } - }, - "adresStatus": "inGebruik", - }, - { - "@type": "Adres", - "identificator": { - "id": "https://data.vlaanderen.be/id/adres/364340", - "naamruimte": "https://data.vlaanderen.be/id/adres", - "objectId": "364340", - "versieId": "2011-04-29T14:50:10+02:00", - }, - "detail": "https://api.basisregisters.vlaanderen.be/v2/adressen/364340", - "huisnummer": "11", - "busnummer": "1", - "volledigAdres": { - "geografischeNaam": { - "spelling": "Acacialaan 11, 2630 Aartselaar", - "taal": "nl", - } - }, - "adresStatus": "inGebruik", - }, - ], -} - -adres = { - "@context": "https://docs.basisregisters.vlaanderen.be/context/adres" - "/2023-02-28/adres_detail.jsonld", - "@type": "Adres", - "identificator": { - "id": "https://data.vlaanderen.be/id/adres/900746", - "naamruimte": "https://data.vlaanderen.be/id/adres", - "objectId": "900746", - "versieId": "2016-12-19T15:23:28+01:00" - }, - "gemeente": { - "objectId": "44021", - "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/44021", - "gemeentenaam": { - "geografischeNaam": { - "spelling": "Gent", - "taal": "nl" - } - } - }, - "postinfo": { - "objectId": "9000", - "detail": "https://api.basisregisters.vlaanderen.be/v2/postinfo/9000" - }, - "straatnaam": { - "objectId": "71608", - "detail": "https://api.basisregisters.vlaanderen.be/v2/straatnamen/71608", - "straatnaam": { - "geografischeNaam": { - "spelling": "Sint-Jansvest", - "taal": "nl" - } - } - }, - "huisnummer": "50", - "volledigAdres": { - "geografischeNaam": { - "spelling": "Sint-Jansvest 50, 9000 Gent", - "taal": "nl" - } - }, - "adresPositie": { - "geometrie": { - "type": "Point", - "gml": "105052.34 " - "193542.11" - }, - "positieGeometrieMethode": "aangeduidDoorBeheerder", - "positieSpecificatie": "perceel" - }, - "adresStatus": "inGebruik", - "officieelToegekend": True -} - -percelen = { - "@context": "https://docs.basisregisters.vlaanderen.be/context/perceel" - "/2023-02-28/perceel_lijst.jsonld", - "percelen": [ - { - "@type": "Perceel", - "identificator": { - "id": "https://data.vlaanderen.be/id/perceel/13013C0384-02H003", - "naamruimte": "https://data.vlaanderen.be/id/perceel", - "objectId": "13013C0384-02H003", - "versieId": "2004-02-13T05:34:17+01:00" - }, - "detail": "https://api.basisregisters.vlaanderen.be/v2/percelen/13013C0384-02H003", - "perceelStatus": "gerealiseerd" - } - ] -} - -perceel = { - "@context": "https://docs.basisregisters.vlaanderen.be/context/perceel" - "/2023-02-28/perceel_detail.jsonld", - "@type": "Perceel", - "identificator": { - "id": "https://data.vlaanderen.be/id/perceel/13013C0384-02H003", - "naamruimte": "https://data.vlaanderen.be/id/perceel", - "objectId": "13013C0384-02H003", - "versieId": "2004-02-13T05:34:17+01:00" - }, - "perceelStatus": "gerealiseerd", - "adressen": [ - { - "objectId": "200001", - "detail": "https://api.basisregisters.vlaanderen.be/v2/adressen/200001" - } - ] -} - -postinfos = { - "@context": "https://docs.basisregisters.vlaanderen.be/context" - "/postinfo/2023-02-28/postinfo_lijst.jsonld", - "postInfoObjecten": [ - { - "@type": "PostInfo", - "identificator": { - "id": "https://data.vlaanderen.be/id/postinfo/1000", - "naamruimte": "https://data.vlaanderen.be/id/postinfo", - "objectId": "1000", - "versieId": "2020-02-10T12:44:14+01:00" - }, - "detail": "https://api.basisregisters.vlaanderen.be/v2/postinfo/1000", - "postInfoStatus": "gerealiseerd", - "postnamen": [ - { - "geografischeNaam": { - "spelling": "BRUSSEL", - "taal": "nl" - } - } - ] - }, - { - "@type": "PostInfo", - "identificator": { - "id": "https://data.vlaanderen.be/id/postinfo/1020", - "naamruimte": "https://data.vlaanderen.be/id/postinfo", - "objectId": "1020", - "versieId": "2020-02-10T12:44:14+01:00" - }, - "detail": "https://api.basisregisters.vlaanderen.be/v2/postinfo/1020", - "postInfoStatus": "gerealiseerd", - "postnamen": [ - { - "geografischeNaam": { - "spelling": "Laken", - "taal": "nl" - } - } - ] - } - ] -} - -postinfo_1000 = { - "@context": "https://docs.basisregisters.vlaanderen.be/context" - "/postinfo/2023-02-28/postinfo_detail.jsonld", - "@type": "PostInfo", - "identificator": { - "id": "https://data.vlaanderen.be/id/postinfo/1000", - "naamruimte": "https://data.vlaanderen.be/id/postinfo", - "objectId": "1000", - "versieId": "2020-02-10T12:44:14+01:00" - }, - "gemeente": { - "objectId": "21004", - "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/21004", - "gemeentenaam": { - "geografischeNaam": { - "spelling": "Brussel", - "taal": "nl" - } - } - }, - "postnamen": [ - { - "geografischeNaam": { - "spelling": "BRUSSEL", - "taal": "nl" - } - } - ], - "postInfoStatus": "gerealiseerd" -} -postinfo_1020 = { - "@context": "https://docs.basisregisters.vlaanderen.be/context/postinfo/2023-02-28/postinfo_detail.jsonld", - "@type": "PostInfo", - "identificator": { - "id": "https://data.vlaanderen.be/id/postinfo/1020", - "naamruimte": "https://data.vlaanderen.be/id/postinfo", - "objectId": "1020", - "versieId": "2020-02-10T12:44:14+01:00" - }, - "gemeente": { - "objectId": "21004", - "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/21004", - "gemeentenaam": { - "geografischeNaam": { - "spelling": "Brussel", - "taal": "nl" - } - } - }, - "postnamen": [ - { - "geografischeNaam": { - "spelling": "Laken", - "taal": "nl" - } - } - ], - "postInfoStatus": "gerealiseerd" -} \ No newline at end of file diff --git a/crabpy_pyramid/views/adressenregister.py b/crabpy_pyramid/views/adressenregister.py index ecba591..7d6ce57 100644 --- a/crabpy_pyramid/views/adressenregister.py +++ b/crabpy_pyramid/views/adressenregister.py @@ -1,4 +1,3 @@ -import inspect import logging import re @@ -11,6 +10,7 @@ from crabpy_pyramid.views.utils import extract_valid_params from crabpy_pyramid.views.utils import handle_gateway_response + log = logging.getLogger(__name__) diff --git a/crabpy_pyramid/views/capakey.py b/crabpy_pyramid/views/capakey.py index f92dfd3..669fc17 100644 --- a/crabpy_pyramid/views/capakey.py +++ b/crabpy_pyramid/views/capakey.py @@ -4,28 +4,32 @@ .. versionadded:: 0.1.0 """ -from pyramid.view import view_config -from crabpy_pyramid.utils import range_return, set_http_caching - from crabpy.gateway.exception import GatewayResourceNotFoundException - from pyramid.httpexceptions import HTTPNotFound +from pyramid.view import view_config + +from crabpy_pyramid.utils import range_return +from crabpy_pyramid.utils import set_http_caching -@view_config(route_name='list_gemeenten', renderer='capakey_listjson', accept='application/json') +@view_config( + route_name="list_gemeenten", renderer="capakey_listjson", accept="application/json" +) def list_gemeenten(request): - request = set_http_caching(request, 'capakey', 'permanent') + request = set_http_caching(request, "capakey", "permanent") Gateway = request.capakey_gateway() - sort = request.params.get('sort', 1) + sort = request.params.get("sort", 1) gemeenten = Gateway.list_gemeenten(sort) return range_return(request, gemeenten) -@view_config(route_name='get_gemeente', renderer='capakey_itemjson', accept='application/json') +@view_config( + route_name="get_gemeente", renderer="capakey_itemjson", accept="application/json" +) def get_gemeente_by_niscode(request): - request = set_http_caching(request, 'capakey', 'long') + request = set_http_caching(request, "capakey", "long") Gateway = request.capakey_gateway() - gemeente_id = int(request.matchdict.get('gemeente_id')) + gemeente_id = int(request.matchdict.get("gemeente_id")) try: return Gateway.get_gemeente_by_id(gemeente_id) except GatewayResourceNotFoundException: @@ -33,34 +37,40 @@ def get_gemeente_by_niscode(request): @view_config( - route_name='list_kadastrale_afdelingen_by_gemeente', - renderer='capakey_listjson', accept='application/json' + route_name="list_kadastrale_afdelingen_by_gemeente", + renderer="capakey_listjson", + accept="application/json", ) def list_kadastrale_afdelingen_by_gemeente(request): - request = set_http_caching(request, 'capakey', 'permanent') + request = set_http_caching(request, "capakey", "permanent") Gateway = request.capakey_gateway() - gemeente_id = request.matchdict.get('gemeente_id') - sort = request.params.get('sort', 1) + gemeente_id = request.matchdict.get("gemeente_id") + sort = request.params.get("sort", 1) afdelingen = Gateway.list_kadastrale_afdelingen_by_gemeente(gemeente_id, sort) return range_return(request, afdelingen) -@view_config(route_name='list_kadastrale_afdelingen', renderer='capakey_listjson', accept='application/json') +@view_config( + route_name="list_kadastrale_afdelingen", + renderer="capakey_listjson", + accept="application/json", +) def list_kadastrale_afdelingen(request): - request = set_http_caching(request, 'capakey', 'permanent') + request = set_http_caching(request, "capakey", "permanent") Gateway = request.capakey_gateway() afdelingen = Gateway.list_kadastrale_afdelingen() return range_return(request, afdelingen) @view_config( - route_name='get_kadastrale_afdeling_by_id', - renderer='capakey_itemjson', accept='application/json' + route_name="get_kadastrale_afdeling_by_id", + renderer="capakey_itemjson", + accept="application/json", ) def get_kadastrale_afdeling_by_id(request): - request = set_http_caching(request, 'capakey', 'long') + request = set_http_caching(request, "capakey", "long") Gateway = request.capakey_gateway() - afdeling_id = request.matchdict.get('afdeling_id') + afdeling_id = request.matchdict.get("afdeling_id") try: return Gateway.get_kadastrale_afdeling_by_id(afdeling_id) except GatewayResourceNotFoundException: @@ -68,26 +78,28 @@ def get_kadastrale_afdeling_by_id(request): @view_config( - route_name='list_secties_by_afdeling', - renderer='capakey_listjson', accept='application/json' + route_name="list_secties_by_afdeling", + renderer="capakey_listjson", + accept="application/json", ) def list_secties_by_afdeling(request): - request = set_http_caching(request, 'capakey', 'long') + request = set_http_caching(request, "capakey", "long") Gateway = request.capakey_gateway() - afdeling_id = request.matchdict.get('afdeling_id') + afdeling_id = request.matchdict.get("afdeling_id") secties = Gateway.list_secties_by_afdeling(afdeling_id) return range_return(request, secties) @view_config( - route_name='get_sectie_by_id_and_afdeling', - renderer='capakey_itemjson', accept='application/json' + route_name="get_sectie_by_id_and_afdeling", + renderer="capakey_itemjson", + accept="application/json", ) def get_sectie_by_id_and_afdeling(request): - request = set_http_caching(request, 'capakey', 'long') + request = set_http_caching(request, "capakey", "long") Gateway = request.capakey_gateway() - afdeling_id = request.matchdict.get('afdeling_id') - sectie_id = request.matchdict.get('sectie_id') + afdeling_id = request.matchdict.get("afdeling_id") + sectie_id = request.matchdict.get("sectie_id") try: return Gateway.get_sectie_by_id_and_afdeling(sectie_id, afdeling_id) except GatewayResourceNotFoundException: @@ -95,30 +107,35 @@ def get_sectie_by_id_and_afdeling(request): @view_config( - route_name='list_percelen_by_sectie', - renderer='capakey_listjson', accept='application/json' + route_name="list_percelen_by_sectie", + renderer="capakey_listjson", + accept="application/json", ) def list_percelen_by_sectie(request): - request = set_http_caching(request, 'capakey', 'short') + request = set_http_caching(request, "capakey", "short") Gateway = request.capakey_gateway() - sectie_id = request.matchdict.get('sectie_id') - afdeling_id = request.matchdict.get('afdeling_id') + sectie_id = request.matchdict.get("sectie_id") + afdeling_id = request.matchdict.get("afdeling_id") sectie = Gateway.get_sectie_by_id_and_afdeling(sectie_id, afdeling_id) percelen = Gateway.list_percelen_by_sectie(sectie) return range_return(request, percelen) @view_config( - route_name='get_perceel_by_sectie_and_id', - renderer='capakey_itemjson', accept='application/json' + route_name="get_perceel_by_sectie_and_id", + renderer="capakey_itemjson", + accept="application/json", ) def get_perceel_by_sectie_and_id(request): - request = set_http_caching(request, 'capakey', 'short') + request = set_http_caching(request, "capakey", "short") Gateway = request.capakey_gateway() - perceel_id = str(request.matchdict.get('perceel_id1')) + '/' \ - + str(request.matchdict.get('perceel_id2')) - sectie_id = request.matchdict.get('sectie_id') - afdeling_id = request.matchdict.get('afdeling_id') + perceel_id = ( + str(request.matchdict.get("perceel_id1")) + + "/" + + str(request.matchdict.get("perceel_id2")) + ) + sectie_id = request.matchdict.get("sectie_id") + afdeling_id = request.matchdict.get("afdeling_id") sectie = Gateway.get_sectie_by_id_and_afdeling(sectie_id, afdeling_id) try: return Gateway.get_perceel_by_id_and_sectie(perceel_id, sectie) @@ -127,14 +144,18 @@ def get_perceel_by_sectie_and_id(request): @view_config( - route_name='get_perceel_by_capakey', - renderer='capakey_itemjson', accept='application/json' + route_name="get_perceel_by_capakey", + renderer="capakey_itemjson", + accept="application/json", ) def get_perceel_by_capakey(request): - request = set_http_caching(request, 'capakey', 'short') + request = set_http_caching(request, "capakey", "short") Gateway = request.capakey_gateway() - capakey = str(request.matchdict.get('capakey1')) + '/' \ - + str(request.matchdict.get('capakey2')) + capakey = ( + str(request.matchdict.get("capakey1")) + + "/" + + str(request.matchdict.get("capakey2")) + ) try: return Gateway.get_perceel_by_capakey(capakey) except GatewayResourceNotFoundException: @@ -142,13 +163,14 @@ def get_perceel_by_capakey(request): @view_config( - route_name='get_perceel_by_percid', - renderer='capakey_itemjson', accept='application/json' + route_name="get_perceel_by_percid", + renderer="capakey_itemjson", + accept="application/json", ) def get_perceel_by_percid(request): - request = set_http_caching(request, 'capakey', 'short') + request = set_http_caching(request, "capakey", "short") Gateway = request.capakey_gateway() - percid = request.matchdict.get('percid') + percid = request.matchdict.get("percid") try: return Gateway.get_perceel_by_percid(percid) except GatewayResourceNotFoundException: diff --git a/crabpy_pyramid/views/exceptions.py b/crabpy_pyramid/views/exceptions.py index f275850..05b4f87 100644 --- a/crabpy_pyramid/views/exceptions.py +++ b/crabpy_pyramid/views/exceptions.py @@ -1,15 +1,14 @@ import logging -import sys from crabpy.client import AdressenRegisterClientException from pyramid.view import view_config + LOGGER = logging.getLogger(__name__) + @view_config( - context=AdressenRegisterClientException, - renderer="json", - accept="application/json" + context=AdressenRegisterClientException, renderer="json", accept="application/json" ) def internal_server_error(exception, request): LOGGER.exception(exception) @@ -19,6 +18,5 @@ def internal_server_error(exception, request): return { "message": "Er ging iets fout in de vraag naar adressenregister API.", - "Errors": errors - + "Errors": errors, } diff --git a/nose_cover.cfg b/nose_cover.cfg deleted file mode 100644 index 213a5ab..0000000 --- a/nose_cover.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[nosetests] -match=^test -nocapture=1 -cover-package=crabpy_pyramid -with-coverage=1 -cover-erase=1 diff --git a/nose_development.ini b/nose_development.ini deleted file mode 100644 index 69044b1..0000000 --- a/nose_development.ini +++ /dev/null @@ -1,5 +0,0 @@ -[crab] -run_integration_tests = True - -[capakey] -run_integration_tests = True diff --git a/nose_travis.ini b/nose_travis.ini deleted file mode 100644 index 52ff32c..0000000 --- a/nose_travis.ini +++ /dev/null @@ -1,5 +0,0 @@ -[crab] -run_integration_tests = 1 - -[capakey] -run_integration_tests = 1 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..683f70b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,59 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +version = "2.1.1" +name = "crabpy_pyramid" +readme = "README.md" +authors = [ + { name = "Flanders Heritage Agency", email = "ict@onroerenderfgoed.be" }, +] +license = {file = "LICENSE"} +description = "Bindings for the CRABpy webservices and the Pyramid framework." +requires-python = ">=3.10,<3.13" +keywords = ["web", "pyramid", "wsgi", "CRAB", "CAPAKEY", "AGIV"] +classifiers = [ + 'Development Status :: 5 - Production/Stable', + "Programming Language :: Python", + 'Programming Language :: Python :: 3.10', + "Framework :: Pyramid", + "Topic :: Internet :: WWW/HTTP", + "Intended Audience :: Developers", + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', +] +dependencies = [ + "pyramid>=2.0.0", + "crabpy>=1.3.2", + "pycountry>=23.12.11", +] + +[project.optional-dependencies] +dev = [ + "waitress==3.0.0", + "pytest==8.3.3", + "WebTest==3.0.1", + "responses==0.25.3", + "flake8==7.1.1", + "flake8-bugbear==24.8.19", + "black==24.10.0", + "uv==0.4.20", + "coveralls==4.0.1", + "flake8-import-order==0.18.2" +] + +[project.urls] +Repository = "https://github.com/OnroerendErfgoed/crabpy_pyramid.git" +Issues = "https://github.com/OnroerendErfgoed/crabpy_pyramid/issues" +Changelog = "https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/master/CHANGES.rst" + +[project.entry-points."paste.app_factory"] +main = "crabpy_pyramid:main" + +[tool.hatch.build.targets.wheel] +# In the wheel we want to have crabpy_pyramid in the root as +# python modules. +packages = [ + "/crabpy_pyramid", +] diff --git a/requirements-ci.txt b/requirements-ci.txt new file mode 100644 index 0000000..f88b5d9 --- /dev/null +++ b/requirements-ci.txt @@ -0,0 +1,119 @@ +attrs==24.2.0 + # via flake8-bugbear +beautifulsoup4==4.12.3 + # via webtest +black==24.10.0 + # via crabpy-pyramid (pyproject.toml) +certifi==2024.8.30 + # via requests +charset-normalizer==3.4.0 + # via requests +click==8.1.7 + # via black +coverage==7.6.2 + # via coveralls +coveralls==4.0.1 + # via crabpy-pyramid (pyproject.toml) +crabpy==1.3.2 + # via crabpy-pyramid (pyproject.toml) +decorator==5.1.1 + # via dogpile-cache +docopt==0.6.2 + # via coveralls +dogpile-cache==1.3.3 + # via crabpy +flake8==7.1.1 + # via + # crabpy-pyramid (pyproject.toml) + # flake8-bugbear +flake8-bugbear==24.8.19 + # via crabpy-pyramid (pyproject.toml) +flake8-import-order==0.18.2 + # via crabpy-pyramid (pyproject.toml) +hupper==1.12.1 + # via pyramid +idna==3.10 + # via requests +iniconfig==2.0.0 + # via pytest +mccabe==0.7.0 + # via flake8 +mypy-extensions==1.0.0 + # via black +packaging==24.1 + # via + # black + # pytest +pastedeploy==3.1.0 + # via plaster-pastedeploy +pathspec==0.12.1 + # via black +pbr==6.1.0 + # via stevedore +plaster==1.1.2 + # via + # plaster-pastedeploy + # pyramid +plaster-pastedeploy==1.0.1 + # via pyramid +platformdirs==4.3.6 + # via black +pluggy==1.5.0 + # via pytest +pycodestyle==2.12.1 + # via + # flake8 + # flake8-import-order +pycountry==24.6.1 + # via crabpy-pyramid (pyproject.toml) +pyflakes==3.2.0 + # via flake8 +pyramid==2.0.2 + # via crabpy-pyramid (pyproject.toml) +pytest==8.3.3 + # via crabpy-pyramid (pyproject.toml) +pyyaml==6.0.2 + # via responses +requests==2.32.3 + # via + # coveralls + # crabpy + # responses +responses==0.25.3 + # via crabpy-pyramid (pyproject.toml) +setuptools==75.1.0 + # via + # flake8-import-order + # pyramid + # zope-deprecation + # zope-interface +soupsieve==2.6 + # via beautifulsoup4 +stevedore==5.3.0 + # via dogpile-cache +suds-py3==1.4.5.0 + # via crabpy +translationstring==1.4 + # via pyramid +urllib3==2.2.3 + # via + # requests + # responses +uv==0.4.20 + # via crabpy-pyramid (pyproject.toml) +venusian==3.1.0 + # via pyramid +waitress==3.0.0 + # via + # crabpy-pyramid (pyproject.toml) + # webtest +webob==1.8.8 + # via + # pyramid + # webtest +webtest==3.0.1 + # via crabpy-pyramid (pyproject.toml) +zope-deprecation==5.0 + # via pyramid +zope-interface==7.1.0 + # via pyramid diff --git a/requirements-dev.txt b/requirements-dev.txt index 16a5684..2894ac0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,22 +1,119 @@ ---requirement requirements.txt - -# Development -pyramid-debugtoolbar==4.6.1 -waitress==1.4.2 - -# Testing -nose==1.3.7 -nose-testconfig==0.10 -coverage==5.3 -WebTest==2.0.35 -responses==0.23.1 -requests==2.29.0 -urllib3==1.26.15 - -# Linting -flake8==3.8.3 - -# Documentation -Sphinx==1.8.5 ; python_version < '3.5' -Sphinx==3.2.1 ; python_version >= '3.5' -sphinxcontrib-httpdomain==1.7.0 +attrs==24.2.0 + # via flake8-bugbear +beautifulsoup4==4.12.3 + # via webtest +black==24.10.0 + # via crabpy-pyramid (pyproject.toml) +certifi==2024.8.30 + # via requests +charset-normalizer==3.4.0 + # via requests +click==8.1.7 + # via black +coverage==7.6.2 + # via coveralls +coveralls==4.0.1 + # via crabpy-pyramid (pyproject.toml) +crabpy==1.3.2 + # via crabpy-pyramid (pyproject.toml) +decorator==5.1.1 + # via dogpile-cache +docopt==0.6.2 + # via coveralls +dogpile-cache==1.3.3 + # via crabpy +flake8==7.1.1 + # via + # crabpy-pyramid (pyproject.toml) + # flake8-bugbear +flake8-bugbear==24.8.19 + # via crabpy-pyramid (pyproject.toml) +flake8-import-order==0.18.2 + # via crabpy-pyramid (pyproject.toml) +hupper==1.12.1 + # via pyramid +idna==3.10 + # via requests +iniconfig==2.0.0 + # via pytest +mccabe==0.7.0 + # via flake8 +mypy-extensions==1.0.0 + # via black +packaging==24.1 + # via + # black + # pytest +pastedeploy==3.1.0 + # via plaster-pastedeploy +pathspec==0.12.1 + # via black +pbr==6.1.0 + # via stevedore +plaster==1.1.2 + # via + # plaster-pastedeploy + # pyramid +plaster-pastedeploy==1.0.1 + # via pyramid +platformdirs==4.3.6 + # via black +pluggy==1.5.0 + # via pytest +pycodestyle==2.12.1 + # via + # flake8 + # flake8-import-order +pycountry==23.12.11 + # via crabpy-pyramid (pyproject.toml) +pyflakes==3.2.0 + # via flake8 +pyramid==2.0 + # via crabpy-pyramid (pyproject.toml) +pytest==8.3.3 + # via crabpy-pyramid (pyproject.toml) +pyyaml==6.0.2 + # via responses +requests==2.32.3 + # via + # coveralls + # crabpy + # responses +responses==0.25.3 + # via crabpy-pyramid (pyproject.toml) +setuptools==75.1.0 + # via + # flake8-import-order + # pyramid + # zope-deprecation + # zope-interface +soupsieve==2.6 + # via beautifulsoup4 +stevedore==5.3.0 + # via dogpile-cache +suds-py3==1.4.5.0 + # via crabpy +translationstring==1.4 + # via pyramid +urllib3==2.2.3 + # via + # requests + # responses +uv==0.4.20 + # via crabpy-pyramid (pyproject.toml) +venusian==3.1.0 + # via pyramid +waitress==3.0.0 + # via + # crabpy-pyramid (pyproject.toml) + # webtest +webob==1.8.8 + # via + # pyramid + # webtest +webtest==3.0.1 + # via crabpy-pyramid (pyproject.toml) +zope-deprecation==5.0 + # via pyramid +zope-interface==7.1.0 + # via pyramid diff --git a/requirements.txt b/requirements.txt index 4047196..ce5a925 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,49 @@ -# Tested and approved with these versions -pyramid==2.0.0 +certifi==2024.8.30 + # via requests +charset-normalizer==3.4.0 + # via requests crabpy==1.3.2 -pycountry==23.12.11 ; python_version >= '3.4' + # via crabpy_pyramid (pyproject.toml) +decorator==5.1.1 + # via dogpile-cache +dogpile-cache==1.3.3 + # via crabpy +hupper==1.12.1 + # via pyramid +idna==3.10 + # via requests +pastedeploy==3.1.0 + # via plaster-pastedeploy +pbr==6.1.0 + # via stevedore +plaster==1.1.2 + # via + # plaster-pastedeploy + # pyramid +plaster-pastedeploy==1.0.1 + # via pyramid +pycountry==23.12.11 + # via crabpy_pyramid (pyproject.toml) +pyramid==2.0 + # via crabpy_pyramid (pyproject.toml) +requests==2.32.3 + # via crabpy +stevedore==5.3.0 + # via dogpile-cache +suds-py3==1.4.5.0 + # via crabpy +translationstring==1.4 + # via pyramid +urllib3==2.2.3 + # via requests +venusian==3.1.0 + # via pyramid +webob==1.8.8 + # via pyramid +zope-deprecation==5.0 + # via pyramid +zope-interface==7.1.0 + # via pyramid + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2bf013b..0000000 --- a/setup.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[nosetests] -match=^test -nocapture=1 -cover-package=crabpy_pyramid -with-coverage=1 -cover-erase=1 - -[bdist_wheel] -universal=1 diff --git a/setup.py b/setup.py deleted file mode 100644 index fbfc808..0000000 --- a/setup.py +++ /dev/null @@ -1,52 +0,0 @@ -import os - -from setuptools import setup, find_packages - -here = os.path.abspath(os.path.dirname(__file__)) -README = open(os.path.join(here, 'README.rst')).read() -CHANGES = open(os.path.join(here, 'CHANGES.rst')).read() - -requires = [ - 'pyramid', - 'crabpy>=1.3.2', - 'pycountry>=23.12.11' -] - -tests_requires = [ - 'nose', - 'coverage', - 'webtest' -] - -testing_extras = tests_requires + [] - -setup(name='crabpy_pyramid', - version='2.1.1', - description='Bindings for the CRABpy webservices and the Pyramid framework.', - long_description=README + '\n\n' + CHANGES, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - "Programming Language :: Python", - 'Programming Language :: Python :: 3.8', - "Framework :: Pyramid", - "Topic :: Internet :: WWW/HTTP", - "Intended Audience :: Developers", - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - ], - author='Onroerend Erfgoed', - author_email='ict@onroerenderfgoed.be', - url='http://github.com/OnroerendErfgoed/crabpy_pyramid', - keywords='web wsgi pyramid CRAB CAPAKEY AGIV', - license='MIT', - packages=find_packages(), - include_package_data=True, - zip_safe=False, - test_suite='crabpy_pyramid', - install_requires=requires, - tests_require=tests_requires, - entry_points="""\ - [paste.app_factory] - main = crabpy_pyramid:main - """, - ) diff --git a/crabpy_pyramid/tests/__init__.py b/tests/__init__.py similarity index 100% rename from crabpy_pyramid/tests/__init__.py rename to tests/__init__.py diff --git a/tests/fixtures/adressenregister.py b/tests/fixtures/adressenregister.py new file mode 100644 index 0000000..b5cb3a6 --- /dev/null +++ b/tests/fixtures/adressenregister.py @@ -0,0 +1,287 @@ +gemeenten = { + "@context": "https://docs.basisregisters.vlaanderen.be/context" + "/gemeente/2023-02-28/gemeente_lijst.jsonld", + "gemeenten": [ + { + "@type": "Gemeente", + "identificator": { + "id": "https://data.vlaanderen.be/id/gemeente/11001", + "naamruimte": "https://data.vlaanderen.be/id/gemeente", + "objectId": "11001", + "versieId": "2002-08-13T16:33:18+02:00", + }, + "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/11001", + "gemeentenaam": { + "geografischeNaam": {"spelling": "Aartselaar", "taal": "nl"} + }, + "gemeenteStatus": "inGebruik", + } + ], +} + +gemeente = { + "@context": "https://docs.basisregisters.vlaanderen.be/context/gemeente" + "/2023-02-28/gemeente_detail.jsonld", + "@type": "Gemeente", + "identificator": { + "id": "https://data.vlaanderen.be/id/gemeente/11001", + "naamruimte": "https://data.vlaanderen.be/id/gemeente", + "objectId": "11001", + "versieId": "2002-08-13T16:33:18+02:00", + }, + "officieleTalen": ["nl"], + "faciliteitenTalen": [], + "gemeentenamen": [{"spelling": "Aartselaar", "taal": "nl"}], + "gemeenteStatus": "inGebruik", +} + +straten = { + "@context": "https://docs.basisregisters.vlaanderen.be/context/straatnaam" + "/2023-02-28/straatnaam_lijst.jsonld", + "straatnamen": [ + { + "@type": "Straatnaam", + "identificator": { + "id": "https://data.vlaanderen.be/id/straatnaam/1", + "naamruimte": "https://data.vlaanderen.be/id/straatnaam", + "objectId": "1", + "versieId": "2011-04-29T13:34:14+02:00", + }, + "detail": "https://api.basisregisters.vlaanderen.be/v2/straatnamen/1", + "straatnaam": { + "geografischeNaam": {"spelling": "Acacialaan", "taal": "nl"} + }, + "straatnaamStatus": "inGebruik", + }, + { + "@type": "Straatnaam", + "identificator": { + "id": "https://data.vlaanderen.be/id/straatnaam/2", + "naamruimte": "https://data.vlaanderen.be/id/straatnaam", + "objectId": "2", + "versieId": "2011-04-29T13:34:14+02:00", + }, + "detail": "https://api.basisregisters.vlaanderen.be/v2/straatnamen/2", + "straatnaam": { + "geografischeNaam": {"spelling": "Adriaan Sanderslei", "taal": "nl"} + }, + "straatnaamStatus": "inGebruik", + }, + ], +} + +straat = { + "@context": ( + "https://docs.basisregisters.vlaanderen.be/context/straatnaam/2023-02-28" + "/straatnaam_detail.jsonld" + ), + "@type": "Straatnaam", + "identificator": { + "id": "https://data.vlaanderen.be/id/straatnaam/1", + "naamruimte": "https://data.vlaanderen.be/id/straatnaam", + "objectId": "1", + "versieId": "2011-04-29T13:34:14+02:00", + }, + "gemeente": { + "objectId": "11001", + "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/11001", + "gemeentenaam": {"geografischeNaam": {"spelling": "Aartselaar", "taal": "nl"}}, + }, + "straatnamen": [{"spelling": "Acacialaan", "taal": "nl"}], + "homoniemToevoegingen": [], + "straatnaamStatus": "inGebruik", +} + +adressen = { + "@context": "https://docs.basisregisters.vlaanderen.be/context/adres/2023-02-28" + "/adres_lijst.jsonld", + "adressen": [ + { + "@type": "Adres", + "identificator": { + "id": "https://data.vlaanderen.be/id/adres/307106", + "naamruimte": "https://data.vlaanderen.be/id/adres", + "objectId": "307106", + "versieId": "2011-04-29T14:50:10+02:00", + }, + "detail": "https://api.basisregisters.vlaanderen.be/v2/adressen/307106", + "huisnummer": "4", + "volledigAdres": { + "geografischeNaam": { + "spelling": "Acacialaan 4, 2630 Aartselaar", + "taal": "nl", + } + }, + "adresStatus": "inGebruik", + }, + { + "@type": "Adres", + "identificator": { + "id": "https://data.vlaanderen.be/id/adres/364340", + "naamruimte": "https://data.vlaanderen.be/id/adres", + "objectId": "364340", + "versieId": "2011-04-29T14:50:10+02:00", + }, + "detail": "https://api.basisregisters.vlaanderen.be/v2/adressen/364340", + "huisnummer": "11", + "busnummer": "1", + "volledigAdres": { + "geografischeNaam": { + "spelling": "Acacialaan 11, 2630 Aartselaar", + "taal": "nl", + } + }, + "adresStatus": "inGebruik", + }, + ], +} + +adres = { + "@context": "https://docs.basisregisters.vlaanderen.be/context/adres" + "/2023-02-28/adres_detail.jsonld", + "@type": "Adres", + "identificator": { + "id": "https://data.vlaanderen.be/id/adres/900746", + "naamruimte": "https://data.vlaanderen.be/id/adres", + "objectId": "900746", + "versieId": "2016-12-19T15:23:28+01:00", + }, + "gemeente": { + "objectId": "44021", + "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/44021", + "gemeentenaam": {"geografischeNaam": {"spelling": "Gent", "taal": "nl"}}, + }, + "postinfo": { + "objectId": "9000", + "detail": "https://api.basisregisters.vlaanderen.be/v2/postinfo/9000", + }, + "straatnaam": { + "objectId": "71608", + "detail": "https://api.basisregisters.vlaanderen.be/v2/straatnamen/71608", + "straatnaam": {"geografischeNaam": {"spelling": "Sint-Jansvest", "taal": "nl"}}, + }, + "huisnummer": "50", + "volledigAdres": { + "geografischeNaam": {"spelling": "Sint-Jansvest 50, 9000 Gent", "taal": "nl"} + }, + "adresPositie": { + "geometrie": { + "type": "Point", + "gml": '105052.34 ' + "193542.11", + }, + "positieGeometrieMethode": "aangeduidDoorBeheerder", + "positieSpecificatie": "perceel", + }, + "adresStatus": "inGebruik", + "officieelToegekend": True, +} + +percelen = { + "@context": "https://docs.basisregisters.vlaanderen.be/context/perceel" + "/2023-02-28/perceel_lijst.jsonld", + "percelen": [ + { + "@type": "Perceel", + "identificator": { + "id": "https://data.vlaanderen.be/id/perceel/13013C0384-02H003", + "naamruimte": "https://data.vlaanderen.be/id/perceel", + "objectId": "13013C0384-02H003", + "versieId": "2004-02-13T05:34:17+01:00", + }, + "detail": ( + "https://api.basisregisters.vlaanderen.be/v2/percelen/13013C0384-02H003" + ), + "perceelStatus": "gerealiseerd", + } + ], +} + +perceel = { + "@context": "https://docs.basisregisters.vlaanderen.be/context/perceel" + "/2023-02-28/perceel_detail.jsonld", + "@type": "Perceel", + "identificator": { + "id": "https://data.vlaanderen.be/id/perceel/13013C0384-02H003", + "naamruimte": "https://data.vlaanderen.be/id/perceel", + "objectId": "13013C0384-02H003", + "versieId": "2004-02-13T05:34:17+01:00", + }, + "perceelStatus": "gerealiseerd", + "adressen": [ + { + "objectId": "200001", + "detail": "https://api.basisregisters.vlaanderen.be/v2/adressen/200001", + } + ], +} + +postinfos = { + "@context": "https://docs.basisregisters.vlaanderen.be/context" + "/postinfo/2023-02-28/postinfo_lijst.jsonld", + "postInfoObjecten": [ + { + "@type": "PostInfo", + "identificator": { + "id": "https://data.vlaanderen.be/id/postinfo/1000", + "naamruimte": "https://data.vlaanderen.be/id/postinfo", + "objectId": "1000", + "versieId": "2020-02-10T12:44:14+01:00", + }, + "detail": "https://api.basisregisters.vlaanderen.be/v2/postinfo/1000", + "postInfoStatus": "gerealiseerd", + "postnamen": [{"geografischeNaam": {"spelling": "BRUSSEL", "taal": "nl"}}], + }, + { + "@type": "PostInfo", + "identificator": { + "id": "https://data.vlaanderen.be/id/postinfo/1020", + "naamruimte": "https://data.vlaanderen.be/id/postinfo", + "objectId": "1020", + "versieId": "2020-02-10T12:44:14+01:00", + }, + "detail": "https://api.basisregisters.vlaanderen.be/v2/postinfo/1020", + "postInfoStatus": "gerealiseerd", + "postnamen": [{"geografischeNaam": {"spelling": "Laken", "taal": "nl"}}], + }, + ], +} + +postinfo_1000 = { + "@context": "https://docs.basisregisters.vlaanderen.be/context" + "/postinfo/2023-02-28/postinfo_detail.jsonld", + "@type": "PostInfo", + "identificator": { + "id": "https://data.vlaanderen.be/id/postinfo/1000", + "naamruimte": "https://data.vlaanderen.be/id/postinfo", + "objectId": "1000", + "versieId": "2020-02-10T12:44:14+01:00", + }, + "gemeente": { + "objectId": "21004", + "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/21004", + "gemeentenaam": {"geografischeNaam": {"spelling": "Brussel", "taal": "nl"}}, + }, + "postnamen": [{"geografischeNaam": {"spelling": "BRUSSEL", "taal": "nl"}}], + "postInfoStatus": "gerealiseerd", +} +postinfo_1020 = { + "@context": ( + "https://docs.basisregisters.vlaanderen.be/context/postinfo/2023-02-28/postinfo_detail.jsonld" + ), + "@type": "PostInfo", + "identificator": { + "id": "https://data.vlaanderen.be/id/postinfo/1020", + "naamruimte": "https://data.vlaanderen.be/id/postinfo", + "objectId": "1020", + "versieId": "2020-02-10T12:44:14+01:00", + }, + "gemeente": { + "objectId": "21004", + "detail": "https://api.basisregisters.vlaanderen.be/v2/gemeenten/21004", + "gemeentenaam": {"geografischeNaam": {"spelling": "Brussel", "taal": "nl"}}, + }, + "postnamen": [{"geografischeNaam": {"spelling": "Laken", "taal": "nl"}}], + "postInfoStatus": "gerealiseerd", +} diff --git a/crabpy_pyramid/tests/renderers/__init__.py b/tests/renderers/__init__.py similarity index 100% rename from crabpy_pyramid/tests/renderers/__init__.py rename to tests/renderers/__init__.py diff --git a/crabpy_pyramid/tests/renderers/test_capakey.py b/tests/renderers/test_capakey.py similarity index 100% rename from crabpy_pyramid/tests/renderers/test_capakey.py rename to tests/renderers/test_capakey.py diff --git a/crabpy_pyramid/tests/test_capakey.py b/tests/test_capakey.py similarity index 100% rename from crabpy_pyramid/tests/test_capakey.py rename to tests/test_capakey.py index 7e3bd26..250ff9f 100644 --- a/crabpy_pyramid/tests/test_capakey.py +++ b/tests/test_capakey.py @@ -11,9 +11,9 @@ from pyramid.registry import Registry from crabpy_pyramid import capakey +from crabpy_pyramid.capakey import ICapakey from crabpy_pyramid.capakey import build_capakey from crabpy_pyramid.capakey import get_capakey -from crabpy_pyramid.capakey import ICapakey class TestGetAndBuild(unittest.TestCase): diff --git a/crabpy_pyramid/tests/test_functional.py b/tests/test_functional.py similarity index 98% rename from crabpy_pyramid/tests/test_functional.py rename to tests/test_functional.py index 1b0fec4..d66cd60 100644 --- a/crabpy_pyramid/tests/test_functional.py +++ b/tests/test_functional.py @@ -14,15 +14,15 @@ from webtest import TestApp from crabpy_pyramid import main -from crabpy_pyramid.tests.fixtures.adressenregister import adres -from crabpy_pyramid.tests.fixtures.adressenregister import adressen -from crabpy_pyramid.tests.fixtures.adressenregister import perceel -from crabpy_pyramid.tests.fixtures.adressenregister import percelen -from crabpy_pyramid.tests.fixtures.adressenregister import postinfo_1000 -from crabpy_pyramid.tests.fixtures.adressenregister import postinfo_1020 -from crabpy_pyramid.tests.fixtures.adressenregister import postinfos -from crabpy_pyramid.tests.fixtures.adressenregister import straat -from crabpy_pyramid.tests.fixtures.adressenregister import straten +from tests.fixtures.adressenregister import adres +from tests.fixtures.adressenregister import adressen +from tests.fixtures.adressenregister import perceel +from tests.fixtures.adressenregister import percelen +from tests.fixtures.adressenregister import postinfo_1000 +from tests.fixtures.adressenregister import postinfo_1020 +from tests.fixtures.adressenregister import postinfos +from tests.fixtures.adressenregister import straat +from tests.fixtures.adressenregister import straten def as_bool(value): diff --git a/crabpy_pyramid/tests/test_utils.py b/tests/test_utils.py similarity index 100% rename from crabpy_pyramid/tests/test_utils.py rename to tests/test_utils.py