Ejemplo n.º 1
0
def handle(event, context):
    reports_scraper = Reports()
    email = Email(settings=settings.EMAIL)

    print('Scraping reports')
    reports = reports_scraper.scrape()
    print('Found:', [r['file_url'] for r in reports])

    print('Sending emails to', email.email_to)
    for report in reports:
        subject, text, attachment = prep_email(report)
        email.send(subject, text, attachment)

    print('Done!')
Ejemplo n.º 2
0
from utils.config import REPORT_PATH


def create_test_suite():
    test_list_path = "../testcase"
    test_unit = unittest.TestSuite()
    discover = unittest.defaultTestLoader.discover(test_list_path,
                                                   pattern="test_*.py")
    for test_suite in discover:
        for test_case in test_suite:
            test_unit.addTest(test_case)
            print(test_case)

    return test_unit


all_test = create_test_suite()
now_time = time.strftime("%Y%m%d%H%M%S", time.localtime())

report = REPORT_PATH + '\\' + now_time + 'report.html'
with open(report, "wb") as outfile:
    runner = HTMLTestRunner.HTMLTestRunner(stream=outfile,
                                           title=u"PC端测试报告",
                                           description=u"用例执行情况:",
                                           verbosity=2)
    runner.run(all_test)
e = Email(path=report, message="详情请下载后打开查看测试报告结果")
e.send()
"""TODO:1、搭建docker+selenium环境,使用无界面模式运行;
        2、使用多线程
        3、加入系统参数启动脚本"""