This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
test_pitch_automatique.py
67 lines (58 loc) · 2.38 KB
/
test_pitch_automatique.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# -*- coding: utf-8 -*-
"""
@brief test log(time=2s)
"""
import os
import unittest
import pandas
from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import get_temp_folder, ExtTestCase
from ensae_teaching_cs.automation_students import enumerate_feedback, enumerate_send_email
class TestFeedback(ExtTestCase):
def test_enumerate_feedback(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
exp = [
"<p>ok</p>",
]
temp = get_temp_folder(__file__, "temp_enumerate_feedback")
data = os.path.abspath(os.path.dirname(__file__))
data = os.path.join(data, "data")
xls = os.path.join(data, "groupes_eleves_pitch.xlsx")
df = pandas.read_excel(xls, sheet_name=0, engine='openpyxl')
mails = list(enumerate_feedback(df, exc=False, fLOG=fLOG,
begin="BEGIN", end="END", subject="SUBJECT",
col_name="Nom", cols=["Pitch", "Code"]))
for i, m in enumerate(mails):
fLOG("------------", i)
name = os.path.join(temp, "m%d.html" % i)
with open(name, "w", encoding="utf-8") as f:
f.write(m[1])
if i < len(exp):
if exp[i] not in m[1]:
raise AssertionError(f"EXP\n{exp[i]}\nRES\n{m[1]}")
def test_enumerate_send_email(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
data = os.path.abspath(os.path.dirname(__file__))
data = os.path.join(data, "data")
xls = os.path.join(data, "groupes_eleves_pitch.xlsx")
# pymmails.sender.create_smtp_server("gmail", login, pwd)
mailbox = None
df = pandas.read_excel(xls, sheet_name=0, engine='openpyxl')
try:
mails = list(enumerate_send_email(mailbox, fr="me", col_name="Nom", cols=["Pitch", "Code"],
df1=df, exc=False, fLOG=fLOG, delay_sending=True,
begin="BEGIN", end="END", subject="SUBJECT"))
self.assertNotEmpty(mails)
except ValueError as e:
if "mailbox is None" in str(e):
pass
else:
raise e
if __name__ == "__main__":
unittest.main()