pass unit test_abs_counts and test_abs_demijournee

This commit is contained in:
Emmanuel Viennet 2021-08-10 13:44:30 +02:00
parent 5d13195070
commit 2a67e9827a
6 changed files with 35 additions and 25 deletions

View File

@ -594,11 +594,11 @@ class GenTable(object):
r = {} r = {}
for cid in self.columns_ids: for cid in self.columns_ids:
v = row.get(cid, None) v = row.get(cid, None)
if v != None: # if v != None:
v = str(v) # v = str(v)
r[cid] = v r[cid] = v
d.append(r) d.append(r)
return json.dumps(d) return json.dumps(d, cls=scu.ScoDocJSONEncoder)
def make_page( def make_page(
self, self,

View File

@ -924,18 +924,26 @@ def _TablesAbsEtud(
cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor) cursor = cnx.cursor(cursor_factory=ndb.ScoDocCursor)
for a in absnonjust + absjust: for a in absnonjust + absjust:
cursor.execute( cursor.execute(
"""select eval.* """SELECT eval.*
from notes_evaluation eval, notes_moduleimpl_inscription mi, notes_moduleimpl m FROM notes_evaluation eval, notes_moduleimpl_inscription mi, notes_moduleimpl m
where eval.jour = %(jour)s and eval.moduleimpl_id = m.moduleimpl_id WHERE eval.jour = %(jour)s
and mi.moduleimpl_id = m.moduleimpl_id and mi.etudid = %(etudid)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}, {"jour": a["jour"].strftime("%Y-%m-%d"), "etudid": etudid},
) )
a["evals"] = cursor.dictfetchall() a["evals"] = cursor.dictfetchall()
cursor.execute( cursor.execute(
"""SELECT mi.moduleimpl_id """SELECT mi.moduleimpl_id
from absences abs, notes_moduleimpl_inscription mi, notes_moduleimpl m 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 WHERE abs.matin = %(matin)s
and mi.etudid = %(etudid)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"]), "matin": bool(a["matin"]),
"jour": a["jour"].strftime("%Y-%m-%d"), "jour": a["jour"].strftime("%Y-%m-%d"),

View File

@ -342,7 +342,7 @@ class DisplayedGroupsInfos(object):
gq = [] gq = []
for group_id in group_ids: 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.groups_query_args = "&".join(gq)
self.base_url = REQUEST.URL0 + "?" + self.groups_query_args self.base_url = REQUEST.URL0 + "?" + self.groups_query_args
self.group_ids = group_ids self.group_ids = group_ids
@ -724,10 +724,15 @@ def groups_table(
return tab.make_page(context, format=format, REQUEST=REQUEST) return tab.make_page(context, format=format, REQUEST=REQUEST)
elif format == "xlsappel": elif format == "xlsappel":
xls = sco_excel.excel_feuille_listeappel(groups_infos.formsemestre, groups_infos.groups_titles, xls = sco_excel.excel_feuille_listeappel(
groups_infos.members, partitions=groups_infos.partitions, groups_infos.formsemestre,
with_codes=with_codes, with_paiement=with_paiement, groups_infos.groups_titles,
server_name=REQUEST.BASE0) 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" filename = "liste_%s" % groups_infos.groups_filename + ".xlsx"
return sco_excel.send_excel_file(REQUEST, xls, filename) return sco_excel.send_excel_file(REQUEST, xls, filename)
elif format == "allxls": elif format == "allxls":

View File

@ -1099,7 +1099,7 @@ def AddBilletAbsence(
if begin_date > end_date: if begin_date > end_date:
raise ValueError("invalid dates") raise ValueError("invalid dates")
# #
justified = int(justified) justified = bool(justified)
# #
cnx = ndb.GetDBConnexion() cnx = ndb.GetDBConnexion()
billet_id = sco_abs.billet_absence_create( billet_id = sco_abs.billet_absence_create(
@ -1109,7 +1109,7 @@ def AddBilletAbsence(
"abs_begin": begin, "abs_begin": begin,
"abs_end": end, "abs_end": end,
"description": description, "description": description,
"etat": 0, "etat": False,
"justified": justified, "justified": justified,
}, },
) )

View File

@ -49,7 +49,6 @@ def test_abs_counts(test_client):
mi = G.create_moduleimpl( mi = G.create_moduleimpl(
module_id=mod["module_id"], module_id=mod["module_id"],
formsemestre_id=sem["formsemestre_id"], formsemestre_id=sem["formsemestre_id"],
responsable_id="bach",
) )
# --- Inscription des étudiants # --- Inscription des étudiants

View File

@ -51,7 +51,6 @@ def test_abs_demijournee(test_client):
mi = G.create_moduleimpl( mi = G.create_moduleimpl(
module_id=mod["module_id"], module_id=mod["module_id"],
formsemestre_id=sem["formsemestre_id"], formsemestre_id=sem["formsemestre_id"],
responsable_id="bach",
) )
# --- Inscription des étudiants # --- Inscription des étudiants
@ -162,7 +161,6 @@ def test_abs_basic(test_client):
mi = G.create_moduleimpl( mi = G.create_moduleimpl(
module_id=mod["module_id"], module_id=mod["module_id"],
formsemestre_id=sem["formsemestre_id"], formsemestre_id=sem["formsemestre_id"],
responsable_id="bach",
) )
# --- Inscription des étudiants # --- Inscription des étudiants
@ -274,7 +272,7 @@ def test_abs_basic(test_client):
assert len(load_liste_abs2) == 1 assert len(load_liste_abs2) == 1
assert len(load_liste_abs) == 2 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]["datedmy"] == "22/01/2021"
assert load_liste_abs2[0]["exams"] == mod["code"] assert load_liste_abs2[0]["exams"] == mod["code"]
# absjust_only -> seulement les abs justifiés # absjust_only -> seulement les abs justifiés
@ -322,10 +320,10 @@ def test_abs_basic(test_client):
for un_etud in load_grp1_abs: for un_etud in load_grp1_abs:
if un_etud["etudid"] == etudid: if un_etud["etudid"] == etudid:
assert un_etud["nbabs"] == "3" assert un_etud["nbabs"] == 3
assert un_etud["nbjustifs_noabs"] == "2" assert un_etud["nbjustifs_noabs"] == 2
assert un_etud["nbabsjust"] == "2" assert un_etud["nbabsjust"] == 2
assert un_etud["nbabsnonjust"] == "1" assert un_etud["nbabsnonjust"] == 1
assert un_etud["nomprenom"] == etuds[0]["nomprenom"] assert un_etud["nomprenom"] == etuds[0]["nomprenom"]
# --- Création de billets # --- Création de billets