Skip to content

Commit b693997

Browse files
committed
test: cover mail/web export and deletion offline
Record mail and web exporter dumps in results-offline.csv and add a delete regression exercise. Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
1 parent 4d1334d commit b693997

2 files changed

Lines changed: 9257 additions & 1 deletion

File tree

regzbot/testing_offline.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import git
2323
import regzbot
2424
import regzbot.export_csv
25+
import regzbot.export_mail
2526
import regzbot.export_web
2627
import regzbot._repsources._lore
2728

@@ -448,6 +449,12 @@ def init_mailsdir(path_tmpmail):
448449
def init(tmpdir, testdatadir):
449450
regzbot.set_citesting("offline")
450451

452+
regzbot._TESTING["mail_now"] = datetime.datetime.fromtimestamp(
453+
Emaildir._startdate + 30 * 86400, datetime.timezone.utc
454+
)
455+
regzbot._TESTING["mail_lastreport_gmtime"] = Emaildir._startdate - 86400
456+
regzbot._TESTING["mail_lastreport_msgid"] = "testing-lastreport@example.com"
457+
451458
_, databasedir, gittreesdir, _ = regzbot.basicressources_get_dirs(
452459
tmpdir=tmpdir, databasedir=os.path.join(tmpdir, "db-offlinetsts")
453460
)
@@ -475,6 +482,9 @@ def run(resultfilename, tmpdir, testdatadir):
475482
testfuncprefix = "offltest"
476483
this = sys.modules[__name__]
477484

485+
mail_results = []
486+
web_results = []
487+
478488
outercount = 0
479489
while "%s_%s_0" % (testfuncprefix, outercount) in dir(this):
480490
# reset git
@@ -505,12 +515,21 @@ def run(resultfilename, tmpdir, testdatadir):
505515
update_gittrees()
506516

507517
# write results
508-
resultfile.write("[%s_%s_%s]\n" % (testfuncprefix, outercount, innercount))
518+
name = "%s_%s_%s" % (testfuncprefix, outercount, innercount)
519+
resultfile.write("[%s]\n" % name)
509520
for data in regzbot.export_csv.dumpall_csv():
510521
resultfile.write(data)
511522
resultfile.write("\n")
512523

524+
mail_results.append("-----BEGIN MAIL %s-----\n" % name)
525+
mail_results.extend(regzbot.export_mail.dumpall_mail())
526+
mail_results.append("-----END MAIL %s-----\n\n" % name)
527+
web_results.append("-----BEGIN WEB %s-----\n" % name)
528+
web_results.extend(regzbot.export_web.dumpall_web())
529+
web_results.append("-----END WEB %s-----\n\n" % name)
530+
513531
regzbot.export_web.RegExportWeb.compile()
532+
regzbot.export_mail.RegExportMailReport.compile(interactive=False)
514533

515534
if instructions and "wait" in instructions:
516535
# regzbot.db_commit()
@@ -521,6 +540,15 @@ def run(resultfilename, tmpdir, testdatadir):
521540
# remove generated mails
522541
emaildirs_clear()
523542
outercount += 1
543+
544+
separator = "=" * 80 + "\n"
545+
resultfile.write(separator + "= MAIL REPORTS\n" + separator)
546+
for data in mail_results:
547+
resultfile.write(data)
548+
resultfile.write(separator + "= WEB REPORTS\n" + separator)
549+
for data in web_results:
550+
resultfile.write(data)
551+
524552
resultfile.close()
525553
regzbot.db_commit()
526554
regzbot.db_close()
@@ -1845,3 +1873,31 @@ def offltest_5_2(funcname):
18451873
)
18461874

18471875
return ["mailchk"]
1876+
1877+
1878+
def offltest_6_0(funcname):
1879+
logger.info("%s: create a regression with link, note, and reply for delete test" % funcname)
1880+
1881+
emaildirs["primary"].create_email(funcname, "#regzbot introduced: v1.8..v1.9-rc1")
1882+
1883+
subcounter = 1
1884+
emaildirs["primary"].create_email(
1885+
"%s_%s" % (funcname, subcounter),
1886+
"#regzbot relatebrief: https://www.kernel.org/releases.html Some link\n"
1887+
"#regzbot note: note before delete",
1888+
replyto=funcname,
1889+
)
1890+
1891+
subcounter += 2
1892+
emaildirs["primary"].create_email(
1893+
"%s_%s" % (funcname, subcounter), "a reply to generate activity", replyto=funcname
1894+
)
1895+
1896+
return ["mailchk"]
1897+
1898+
1899+
def offltest_6_1(funcname):
1900+
logger.info("%s: delete the regression created in 6_0" % funcname)
1901+
for regression in regzbot.RegressionBasic.get_all():
1902+
regression.delete()
1903+
return []

0 commit comments

Comments
 (0)