def do_single_test(pageid, uid): '''runs a single test and updates the page to indicate the result''' name = names[uid] result = run_sample(name) if result == "Checked!": append_checkmark(pageid, "div_"+uid) return None else: append_warning(pageid, "div_"+uid) mock_page.fake_uid = uid mock_page.fake_pageid = pageid mock_page.set() plugin['exec_code']('print """%s"""\n'%result, uid) mock_page.restore() return 'Failed'
def do_single_test(pageid, uid): '''runs a single test and updates the page to indicate the result''' name = names[uid] result = run_sample(name) if result == "Checked!": append_checkmark(pageid, "div_" + uid) return None else: append_warning(pageid, "div_" + uid) mock_page.fake_uid = uid mock_page.fake_pageid = pageid mock_page.set() plugin['exec_code']('print """%s"""\n' % result, uid) mock_page.restore() return 'Failed'
def all_code_samples_check_callback(request): '''tests all the code samples on a given page''' pageid = request.args["pageid"] failed = False for uid in names: if uid.startswith(pageid+":"): result = do_single_test(pageid, uid) if result == 'Failed': failed = True if failed: append_warning(pageid, "btn1_"+pageid) append_warning(pageid, "btn2_"+pageid) else: append_checkmark(pageid, "btn1_"+pageid) append_checkmark(pageid, "btn2_"+pageid) request.send_response(200) request.end_headers()
def all_code_samples_check_callback(request): '''tests all the code samples on a given page''' pageid = request.args["pageid"] failed = False for uid in names: if uid.startswith(pageid + ":"): result = do_single_test(pageid, uid) if result == 'Failed': failed = True if failed: append_warning(pageid, "btn1_" + pageid) append_warning(pageid, "btn2_" + pageid) else: append_checkmark(pageid, "btn1_" + pageid) append_checkmark(pageid, "btn2_" + pageid) request.send_response(200) request.end_headers()