diff --git a/_unittests/ut_automation_students/test_pitch_automatique.py b/_unittests/ut_automation_students/test_pitch_automatique.py index 4cbeca852..7e823fd18 100644 --- a/_unittests/ut_automation_students/test_pitch_automatique.py +++ b/_unittests/ut_automation_students/test_pitch_automatique.py @@ -113,7 +113,7 @@ def test_enumerate_feedback(self): xls = os.path.join(data, "groupes_eleves_pitch.xlsx") df = pandas.read_excel(xls, sheetname=0, index=False) comment = pandas.read_excel(xls, sheetname=1, header=None, index=False) - mails = list(enumerate_feedback(df, comment)) + mails = list(enumerate_feedback(df, comment, exc=False, fLOG=fLOG)) for i, m in enumerate(mails): fLOG("------------", i) name = os.path.join(temp, "m%d.html" % i) diff --git a/src/ensae_teaching_cs/automation_students/send_feedback.py b/src/ensae_teaching_cs/automation_students/send_feedback.py index 74f6837af..e14573acc 100644 --- a/src/ensae_teaching_cs/automation_students/send_feedback.py +++ b/src/ensae_teaching_cs/automation_students/send_feedback.py @@ -29,7 +29,7 @@ def enumerate_feedback(df1, df2, col_group="Groupe", col_subject="Sujet", col_name="Name", subject="Projet informatique, feedback sur le pitch", begin="Bonjour,\n\nVoici mon feedback sur votre pitch. Ce mail est automatisé. Veuillez vérifier les informations.\n\n", end="Xavier", text_comments="Remarques générales", cc=None, - template=template_mail_feedback, engine="jinja2", fLOG=noLOG): + template=template_mail_feedback, engine="jinja2", exc=True, fLOG=noLOG): """ sends feedback to students @@ -47,6 +47,7 @@ def enumerate_feedback(df1, df2, col_group="Groupe", col_subject="Sujet", @param template template of the mail @param text_comments sentance before the general comments @param engine engine for the template + @param exc raise an exception if there is no mail @return list of mails Example of dataframe containing feedback: @@ -108,4 +109,9 @@ def sums2(spl): k = k[4:] context[k] = v text = apply_template(template, context, engine=engine) + if mail is None or "@" not in mail: + if exc: + raise ValueError("No mail for:\n" + text) + else: + fLOG("No mail for:\n" + text) yield (mail, text)