def test_format_result(self): self.assertEquals("PASS", format_result("PASS", None)) self.assertEquals("FAIL", format_result("FAIL", None)) exc = OTSException() exc.strerror = "foo" self.assertEquals("FAIL (Error: foo, Error code: )", format_result("FAIL", exc))
def test_publish(self): rnd = Random() reqnumber = rnd.randint(100, 1000) email_plugin = EmailPlugin(reqnumber, 2222, "sw_product", "www.meego.com", email = "on", email_attachments = "on", notify_list=[RECIPIENT], build_url="build_url %s") exc = OTSException() exc.strerror = "foo" results_1 = Results("foo", "<foo>foo</foo>", environment = "foo") results_2 = Results("bar", "<bar>bar</bar>", environment = "bar") results_list = [results_1, results_2] email_plugin.set_exception(exc) email_plugin.set_expected_packages(Packages("env", ["foo", "bar", "baz"])) email_plugin.set_tested_packages(Packages("env", ["foo", "bar", "baz"])) email_plugin.set_results(results_list) email_plugin.add_monitor_event(Monitor()) email_plugin.set_testrun_result("PASS") email_plugin.publish() time.sleep(2) header = pop_inbox() expected = "[OTS] [sw_product] Req#" + str(reqnumber) +": PASS" self.assertTrue(expected, header)
def run(self): pkgs = Packages("hardware_test", ["pkg1-tests"]) DTO_SIGNAL.send(sender="MockTaskRunner", dto=pkgs) exc = OTSException("mock task runner", 6310) DTO_SIGNAL.send(sender="MockTaskRunner", dto=exc)