From c8200ef51600625542a1f53607345307ffe36b63 Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Thu, 1 Jun 2023 14:00:09 +0200 Subject: [PATCH 01/12] Back to dev --- VERSION | 2 +- docs/changelog.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index ca717669..28030a66 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.2 +1.11.3.dev diff --git a/docs/changelog.md b/docs/changelog.md index b3b5d548..5998bd58 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,4 +1,8 @@ +1.11.3 (unrelease) +=================== + + 1.11.2 (01-06-2023) =================== From 9f42128ec73100055e7c17255ed756bb8444e7e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Sun, 11 Jun 2023 16:13:21 +0200 Subject: [PATCH 02/12] =?UTF-8?q?collections=20=E2=86=92=20collections.abc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From the doc: « Deprecated since version 3.3, will be removed in version 3.10: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.9. » --- apptax/utils/utilssqlalchemy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apptax/utils/utilssqlalchemy.py b/apptax/utils/utilssqlalchemy.py index 4e015e6c..63ea79d3 100644 --- a/apptax/utils/utilssqlalchemy.py +++ b/apptax/utils/utilssqlalchemy.py @@ -2,7 +2,7 @@ """ Fonctions utilitaires """ -import collections +import collections.abc from flask import jsonify, Response, current_app import json from functools import wraps @@ -125,7 +125,11 @@ def dict_merge(dct, merge_dct): :return: None """ for k, v in merge_dct.items(): - if k in dct and isinstance(dct[k], dict) and isinstance(merge_dct[k], collections.Mapping): + if ( + k in dct + and isinstance(dct[k], dict) + and isinstance(merge_dct[k], collections.abc.Mapping) + ): dict_merge(dct[k], merge_dct[k]) else: dct[k] = merge_dct[k] From dcb7b6346a4ec80389564c6206b9864011da1c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89lie=20Bouttier?= Date: Sun, 11 Jun 2023 16:11:33 +0200 Subject: [PATCH 03/12] add Debian 12 to CI matrix --- .github/workflows/pytest.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 7f560751..9b2e6c67 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - debian-version: [ '10', '11' ] + debian-version: [ '10', '11', '12' ] sqlalchemy-version: [ '1.3', '1.4' ] include: - debian-version: '10' @@ -31,9 +31,15 @@ jobs: python-version: '3.9' postgres-version: '13' postgis-version: '3.2' + - debian-version: '12' + python-version: '3.11' + postgres-version: '15' + postgis-version: '3.3' exclude: - debian-version: '10' sqlalchemy-version: '1.3' + - debian-version: '12' + sqlalchemy-version: '1.3' name: Debian ${{ matrix.debian-version }} - SQLAlchemy ${{ matrix.sqlalchemy-version }} From 5a3f622d36212c887c91f494b0d8cd6e3f9b95f4 Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Wed, 14 Jun 2023 17:39:01 +0200 Subject: [PATCH 04/12] bump dependencies --- dependencies/UsersHub-authentification-module | 2 +- requirements-dev.txt | 125 +++++++++--------- requirements.txt | 115 ++++++++-------- 3 files changed, 126 insertions(+), 116 deletions(-) diff --git a/dependencies/UsersHub-authentification-module b/dependencies/UsersHub-authentification-module index 0d269c83..9293dfbb 160000 --- a/dependencies/UsersHub-authentification-module +++ b/dependencies/UsersHub-authentification-module @@ -1 +1 @@ -Subproject commit 0d269c8323e441b13fe8ffd7ca99ec36178c6415 +Subproject commit 9293dfbbee453d052932a353ea1c31c7709ea463 diff --git a/requirements-dev.txt b/requirements-dev.txt index 5c2a7e1e..febadbb2 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,8 @@ # -# This file is autogenerated by pip-compile with python 3.7 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.7 +# by the following command: # -# pip-compile requirements-dev.in +# pip-compile --resolver=backtracking requirements-dev.in # -e file:dependencies/RefGeo#egg=pypn-ref-geo # via -r requirements-submodules.in @@ -14,32 +14,34 @@ # pypn-ref-geo # pypnusershub # utils-flask-sqlalchemy-geo -alembic==1.8.1 +-e file:dependencies/Utils-Flask-SQLAlchemy-Geo#egg=utils-flask-sqlalchemy-geo + # via + # -r requirements-submodules.in + # pypn-ref-geo +alembic==1.11.1 # via # flask-migrate # pypn-ref-geo # pypnusershub -attrs==22.1.0 - # via - # fiona - # pytest -authlib==1.0.1 +attrs==23.1.0 + # via fiona +authlib==1.2.0 # via pypnusershub -bcrypt==4.0.0 +bcrypt==4.0.1 # via pypnusershub -boto3==1.24.63 +boto3==1.26.153 # via -r requirements-common.in -botocore==1.27.63 +botocore==1.29.153 # via # boto3 # s3transfer -certifi==2022.6.15 +certifi==2023.5.7 # via # fiona # requests cffi==1.15.1 # via cryptography -charset-normalizer==2.1.1 +charset-normalizer==3.1.0 # via requests click==8.1.3 # via @@ -54,59 +56,65 @@ cligj==0.7.2 # via fiona contextlib2==21.6.0 # via schema -cryptography==37.0.4 +cryptography==41.0.1 # via authlib -fiona==1.8.21 +exceptiongroup==1.1.1 + # via pytest +fiona==1.9.4.post1 # via utils-flask-sqlalchemy-geo flake8==5.0.4 # via -r requirements-dev.in -flask==2.2.2 +flask==2.2.5 # via # -r requirements-common.in # flask-cors # flask-marshmallow # flask-migrate # flask-sqlalchemy + # pypn-ref-geo # pypnusershub # pytest-flask # utils-flask-sqlalchemy flask-cors==3.0.10 # via -r requirements-common.in -flask-marshmallow==0.14.0 +flask-marshmallow==0.15.0 # via pypnusershub -flask-migrate==3.1.0 +flask-migrate==4.0.4 # via # -r requirements-common.in # utils-flask-sqlalchemy -flask-sqlalchemy==2.5.1 +flask-sqlalchemy==3.0.3 # via # -r requirements-common.in # flask-migrate # pypn-ref-geo # pypnusershub # utils-flask-sqlalchemy -geoalchemy2==0.11.1 +geoalchemy2==0.13.3 # via utils-flask-sqlalchemy-geo -geog==0.0.2 - # via utils-flask-sqlalchemy-geo -geojson==2.5.0 +geojson==3.0.1 # via utils-flask-sqlalchemy-geo +greenlet==2.0.2 + # via sqlalchemy gunicorn==20.1.0 # via -r requirements-common.in -idna==3.3 +idna==3.4 # via requests importlib-metadata==4.2.0 # via # alembic + # attrs # click + # fiona # flake8 # flask # mako # pluggy # pytest -importlib-resources==5.9.0 + # sqlalchemy +importlib-resources==5.12.0 # via alembic -iniconfig==1.1.1 +iniconfig==2.0.0 # via pytest itsdangerous==2.1.2 # via flask @@ -116,55 +124,51 @@ jmespath==1.0.1 # via # boto3 # botocore -mako==1.2.2 +mako==1.2.4 # via alembic -markupsafe==2.1.1 +markupsafe==2.1.3 # via # jinja2 # mako # werkzeug -marshmallow==3.17.1 +marshmallow==3.19.0 # via # flask-marshmallow + # marshmallow-geojson # marshmallow-sqlalchemy # utils-flask-sqlalchemy -marshmallow-sqlalchemy==0.28.1 +marshmallow-geojson==0.4.0 + # via utils-flask-sqlalchemy-geo +marshmallow-sqlalchemy==0.29.0 # via # -r requirements-common.in # pypnusershub + # utils-flask-sqlalchemy-geo mccabe==0.7.0 # via flake8 -munch==2.5.0 - # via fiona -numpy==1.21.6 - # via - # geog - # utils-flask-sqlalchemy-geo -packaging==21.3 +packaging==23.1 # via + # flask-marshmallow # geoalchemy2 # marshmallow # marshmallow-sqlalchemy # pytest -pillow==9.2.0 +pillow==9.5.0 # via -r requirements-common.in pluggy==1.0.0 # via pytest -psycopg2==2.9.3 +psycopg2==2.9.6 # via # -r requirements-common.in + # pypn-ref-geo # pypnusershub -py==1.11.0 - # via pytest pycodestyle==2.9.1 # via flake8 pycparser==2.21 # via cffi pyflakes==2.5.0 # via flake8 -pyparsing==3.0.9 - # via packaging -pytest==7.1.2 +pytest==7.3.2 # via # -r requirements-dev.in # pytest-flask @@ -174,24 +178,24 @@ python-dateutil==2.8.2 # via # botocore # utils-flask-sqlalchemy -python-dotenv==0.20.0 - # via -r requirements-common.in -requests==2.28.1 +python-dotenv==0.21.1 + # via + # -r requirements-common.in + # pypn-ref-geo +requests==2.31.0 # via pypnusershub -s3transfer==0.6.0 +s3transfer==0.6.1 # via boto3 schema==0.7.5 # via -r requirements-dev.in -shapely==1.8.4 +shapely==1.8.5.post1 # via utils-flask-sqlalchemy-geo six==1.16.0 # via # fiona # flask-cors - # flask-marshmallow - # munch # python-dateutil -sqlalchemy==1.3.24 +sqlalchemy==1.4.48 # via # -r requirements-common.in # alembic @@ -200,23 +204,24 @@ sqlalchemy==1.3.24 # marshmallow-sqlalchemy # pypn-ref-geo # pypnusershub + # utils-flask-sqlalchemy # utils-flask-sqlalchemy-geo tomli==2.0.1 # via pytest -typing-extensions==4.3.0 - # via importlib-metadata -urllib3==1.26.12 +typing-extensions==4.6.3 + # via + # alembic + # importlib-metadata +urllib3==1.26.16 # via # -r requirements-common.in # botocore # requests -utils-flask-sqlalchemy-geo==0.2.4 - # via pypn-ref-geo -werkzeug==2.2.2 +werkzeug==2.2.3 # via # flask # pytest-flask -zipp==3.8.1 +zipp==3.15.0 # via # importlib-metadata # importlib-resources diff --git a/requirements.txt b/requirements.txt index 909bd5ef..87ac57ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,33 +1,33 @@ # -# This file is autogenerated by pip-compile with python 3.7 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.7 +# by the following command: # -# pip-compile requirements.in +# pip-compile --resolver=backtracking requirements.in # -alembic==1.8.1 +alembic==1.11.1 # via # flask-migrate # pypn-ref-geo # pypnusershub -attrs==22.1.0 +attrs==23.1.0 # via fiona -authlib==1.0.1 +authlib==1.2.0 # via pypnusershub -bcrypt==4.0.0 +bcrypt==4.0.1 # via pypnusershub -boto3==1.24.63 +boto3==1.26.153 # via -r requirements-common.in -botocore==1.27.63 +botocore==1.29.153 # via # boto3 # s3transfer -certifi==2022.6.15 +certifi==2023.5.7 # via # fiona # requests cffi==1.15.1 # via cryptography -charset-normalizer==2.1.1 +charset-normalizer==3.1.0 # via requests click==8.1.3 # via @@ -40,51 +40,55 @@ click-plugins==1.1.1 # via fiona cligj==0.7.2 # via fiona -cryptography==37.0.4 +cryptography==41.0.1 # via authlib -fiona==1.8.21 +fiona==1.9.4.post1 # via utils-flask-sqlalchemy-geo -flask==2.2.2 +flask==2.2.5 # via # -r requirements-common.in # flask-cors # flask-marshmallow # flask-migrate # flask-sqlalchemy + # pypn-ref-geo # pypnusershub # utils-flask-sqlalchemy flask-cors==3.0.10 # via -r requirements-common.in -flask-marshmallow==0.14.0 +flask-marshmallow==0.15.0 # via pypnusershub -flask-migrate==3.1.0 +flask-migrate==4.0.4 # via # -r requirements-common.in # utils-flask-sqlalchemy -flask-sqlalchemy==2.5.1 +flask-sqlalchemy==3.0.3 # via # -r requirements-common.in # flask-migrate # pypn-ref-geo # pypnusershub # utils-flask-sqlalchemy -geoalchemy2==0.11.1 - # via utils-flask-sqlalchemy-geo -geog==0.0.2 +geoalchemy2==0.13.3 # via utils-flask-sqlalchemy-geo -geojson==2.5.0 +geojson==3.0.1 # via utils-flask-sqlalchemy-geo +greenlet==2.0.2 + # via sqlalchemy gunicorn==20.1.0 # via -r requirements-common.in -idna==3.3 +idna==3.4 # via requests -importlib-metadata==4.12.0 +importlib-metadata==6.6.0 # via # alembic + # attrs # click + # fiona # flask # mako -importlib-resources==5.9.0 + # sqlalchemy +importlib-resources==5.12.0 # via alembic itsdangerous==2.1.2 # via flask @@ -94,67 +98,65 @@ jmespath==1.0.1 # via # boto3 # botocore -mako==1.2.2 +mako==1.2.4 # via alembic -markupsafe==2.1.1 +markupsafe==2.1.3 # via # jinja2 # mako # werkzeug -marshmallow==3.17.1 +marshmallow==3.19.0 # via # flask-marshmallow + # marshmallow-geojson # marshmallow-sqlalchemy # utils-flask-sqlalchemy -marshmallow-sqlalchemy==0.28.1 +marshmallow-geojson==0.4.0 + # via utils-flask-sqlalchemy-geo +marshmallow-sqlalchemy==0.29.0 # via # -r requirements-common.in # pypnusershub -munch==2.5.0 - # via fiona -numpy==1.21.6 - # via - # geog # utils-flask-sqlalchemy-geo -packaging==21.3 +packaging==23.1 # via + # flask-marshmallow # geoalchemy2 # marshmallow # marshmallow-sqlalchemy -pillow==9.2.0 +pillow==9.5.0 # via -r requirements-common.in -psycopg2==2.9.3 +psycopg2==2.9.6 # via # -r requirements-common.in + # pypn-ref-geo # pypnusershub pycparser==2.21 # via cffi -pyparsing==3.0.9 - # via packaging -pypn-ref-geo==1.2.0 +pypn-ref-geo==1.3.0 # via -r requirements-dependencies.in -pypnusershub==1.6.2 +pypnusershub==1.6.7 # via -r requirements-dependencies.in python-dateutil==2.8.2 # via # botocore # utils-flask-sqlalchemy -python-dotenv==0.20.0 - # via -r requirements-common.in -requests==2.28.1 +python-dotenv==0.21.1 + # via + # -r requirements-common.in + # pypn-ref-geo +requests==2.31.0 # via pypnusershub -s3transfer==0.6.0 +s3transfer==0.6.1 # via boto3 -shapely==1.8.4 +shapely==1.8.5.post1 # via utils-flask-sqlalchemy-geo six==1.16.0 # via # fiona # flask-cors - # flask-marshmallow - # munch # python-dateutil -sqlalchemy==1.3.24 +sqlalchemy==1.4.48 # via # -r requirements-common.in # alembic @@ -163,25 +165,28 @@ sqlalchemy==1.3.24 # marshmallow-sqlalchemy # pypn-ref-geo # pypnusershub + # utils-flask-sqlalchemy # utils-flask-sqlalchemy-geo -typing-extensions==4.3.0 - # via importlib-metadata -urllib3==1.26.12 +typing-extensions==4.6.3 + # via + # alembic + # importlib-metadata +urllib3==1.26.16 # via # -r requirements-common.in # botocore # requests -utils-flask-sqlalchemy==0.3.0 +utils-flask-sqlalchemy==0.3.4 # via # -r requirements-dependencies.in # pypn-ref-geo # pypnusershub # utils-flask-sqlalchemy-geo -utils-flask-sqlalchemy-geo==0.2.4 +utils-flask-sqlalchemy-geo==0.2.8 # via pypn-ref-geo -werkzeug==2.2.2 +werkzeug==2.2.3 # via flask -zipp==3.8.1 +zipp==3.15.0 # via # importlib-metadata # importlib-resources From 8880feafe2b0f96555c019fa4c2a4d3b1661ca89 Mon Sep 17 00:00:00 2001 From: Camille Monchicourt Date: Mon, 19 Jun 2023 11:39:11 +0200 Subject: [PATCH 05/12] Changelog 1.11.3 --- docs/changelog.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 5998bd58..9688d4a2 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,7 +1,11 @@ - -1.11.3 (unrelease) +1.11.3 (unreleased) =================== +**🚀 Nouveautés** + +* Compatibilité Debian 12 (Python 3.11) +* Ajout de Debian 12 dans la CI de tests automatisés +* Mise à jour de nombreuses dépendances Python (Flask, Alembic, SQLAlchemy, Marshmallow, Pytest, Pillow, ...) 1.11.2 (01-06-2023) =================== From 081be05efa199311cc53a16987154f317c9635d1 Mon Sep 17 00:00:00 2001 From: TheoLechemia Date: Wed, 21 Jun 2023 16:43:29 +0200 Subject: [PATCH 06/12] fix getOne_bibtaxonsInfo + test --- apptax/taxonomie/routesbibnoms.py | 8 +++- apptax/tests/fixtures.py | 71 +++++++++++++++++-------------- apptax/tests/test_bib_noms.py | 25 +++++++++++ 3 files changed, 70 insertions(+), 34 deletions(-) create mode 100644 apptax/tests/test_bib_noms.py diff --git a/apptax/taxonomie/routesbibnoms.py b/apptax/taxonomie/routesbibnoms.py index a43a54e4..37dc1c4b 100644 --- a/apptax/taxonomie/routesbibnoms.py +++ b/apptax/taxonomie/routesbibnoms.py @@ -3,6 +3,7 @@ from flask import json, Blueprint, request, current_app from sqlalchemy import func +from werkzeug.exceptions import NotFound from ..utils.utilssqlalchemy import json_resp from ..utils.genericfunctions import calculate_offset_page @@ -106,9 +107,12 @@ def getOne_bibtaxonsInfo(cd_nom): (Possibilité de passer plusiers id_attribut) """ # Récupération du cd_ref à partir du cd_nom - cd_ref = db.session.query(Taxref.cd_ref).filter_by(cd_nom=cd_nom).first() + taxon = Taxref.query.get(cd_nom) + if not taxon: + raise NotFound() + else: + cd_ref = taxon.cd_ref obj = {} - # A out des attributs obj["attributs"] = [] q = db.session.query(CorTaxonAttribut).filter_by(cd_ref=cd_ref) diff --git a/apptax/tests/fixtures.py b/apptax/tests/fixtures.py index b22a988d..6eefe5b9 100644 --- a/apptax/tests/fixtures.py +++ b/apptax/tests/fixtures.py @@ -1,43 +1,22 @@ import pytest from apptax.database import db -from apptax.taxonomie.models import BibListes, BibNoms, BibThemes, BibAttributs +from apptax.taxonomie.models import BibListes, BibNoms, BibThemes, BibAttributs, CorTaxonAttribut + bibnom_exemple = [ - (67111, 67111, "Ablette", None), - (60612, 60612, "Lynx boréal", None), - (351, 351, "Grenouille rousse", None), - (8326, 8326, "Cicindèle hybride", None), - (11165, 11165, "Coccinelle à 7 points", None), - (18437, 18437, "Ecrevisse à pieds blancs", None), - (81065, 81065, "Alchémille rampante", None), - (95186, 95186, "Inule fétide", None), - (713776, 209902, "-", "un synonyme"), + (67111, 67111, "Ablette", None, "migrateur"), + (60612, 60612, "Lynx boréal", None, "sédentaire"), + (351, 351, "Grenouille rousse", None, "migrateur partiel"), + (8326, 8326, "Cicindèle hybride", None, None), + (11165, 11165, "Coccinelle à 7 points", None, None), + (18437, 18437, "Ecrevisse à pieds blancs", None, None), + (81065, 81065, "Alchémille rampante", None, None), + (95186, 95186, "Inule fétide", None, None), + (713776, 209902, "-", "un synonyme", None), ] -@pytest.fixture -def noms_example(): - liste = BibListes.query.filter_by(code_liste="100").one() - with db.session.begin_nested(): - for cd_nom, cd_ref, nom_francais, comments in bibnom_exemple: - nom = BibNoms( - cd_nom=cd_nom, cd_ref=cd_ref, nom_francais=nom_francais, comments=comments - ) - db.session.add(nom) - liste.noms.append(nom) - - -@pytest.fixture -def noms_without_listexample(): - with db.session.begin_nested(): - for cd_nom, cd_ref, nom_francais, comments in bibnom_exemple: - nom = BibNoms( - cd_nom=cd_nom, cd_ref=cd_ref, nom_francais=nom_francais, comments=comments - ) - db.session.add(nom) - - @pytest.fixture def attribut_example(): theme = BibThemes.query.filter_by(nom_theme="Mon territoire").one() @@ -57,3 +36,31 @@ def attribut_example(): ) db.session.add(attribut) return attribut + + +@pytest.fixture +def noms_example(attribut_example): + liste = BibListes.query.filter_by(code_liste="100").one() + + with db.session.begin_nested(): + for cd_nom, cd_ref, nom_francais, comments, attr in bibnom_exemple: + cor_attr = CorTaxonAttribut( + id_attribut=attribut_example.id_attribut, cd_ref=cd_ref, valeur_attribut=attr + ) + nom = BibNoms( + cd_nom=cd_nom, cd_ref=cd_ref, nom_francais=nom_francais, comments=comments + ) + if attr: + nom.attributs.append(cor_attr) + db.session.add(nom) + liste.noms.append(nom) + + +@pytest.fixture +def noms_without_listexample(): + with db.session.begin_nested(): + for cd_nom, cd_ref, nom_francais, comments, attr in bibnom_exemple: + nom = BibNoms( + cd_nom=cd_nom, cd_ref=cd_ref, nom_francais=nom_francais, comments=comments + ) + db.session.add(nom) diff --git a/apptax/tests/test_bib_noms.py b/apptax/tests/test_bib_noms.py new file mode 100644 index 00000000..e1260eb5 --- /dev/null +++ b/apptax/tests/test_bib_noms.py @@ -0,0 +1,25 @@ +import pytest +from flask import url_for + +from .fixtures import noms_example, attribut_example + + +@pytest.mark.usefixtures("client_class", "temporary_transaction") +class TestAPIBibNoms: + def test_getOne_bibtaxonsInfo(self, noms_example, attribut_example): + resp = self.client.get( + url_for( + "bib_noms.getOne_bibtaxonsInfo", + cd_nom=67111, + id_attribut=attribut_example.id_attribut, + ) + ) + assert resp.status_code == 200 + data = resp.json + assert "attributs" in data + attr = next( + attr + for attr in data["attributs"] + if attr["id_attribut"] == attribut_example.id_attribut + ) + assert attr["valeur_attribut"] == "migrateur" From f12b2ab5d1b88047f5cad939e833e9828020cd5f Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Fri, 23 Jun 2023 15:47:36 +0200 Subject: [PATCH 07/12] Import fixtures --- apptax/tests/test_media.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apptax/tests/test_media.py b/apptax/tests/test_media.py index d0a4478f..29ec1913 100644 --- a/apptax/tests/test_media.py +++ b/apptax/tests/test_media.py @@ -16,7 +16,7 @@ ) from pypnusershub.tests.utils import set_logged_user_cookie -from .fixtures import noms_example +from .fixtures import noms_example, attribut_example @pytest.fixture From d0abdc21964534ec8c20714bb7d4640d15d10df2 Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Fri, 23 Jun 2023 15:49:34 +0200 Subject: [PATCH 08/12] Correction sql - cf #397 --- .../data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apptax/taxonomie/commands/migrate_taxref/data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql b/apptax/taxonomie/commands/migrate_taxref/data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql index a8e42884..7af7fba6 100755 --- a/apptax/taxonomie/commands/migrate_taxref/data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql +++ b/apptax/taxonomie/commands/migrate_taxref/data/specific_taxref_v15_v16/3.2_alter_taxref_data.sql @@ -59,7 +59,7 @@ DO $$ BEGIN DELETE FROM taxonomie.taxref WHERE cd_nom IN ( - SELECT cd_nom + SELECT cd_nom FROM taxonomie.cdnom_disparu ); @@ -170,7 +170,7 @@ WHERE n.cd_nom IS NULL; ------------- Cas avec cd_nom de remplacement -- Ajout du cd_nom de remplacement quand il n'existait pas dans bib_noms UPDATE taxonomie.bib_noms b -SET cd_nom = cd_nom_remplacement +SET cd_nom = a.cd_nom_remplacement FROM ( SELECT n.cd_nom, From ac8173f3c0458b1a9c39a2bfaefedd1b40894052 Mon Sep 17 00:00:00 2001 From: amandine-sahl Date: Fri, 23 Jun 2023 18:06:00 +0200 Subject: [PATCH 09/12] =?UTF-8?q?Prise=20en=20compte=20des=20d=C3=A9partem?= =?UTF-8?q?ents/territoires=20l'outre=20mer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apptax/taxonomie/commands/utils.py | 129 ++++++++++++++++++----------- 1 file changed, 82 insertions(+), 47 deletions(-) diff --git a/apptax/taxonomie/commands/utils.py b/apptax/taxonomie/commands/utils.py index 791a6e27..889022e5 100644 --- a/apptax/taxonomie/commands/utils.py +++ b/apptax/taxonomie/commands/utils.py @@ -80,61 +80,85 @@ def populate_bdc_statut_cor_text_area(logger): # Populate table db.session.execute( """ + -- Champ terxfr = true = territoire intra-métropole. False = les DOM-TOM WITH regions AS ( SELECT jsonb_array_elements('[ - { "type": "old_r", "code" : "11", "name" :"Île-de-France", "deps": ["75","77","78","91","92","93","94","95"] }, - { "type": "old_r", "code" : "21", "name" :"Champagne-Ardenne", "deps": ["08","10","51","52"] }, - { "type": "old_r", "code" : "22", "name" :"Picardie", "deps": ["02","60","80"] }, - { "type": "old_r", "code" : "23", "name" :"Haute-Normandie", "deps": ["27", "76"] }, - { "type": "old_r", "code" : "24", "name" :"Centre", "deps": ["18","28","36","37","41","45"] }, - { "type": "old_r", "code" : "25", "name" :"Basse-Normandie", "deps": ["14","50","61"] }, - { "type": "old_r", "code" : "26", "name" :"Bourgogne", "deps": ["21","58","71","89"] }, - { "type": "old_r", "code" : "31", "name" :"Nord-Pas-de-Calais", "deps": ["59", "62"] }, - { "type": "old_r", "code" : "41", "name" :"Lorraine", "deps": ["54","55","57","88"] }, - { "type": "old_r", "code" : "42", "name" :"Alsace", "deps": ["67", "68"] }, - { "type": "old_r", "code" : "43", "name" :"Franche-Comté", "deps": ["25","39","70","90"] }, - { "type": "old_r", "code" : "52", "name" :"Pays de la Loire", "deps": ["44","49","53","72","85"] }, - { "type": "old_r", "code" : "53", "name" :"Bretagne", "deps": ["22","29","35","56"] }, - { "type": "old_r", "code" : "54", "name" :"Poitou-Charentes", "deps": ["16","17","79","86"] }, - { "type": "old_r", "code" : "72", "name" :"Aquitaine", "deps": ["24","33","40","47","64"] }, - { "type": "old_r", "code" : "73", "name" :"Midi-Pyrénées", "deps": ["09","12","31","32","46","65","81","82"] }, - { "type": "old_r", "code" : "74", "name" :"Limousin", "deps": ["19","23","87"] }, - { "type": "old_r", "code" : "82", "name" :"Rhône-Alpes", "deps": ["01","07","26","38","42","69","73","74"] }, - { "type": "old_r", "code" : "83", "name" :"Auvergne", "deps": ["03", "15", "43", "63"] }, - { "type": "old_r", "code" : "91", "name" :"Languedoc-Roussillon", "deps": ["11","30","34","48","66"] }, - { "type": "old_r", "code" : "93", "name" :"Provence-Alpes-Côte d’Azur", "deps": ["04", "05", "06", "13", "83", "84"] }, - { "type": "old_r", "code" : "94", "name" :"Corse", "deps": ["2A", "2B"] }, - { "type": "new_r", "code" : "11", "name" :"Île-de-France", "deps": ["75","77","78","91","92","93","94","95"] }, - { "type": "new_r", "code" : "24", "name" :"Centre-Val de Loire", "deps": ["18","28","36","37","41","45"] }, - { "type": "new_r", "code" : "27", "name" :"Bourgogne-Franche-Comté", "deps": ["21","25","39","58","70","71","89","90"] }, - { "type": "new_r", "code" : "28", "name" :"Normandie", "deps": ["14","27","50","61","76"] }, - { "type": "new_r", "code" : "32", "name" :"Hauts-de-France", "deps": ["02", "59", "60", "62", "80"] }, - { "type": "new_r", "code" : "44", "name" :"Grand Est", "deps": ["08","10","51","52","54","55","57","67","68","88"] }, - { "type": "new_r", "code" : "52", "name" :"Pays de la Loire", "deps": ["44","49","53","72","85"] }, - { "type": "new_r", "code" : "53", "name" :"Bretagne", "deps": ["22","29","35","56"] }, - { "type": "new_r", "code" : "75", "name" :"Nouvelle-Aquitaine", "deps": ["16","17","19","23","24","33","40","47","64","79","86","87"] }, - { "type": "new_r", "code" : "76", "name" :"Occitanie", "deps": ["09", "11", "12", "30", "31", "32", "34", "46", "48", "65", "66", "81", "82"] }, - { "type": "new_r", "code" : "84", "name" :"Auvergne-Rhône-Alpes", "deps": ["01", "03", "07", "15", "26", "38", "42", "43", "63", "69", "73", "74"] }, - { "type": "new_r", "code" : "93", "name" :"Provence-Alpes-Côte d’Azur", "deps": ["04", "05", "06", "13", "83", "84"] }, - { "type": "new_r", "code" : "94", "name" :"Corse", "deps": ["2A", "2B"] } + { "type": "old_r", "TERXFR": true, "code" : "11", "name" :"Île-de-France", "deps": ["75","77","78","91","92","93","94","95"] }, + { "type": "old_r", "TERXFR": true, "code" : "21", "name" :"Champagne-Ardenne", "deps": ["08","10","51","52"] }, + { "type": "old_r", "TERXFR": true, "code" : "22", "name" :"Picardie", "deps": ["02","60","80"] }, + { "type": "old_r", "TERXFR": true, "code" : "23", "name" :"Haute-Normandie", "deps": ["27", "76"] }, + { "type": "old_r", "TERXFR": true, "code" : "24", "name" :"Centre", "deps": ["18","28","36","37","41","45"] }, + { "type": "old_r", "TERXFR": true, "code" : "25", "name" :"Basse-Normandie", "deps": ["14","50","61"] }, + { "type": "old_r", "TERXFR": true, "code" : "26", "name" :"Bourgogne", "deps": ["21","58","71","89"] }, + { "type": "old_r", "TERXFR": true, "code" : "31", "name" :"Nord-Pas-de-Calais", "deps": ["59", "62"] }, + { "type": "old_r", "TERXFR": true, "code" : "41", "name" :"Lorraine", "deps": ["54","55","57","88"] }, + { "type": "old_r", "TERXFR": true, "code" : "42", "name" :"Alsace", "deps": ["67", "68"] }, + { "type": "old_r", "TERXFR": true, "code" : "43", "name" :"Franche-Comté", "deps": ["25","39","70","90"] }, + { "type": "old_r", "TERXFR": true, "code" : "52", "name" :"Pays de la Loire", "deps": ["44","49","53","72","85"] }, + { "type": "old_r", "TERXFR": true, "code" : "53", "name" :"Bretagne", "deps": ["22","29","35","56"] }, + { "type": "old_r", "TERXFR": true, "code" : "54", "name" :"Poitou-Charentes", "deps": ["16","17","79","86"] }, + { "type": "old_r", "TERXFR": true, "code" : "72", "name" :"Aquitaine", "deps": ["24","33","40","47","64"] }, + { "type": "old_r", "TERXFR": true, "code" : "73", "name" :"Midi-Pyrénées", "deps": ["09","12","31","32","46","65","81","82"] }, + { "type": "old_r", "TERXFR": true, "code" : "74", "name" :"Limousin", "deps": ["19","23","87"] }, + { "type": "old_r", "TERXFR": true, "code" : "82", "name" :"Rhône-Alpes", "deps": ["01","07","26","38","42","69","73","74"] }, + { "type": "old_r", "TERXFR": true, "code" : "83", "name" :"Auvergne", "deps": ["03", "15", "43", "63"] }, + { "type": "old_r", "TERXFR": true, "code" : "91", "name" :"Languedoc-Roussillon", "deps": ["11","30","34","48","66"] }, + { "type": "old_r", "TERXFR": true, "code" : "93", "name" :"Provence-Alpes-Côte d’Azur", "deps": ["04", "05", "06", "13", "83", "84"] }, + { "type": "old_r", "TERXFR": true, "code" : "94", "name" :"Corse", "deps": ["2A", "2B"] }, + { "type": "new_r", "TERXFR": true, "code" : "11", "name" :"Île-de-France", "deps": ["75","77","78","91","92","93","94","95"] }, + { "type": "new_r", "TERXFR": true, "code" : "24", "name" :"Centre-Val de Loire", "deps": ["18","28","36","37","41","45"] }, + { "type": "new_r", "TERXFR": true, "code" : "27", "name" :"Bourgogne-Franche-Comté", "deps": ["21","25","39","58","70","71","89","90"] }, + { "type": "new_r", "TERXFR": true, "code" : "28", "name" :"Normandie", "deps": ["14","27","50","61","76"] }, + { "type": "new_r", "TERXFR": true, "code" : "32", "name" :"Hauts-de-France", "deps": ["02", "59", "60", "62", "80"] }, + { "type": "new_r", "TERXFR": true, "code" : "44", "name" :"Grand Est", "deps": ["08","10","51","52","54","55","57","67","68","88"] }, + { "type": "new_r", "TERXFR": true, "code" : "52", "name" :"Pays de la Loire", "deps": ["44","49","53","72","85"] }, + { "type": "new_r", "TERXFR": true, "code" : "53", "name" :"Bretagne", "deps": ["22","29","35","56"] }, + { "type": "new_r", "TERXFR": true, "code" : "75", "name" :"Nouvelle-Aquitaine", "deps": ["16","17","19","23","24","33","40","47","64","79","86","87"] }, + { "type": "new_r", "TERXFR": true, "code" : "76", "name" :"Occitanie", "deps": ["09", "11", "12", "30", "31", "32", "34", "46", "48", "65", "66", "81", "82"] }, + { "type": "new_r", "TERXFR": true, "code" : "84", "name" :"Auvergne-Rhône-Alpes", "deps": ["01", "03", "07", "15", "26", "38", "42", "43", "63", "69", "73", "74"] }, + { "type": "new_r", "TERXFR": true, "code" : "93", "name" :"Provence-Alpes-Côte d’Azur", "deps": ["04", "05", "06", "13", "83", "84"] }, + { "type": "new_r", "TERXFR": true, "code" : "94", "name" :"Corse", "deps": ["2A", "2B"] }, + { "type": "new_r", "TERXFR": false, "code" : "971", "name" :"Guadeloupe", "deps": ["971"] }, + { "type": "new_r", "TERXFR": false, "code" : "972", "name" :"Martinique", "deps": ["972"] }, + { "type": "new_r", "TERXFR": false, "code" : "973", "name" :"Guyane", "deps": ["973"] }, + { "type": "new_r", "TERXFR": false, "code" : "974", "name" :"La Réunion", "deps": ["974"] }, + { "type": "new_r", "TERXFR": false, "code" : "975", "name" :"Saint-Pierre-et-Miquelon", "deps": ["975"] }, + { "type": "new_r", "TERXFR": false, "code" : "976", "name" :"Mayotte", "deps": ["976"] }, + { "type": "new_r", "TERXFR": false, "code" : "977", "name" :"Saint-Barthélemy", "deps": ["977"] }, + { "type": "new_r", "TERXFR": false, "code" : "978", "name" :"Saint-Martin", "deps": ["978"] }, + { "type": "new_r", "TERXFR": false, "code" : "984A", "name" :"TAAF", "deps": ["984"] }, + { "type": "new_r", "TERXFR": false, "code" : "984B", "name" :"TAAF", "deps": ["984"] }, + { "type": "new_r", "TERXFR": false, "code" : "984C", "name" :"TAAF", "deps": ["984"] }, + { "type": "new_r", "TERXFR": false, "code" : "986", "name" :"Wallis-et-Futuna", "deps": ["986"] }, + { "type": "new_r", "TERXFR": false, "code" : "987", "name" :"Polynésie française", "deps": ["987"] }, + { "type": "new_r", "TERXFR": false, "code" : "988", "name" :"Nouvelle-Calédonie", "deps": ["9881", "9882"] }, + { "type": "new_r", "TERXFR": false, "code" : "989", "name" :"Île de Clipperton", "deps": ["989"] } ]'::jsonb)AS d - ), regions_dep AS ( - SELECT jsonb_array_elements_text(d->'deps') AS dep, d->>'code' AS code, d->>'type' AS type + ), + regions_dep AS ( + SELECT jsonb_array_elements_text(d->'deps') AS dep, d->>'code' AS code, d->>'type' AS type, (d->>'TERXFR')::boolean as terxfr FROM regions - ), regions_dep_areas AS ( - SELECT la.id_area, d.code, d.type + ) , regions_dep_areas AS ( + SELECT la.id_area, d.code, d.TYPE, d.terxfr FROM ref_geo.l_areas la JOIN regions_dep d ON d.dep = la.area_code WHERE id_type = ref_geo.get_id_area_type('DEP') - ), + ) , texts AS ( - SELECT -- Si 'TERFXFR', 'ETATFRA' insertion de tous les départements - bst.id_text, - la.id_area - FROM taxonomie.bdc_statut_text AS bst, - ref_geo.l_areas AS la - WHERE la.id_type = ref_geo.get_id_area_type('DEP') - AND bst.cd_sig IN ('TERFXFR', 'ETATFRA') + SELECT -- Si 'ETATFRA' insertion de tous les départements + bst.id_text, + la.id_area + FROM taxonomie.bdc_statut_text AS bst + JOIN regions_dep_areas AS la + ON bst.cd_sig = 'ETATFRA' + UNION + SELECT -- Si 'TERFXFR' insertion de tous les départements métropolitains + bst.id_text, + la.id_area + FROM taxonomie.bdc_statut_text AS bst + JOIN regions_dep_areas AS la + ON la.terxfr = true AND bst.cd_sig = 'TERFXFR' + AND length(la.code) = 2 UNION SELECT DISTINCT -- Si département bst.id_text, @@ -160,6 +184,17 @@ def populate_bdc_statut_cor_text_area(logger): FROM taxonomie.bdc_statut_text AS bst JOIN regions_dep_areas AS ors ON (REPLACE(cd_sig, 'INSEER', '') = ors.code) AND ors.TYPE = 'old_r' WHERE cd_sig ILIKE 'INSEER%' + UNION + SELECT DISTINCT -- Si territoire outre mer + bst.id_text, + ors.id_area + FROM taxonomie.bdc_statut_text AS bst + JOIN regions_dep_areas AS ors + ON ors.terxfr = false + AND ( + REPLACE(cd_sig, 'TER', '') = ors.code OR REPLACE(cd_sig, 'INSEET', '') = ors.code + ) + WHERE cd_sig ILIKE 'INSEET%' OR cd_sig ILIKE 'TER%' ) INSERT INTO taxonomie.bdc_statut_cor_text_area (id_text, id_area) SELECT id_text, id_area From 4767a68db69095ea662f7663eb39b8c9cc4bd04e Mon Sep 17 00:00:00 2001 From: Camille Monchicourt Date: Sat, 24 Jun 2023 12:33:32 +0200 Subject: [PATCH 10/12] =?UTF-8?q?Compl=C3=A9ment=20changelog=201.11.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/changelog.md b/docs/changelog.md index 9688d4a2..de497e8f 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,10 +3,28 @@ **🚀 Nouveautés** +* Ajout de la table `t_meta_taxref` stockant la version de Taxref et sa date de dernière mise à jour, accessible sur la route `/version` (#394) * Compatibilité Debian 12 (Python 3.11) * Ajout de Debian 12 dans la CI de tests automatisés * Mise à jour de nombreuses dépendances Python (Flask, Alembic, SQLAlchemy, Marshmallow, Pytest, Pillow, ...) +**🐛 Corrections** + +* Correction de la route `/taxoninfo` et ajout de tests associés (#402) +* Prise en compte des départements et territoires d'outre-mer pour la relation entre les zonages administratifs et la BDC statuts (#401) +* Correction d'une requête SQL (#397) + +**⚠️ Notes de version** + +* Suite à l'ajout de la table `taxonomie.t_meta_taxref`, celle-ci est censée être remplie automatiquement lors de sa création, mais il est conseillé de vérifier son contenu et le corriger ou compléter si nécessaire +* Suite à la prise en compte des territoires d'outre-mer avec la BDC statuts, il est conseillé de relancer le peuplement des données de la table `bdc_statut_cor_text_area` en utilisant la commande suivante : + +```sh +cd ~/taxhub +source venv/bin/activate +flask taxref link-bdc-statut-to-areas +``` + 1.11.2 (01-06-2023) =================== From 4ba4ca0576d57033a24212f089ec42674c0b9364 Mon Sep 17 00:00:00 2001 From: Camille Monchicourt Date: Tue, 27 Jun 2023 00:13:17 +0200 Subject: [PATCH 11/12] Changelog 1.11.3 --- docs/changelog.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index de497e8f..46b5d97e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,9 +1,8 @@ -1.11.3 (unreleased) +1.11.3 (2023-06-27) =================== **🚀 Nouveautés** -* Ajout de la table `t_meta_taxref` stockant la version de Taxref et sa date de dernière mise à jour, accessible sur la route `/version` (#394) * Compatibilité Debian 12 (Python 3.11) * Ajout de Debian 12 dans la CI de tests automatisés * Mise à jour de nombreuses dépendances Python (Flask, Alembic, SQLAlchemy, Marshmallow, Pytest, Pillow, ...) @@ -16,14 +15,12 @@ **⚠️ Notes de version** -* Suite à l'ajout de la table `taxonomie.t_meta_taxref`, celle-ci est censée être remplie automatiquement lors de sa création, mais il est conseillé de vérifier son contenu et le corriger ou compléter si nécessaire * Suite à la prise en compte des territoires d'outre-mer avec la BDC statuts, il est conseillé de relancer le peuplement des données de la table `bdc_statut_cor_text_area` en utilisant la commande suivante : - -```sh -cd ~/taxhub -source venv/bin/activate -flask taxref link-bdc-statut-to-areas -``` + ```sh + cd ~/taxhub + source venv/bin/activate + flask taxref link-bdc-statut-to-areas + ``` 1.11.2 (01-06-2023) =================== From fef8e3e73b6792a5360b897ca2053ed9d7dc08cf Mon Sep 17 00:00:00 2001 From: Camille Monchicourt Date: Tue, 27 Jun 2023 00:14:00 +0200 Subject: [PATCH 12/12] Bump VERSION - 1.11.3 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 28030a66..0a5af26d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.11.3.dev +1.11.3