Skip to content

Commit

Permalink
Rebase on develop
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Jul 28, 2023
1 parent 605308b commit 488f1b7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
7 changes: 3 additions & 4 deletions apptax/taxonomie/routesbiblistes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ def get_biblistesbyTaxref(regne, group2_inpn=None):
def get_cor_nom_liste():
limit = request.args.get("limit", 20, int)
page = request.args.get("page", 1, int)
q = CorNomListe.query.options(joinedload("bib_nom"))
q = CorNomListe.query
total = q.count()
results = q.paginate(page=page, per_page=limit, error_out=False)
items = []
for r in results.items:
cor_nom_list_dict = r.as_dict(relationships=("bib_nom",), exclude=("id_nom",))
bib_nom = cor_nom_list_dict.pop("bib_nom")
items.append(dict(cor_nom_list_dict, cd_nom=bib_nom["cd_nom"]))
cor_nom_list_dict = r.as_dict()
items.append(cor_nom_list_dict)
return {
"items": items,
"total": total,
Expand Down
31 changes: 18 additions & 13 deletions apptax/tests/fixtures.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import pytest

from apptax.database import db
from apptax.taxonomie.models import BibListes, BibThemes, BibAttributs, CorTaxonAttribut
, Taxref
from apptax.taxonomie.models import BibListes, BibThemes, BibAttributs, CorTaxonAttribut, Taxref
from pypnusershub.db.models import User


Expand All @@ -18,17 +17,6 @@
(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 = Taxref.query.get(cd_nom)
db.session.add(nom)
liste.noms.append(nom)


@pytest.fixture
def noms_without_listexample():
with db.session.begin_nested():
Expand Down Expand Up @@ -58,6 +46,23 @@ def attribut_example():
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:
nom = Taxref.query.get(cd_nom)
if attr:
cor_attr = CorTaxonAttribut(
id_attribut=attribut_example.id_attribut, cd_ref=cd_ref, valeur_attribut=attr
)
nom.attributs.append(cor_attr)
db.session.add(nom)
liste.noms.append(nom)



@pytest.fixture(scope="session")
def users(app):
users = {}
Expand Down

0 comments on commit 488f1b7

Please sign in to comment.