From 6cc1b60da4120c2764db3fd4743563513948e9c0 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 21 Sep 2021 16:34:58 +0200 Subject: [PATCH] =?UTF-8?q?Adaptation=20des=20tests=20unitaires=20aux=20vu?= =?UTF-8?q?es=20de=20l'API=20(qui=20renvoient=20des=20r=C3=A9ponses=20Flas?= =?UTF-8?q?k).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/test_abs_demijournee.py | 12 ++++++++---- tests/unit/test_formations.py | 18 +++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/unit/test_abs_demijournee.py b/tests/unit/test_abs_demijournee.py index f0b9e716..40a617f9 100644 --- a/tests/unit/test_abs_demijournee.py +++ b/tests/unit/test_abs_demijournee.py @@ -246,8 +246,10 @@ def test_abs_basic(test_client): liste_abs = sco_abs_views.ListeAbsEtud( etudid, format="json", absjust_only=1, sco_year="2020" - ) - liste_abs2 = sco_abs_views.ListeAbsEtud(etudid, format="json", sco_year="2020") + ).get_data(as_text=True) + liste_abs2 = sco_abs_views.ListeAbsEtud( + etudid, format="json", sco_year="2020" + ).get_data(as_text=True) load_liste_abs = json.loads(liste_abs) load_liste_abs2 = json.loads(liste_abs2) @@ -283,7 +285,7 @@ def test_abs_basic(test_client): format="json", ) # grp1_abs est une Response car on a appelé une vue (1er appel) - load_grp1_abs = json.loads(grp1_abs.get_data().decode("utf-8")) + load_grp1_abs = json.loads(grp1_abs.get_data(as_text=True)) assert len(load_grp1_abs) == 10 @@ -327,7 +329,9 @@ def test_abs_basic(test_client): code_ine=etuds[0]["code_ine"], ) - li_bi = absences.listeBilletsEtud(etudid=etudid, format="json") + li_bi = absences.listeBilletsEtud(etudid=etudid, format="json").get_data( + as_text=True + ) assert isinstance(li_bi, str) load_li_bi = json.loads(li_bi) diff --git a/tests/unit/test_formations.py b/tests/unit/test_formations.py index 4f5a7f5c..040f33bc 100644 --- a/tests/unit/test_formations.py +++ b/tests/unit/test_formations.py @@ -172,7 +172,7 @@ def test_formations(test_client): assert load_lif[0]["formation_id"] == f["formation_id"] assert load_lif[0]["titre"] == f["titre"] - lif2 = notes.formation_list(format="json") + lif2 = notes.formation_list(format="json").get_data(as_text=True) # lif2 est un chaine assert isinstance(lif2, str) load_lif2 = json.loads(lif2) @@ -182,7 +182,9 @@ def test_formations(test_client): # --- Export de formation_id - exp = sco_formations.formation_export(formation_id=f["formation_id"], format="json") + exp = sco_formations.formation_export( + formation_id=f["formation_id"], format="json" + ).get_data(as_text=True) assert isinstance(exp, str) load_exp = json.loads(exp) @@ -200,7 +202,7 @@ def test_formations(test_client): li_sem1 = notes.formsemestre_list( formsemestre_id=sem1["formsemestre_id"], format="json" - ) + ).get_data(as_text=True) assert isinstance(li_sem1, str) load_li_sem1 = json.loads(li_sem1) # uniquement le semestre 1 dans la liste @@ -212,7 +214,7 @@ def test_formations(test_client): li_semf = notes.formsemestre_list( formation_id=f["formation_id"], format="json", - ) + ).get_data(as_text=True) assert isinstance(li_semf, str) load_li_semf = json.loads(li_semf) @@ -220,7 +222,7 @@ def test_formations(test_client): assert len(load_li_semf) == 2 assert load_li_semf[1]["semestre_id"] == sem2["semestre_id"] - li_sem = notes.formsemestre_list(format="json") + li_sem = notes.formsemestre_list(format="json").get_data(as_text=True) load_li_sem = json.loads(li_sem) assert len(load_li_sem) == 3 @@ -328,7 +330,7 @@ def test_formations(test_client): ) sco_edit_formation.do_formation_delete(oid=f2["formation_id"]) - lif3 = notes.formation_list(format="json") + lif3 = notes.formation_list(format="json").get_data(as_text=True) assert isinstance(lif3, str) load_lif3 = json.loads(lif3) assert len(load_lif3) == 1 @@ -371,5 +373,7 @@ def test_import_formation(test_client): assert mi["module_id"] == mod["module_id"] # --- Export formation en XML - doc1 = sco_formations.formation_export(formation_id, format="xml") + doc1 = sco_formations.formation_export(formation_id, format="xml").get_data( + as_text=True + ) assert isinstance(doc1, str)