Exemple #1
0
 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)
Exemple #2
0
    def test_attachment(self):
        results_1 = Results("foo", "<foo>foo</foo>", environment="foo")
        results_2 = Results("bar", "<bar>bar</bar>", environment="bar")
        results_list = [results_1, results_2]

        a = attachment(111111, results_list)
        self.assertEquals("OTS_testrun_111111.zip", a.get_filename())
        tmp_filename = mktemp()
        pl = a.get_payload(decode=True)
        f = open(tmp_filename, "wb")
        f.write(pl)
        f.close()
        z = ZipFile(tmp_filename)
        self.assertEquals(2, len(z.infolist()))
Exemple #3
0
 def test_zipped(self):
     results_1 = Results("foo", "<foo>foo</foo>", environment="foo")
     results_2 = Results("bar", "<bar>bar</bar>", environment="bar")
     results_list = [results_1, results_2]
     file = _zip_file("111", results_list)
     tmp_filename = mktemp()
     f = open(tmp_filename, "wb")
     f.write(file.read())
     f.close()
     z = ZipFile(tmp_filename)
     self.assertEquals(2, len(z.infolist()))
     contents = ''.join([z.read(name) for name in z.namelist()])
     expected = "<foo>foo</foo><bar>bar</bar>"
     self.assertEquals(expected, contents)
 def _send_result(environment, results_xml, name):
     results = Results(name,
                       results_xml,
                       package=name,
                       hostname="mock_task_runner",
                       environment=environment)
     DTO_SIGNAL.send(sender="MockTaskRunner", dto=results)
    def test_message(self):
        mail_message = MailMessage("*****@*****.**")
        results_1 = Results("foo", "<foo>foo</foo>", environment="foo")
        results_2 = Results("bar", "<bar>bar</bar>", environment="bar")
        results_list = [results_1, results_2]
        source_uris = {
            "meego": "www.meego.com",
            "intel": "www.intel.com",
            "nokia": "www.nokia.com"
        }

        message = mail_message.message("request_id", "testrun_uuid",
                                       "sw_product", "PASS", results_list,
                                       None,
                                       Packages("env", ["foo", "bar", "baz"]),
                                       source_uris, ["*****@*****.**"], True,
                                       "build_url %s")
        self.assertTrue(isinstance(message, MIMEMultipart))
Exemple #6
0
 def test_results(self):
     dto_handler = DTOHandler()
     results = Results("tatam_xml_testrunner_results_for_foo" , "<test>bar</test>", package = "pkg1",
                       environment = "unittest")
     dto_handler._results(results)
     self.assertEquals(["pkg1"], 
                       dto_handler.tested_packages.packages("unittest"))
     dto_handler._results(results)
     self.assertEquals(["pkg1", "pkg1"], 
                       dto_handler.tested_packages.packages("unittest"))
Exemple #7
0
 def add_result(self,
                filename,
                content,
                origin="Unknown",
                test_package="Unknown",
                environment="Unknown"):
     """Calls OTSMessageIO to create result object message"""
     results = Results(filename,
                       content,
                       package=test_package,
                       hostname=origin,
                       environment=environment)
     self._send_message(pack_message(results))
Exemple #8
0
    def test_fail(self):
        pkgs = Packages("hardware", ["pkg1", "pkg2"])
        results_dir = os.path.dirname(os.path.abspath(ots.results.__file__))
        results_fqname = os.path.join(results_dir, "tests", "data",
                                      "dummy_results_file.xml")
        results_xml = open(results_fqname, "r")
        results = Results("tatam_xml_testrunner_fail", results_xml.read())
        tr = Testrun()
        tr._dto_handler.expected_packages = pkgs
        tr._dto_handler.tested_packages = pkgs

        tr._dto_handler.results = [results]
        tr.run_test = lambda: 1
        self.assertFalse(tr.run())