From 2a67e9827a42d006abdcb956eaa8ab204443abbb Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 10 Aug 2021 13:44:30 +0200 Subject: [PATCH] pass unit test_abs_counts and test_abs_demijournee --- app/scodoc/gen_tables.py | 6 +++--- app/scodoc/sco_abs_views.py | 22 +++++++++++++++------- app/scodoc/sco_groups_view.py | 15 ++++++++++----- app/views/absences.py | 4 ++-- tests/unit/test_abs_counts.py | 1 - tests/unit/test_abs_demijournee.py | 12 +++++------- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/app/scodoc/gen_tables.py b/app/scodoc/gen_tables.py index 3791c8142..cb66a4ed6 100644 --- a/app/scodoc/gen_tables.py +++ b/app/scodoc/gen_tables.py @@ -594,11 +594,11 @@ class GenTable(object): r = {} for cid in self.columns_ids: v = row.get(cid, None) - if v != None: - v = str(v) + # if v != None: + # v = str(v) r[cid] = v d.append(r) - return json.dumps(d) + return json.dumps(d, cls=scu.ScoDocJSONEncoder) def make_page( self, diff --git a/app/scodoc/sco_abs_views.py b/app/scodoc/sco_abs_views.py index 02b7f86e4..aa36e3fc4 100644 --- a/app/scodoc/sco_abs_views.py +++ b/app/scodoc/sco_abs_views.py @@ -924,18 +924,26 @@ def _TablesAbsEtud( cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) for a in absnonjust + absjust: cursor.execute( - """select eval.* - from notes_evaluation eval, notes_moduleimpl_inscription mi, notes_moduleimpl m - where eval.jour = %(jour)s and eval.moduleimpl_id = m.moduleimpl_id - and mi.moduleimpl_id = m.moduleimpl_id and mi.etudid = %(etudid)s""", + """SELECT eval.* + FROM notes_evaluation eval, notes_moduleimpl_inscription mi, notes_moduleimpl m + WHERE eval.jour = %(jour)s + and eval.moduleimpl_id = m.id + and mi.moduleimpl_id = m.id + and mi.etudid = %(etudid)s + """, {"jour": a["jour"].strftime("%Y-%m-%d"), "etudid": etudid}, ) a["evals"] = cursor.dictfetchall() cursor.execute( """SELECT mi.moduleimpl_id - from absences abs, notes_moduleimpl_inscription mi, notes_moduleimpl m - where abs.matin = %(matin)s and abs.jour = %(jour)s and abs.etudid=%(etudid)s and abs.moduleimpl_id=mi.moduleimpl_id and mi.moduleimpl_id=m.moduleimpl_id - and mi.etudid = %(etudid)s""", + FROM absences abs, notes_moduleimpl_inscription mi, notes_moduleimpl m + WHERE abs.matin = %(matin)s + and abs.jour = %(jour)s + and abs.etudid = %(etudid)s + and abs.moduleimpl_id = mi.moduleimpl_id + and mi.moduleimpl_id = m.id + and mi.etudid = %(etudid)s + """, { "matin": bool(a["matin"]), "jour": a["jour"].strftime("%Y-%m-%d"), diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 708038b4d..c1ff713bc 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -342,7 +342,7 @@ class DisplayedGroupsInfos(object): gq = [] for group_id in group_ids: - gq.append("group_ids=" + group_id) + gq.append("group_ids=" + str(group_id)) self.groups_query_args = "&".join(gq) self.base_url = REQUEST.URL0 + "?" + self.groups_query_args self.group_ids = group_ids @@ -724,10 +724,15 @@ def groups_table( return tab.make_page(context, format=format, REQUEST=REQUEST) elif format == "xlsappel": - xls = sco_excel.excel_feuille_listeappel(groups_infos.formsemestre, groups_infos.groups_titles, - groups_infos.members, partitions=groups_infos.partitions, - with_codes=with_codes, with_paiement=with_paiement, - server_name=REQUEST.BASE0) + xls = sco_excel.excel_feuille_listeappel( + groups_infos.formsemestre, + groups_infos.groups_titles, + groups_infos.members, + partitions=groups_infos.partitions, + with_codes=with_codes, + with_paiement=with_paiement, + server_name=REQUEST.BASE0, + ) filename = "liste_%s" % groups_infos.groups_filename + ".xlsx" return sco_excel.send_excel_file(REQUEST, xls, filename) elif format == "allxls": diff --git a/app/views/absences.py b/app/views/absences.py index f0482e961..3ba0753e3 100644 --- a/app/views/absences.py +++ b/app/views/absences.py @@ -1099,7 +1099,7 @@ def AddBilletAbsence( if begin_date > end_date: raise ValueError("invalid dates") # - justified = int(justified) + justified = bool(justified) # cnx = ndb.GetDBConnexion() billet_id = sco_abs.billet_absence_create( @@ -1109,7 +1109,7 @@ def AddBilletAbsence( "abs_begin": begin, "abs_end": end, "description": description, - "etat": 0, + "etat": False, "justified": justified, }, ) diff --git a/tests/unit/test_abs_counts.py b/tests/unit/test_abs_counts.py index 3a4426757..5089f70c6 100644 --- a/tests/unit/test_abs_counts.py +++ b/tests/unit/test_abs_counts.py @@ -49,7 +49,6 @@ def test_abs_counts(test_client): mi = G.create_moduleimpl( module_id=mod["module_id"], formsemestre_id=sem["formsemestre_id"], - responsable_id="bach", ) # --- Inscription des étudiants diff --git a/tests/unit/test_abs_demijournee.py b/tests/unit/test_abs_demijournee.py index 9fb429e5a..fded74de3 100644 --- a/tests/unit/test_abs_demijournee.py +++ b/tests/unit/test_abs_demijournee.py @@ -51,7 +51,6 @@ def test_abs_demijournee(test_client): mi = G.create_moduleimpl( module_id=mod["module_id"], formsemestre_id=sem["formsemestre_id"], - responsable_id="bach", ) # --- Inscription des étudiants @@ -162,7 +161,6 @@ def test_abs_basic(test_client): mi = G.create_moduleimpl( module_id=mod["module_id"], formsemestre_id=sem["formsemestre_id"], - responsable_id="bach", ) # --- Inscription des étudiants @@ -274,7 +272,7 @@ def test_abs_basic(test_client): assert len(load_liste_abs2) == 1 assert len(load_liste_abs) == 2 - assert load_liste_abs2[0]["ampm"] == "1" + assert load_liste_abs2[0]["ampm"] == 1 assert load_liste_abs2[0]["datedmy"] == "22/01/2021" assert load_liste_abs2[0]["exams"] == mod["code"] # absjust_only -> seulement les abs justifiés @@ -322,10 +320,10 @@ def test_abs_basic(test_client): for un_etud in load_grp1_abs: if un_etud["etudid"] == etudid: - assert un_etud["nbabs"] == "3" - assert un_etud["nbjustifs_noabs"] == "2" - assert un_etud["nbabsjust"] == "2" - assert un_etud["nbabsnonjust"] == "1" + assert un_etud["nbabs"] == 3 + assert un_etud["nbjustifs_noabs"] == 2 + assert un_etud["nbabsjust"] == 2 + assert un_etud["nbabsnonjust"] == 1 assert un_etud["nomprenom"] == etuds[0]["nomprenom"] # --- Création de billets