Пример #1
0
 def test_get_reports(self):
     job_list_html = files.read(self.job_list_path)
     console_log = files.read(self.log_path)
     html_url = "{}/{}".format(LOGURL, JOBNAME)
     console1_url = "{}/{}/1/console.log.gz".format(LOGURL, JOBNAME)
     console2_url = "{}/{}/2/console.log.gz".format(LOGURL, JOBNAME)
     report = console.ConsoleReports(LOGURL, JOBNAME)
     with requests_mock.Mocker() as mrequests:
         mrequests.register_uri('GET', html_url, text=job_list_html)
         mrequests.register_uri('GET', console1_url, text=console_log)
         mrequests.register_uri('GET', console2_url, text=console_log)
         report.get_reports(2)
         report.write_reports("/tmp")
Пример #2
0
 def test_process_console_log(self):
     console_log = files.read(self.log_path)
     self.report.process_console_log(console_log, 102)
     self.assertEqual(len(self.report.reports), 3)
     suite = self.report.reports.get("01 l2")
     self.assertEqual(len(suite), 2)
     suite = self.report.reports.get("04 security group")
     self.assertEqual(len(suite), 2)
Пример #3
0
 def test_process_txt(self):
     console_log = files.read(self.log_path)
     self.report.process_log(console_log, 102)
     self.assertEqual(len(self.report.reports), 3)
     suite = self.report.reports.get("09 vpn basic ipv6")
     self.assertEqual(len(suite), 4)
     suite = self.report.reports.get("11 arp learning")
     self.assertEqual(len(suite), 5)
Пример #4
0
 def test_get_exceptions_txt_file(self):
     log_text = files.read(self.excepts_log_path)
     path = "{}/1/odl_1_exceptions.txt.gz".format(JOBNAME)
     url = "{}/{}".format(LOGURL, path)
     restclient = rest_client.RestClient(LOGURL)
     with requests_mock.Mocker() as mrequests:
         mrequests.register_uri('GET', url, text=log_text)
         log = reports.get_log_file(restclient, path)
         self.assertEqual(log[0:5], "=====")
Пример #5
0
 def test_get_console_log_file(self):
     log_text = files.read(self.console_log_path)
     path = "{}/1/console.log.gz".format(JOBNAME)
     url = "{}/{}".format(LOGURL, path)
     restclient = rest_client.RestClient(LOGURL)
     with requests_mock.Mocker() as mrequests:
         mrequests.register_uri('GET', url, text=log_text)
         log = reports.get_log_file(restclient, path)
         self.assertEqual(log[0:5], "pybot")
Пример #6
0
    def test_get_models(self):
        files.rmdir(self.args.path)

        with requests_mock.Mocker() as mrequests:
            for res in self.args.modules:
                args2 = Args(path=tests.get_resources_path(), pretty_print=True)
                filename = model.make_filename_from_resource(args2, res)
                data = files.read(filename)
                url_path = model.make_url_path_from_resource(res)
                url_root, _ = model.make_url_parts(self.args, None)
                mrequests.register_uri('GET', '/'.join((url_root, url_path)), text=data)

            models.get_models(self.args)
            # assert each model has been saved to a file
            for res in self.args.modules:
                filename = model.make_filename_from_resource(self.args, res)
                self.assertTrue(os.path.isfile(filename))
Пример #7
0
 def test_get_job_list(self):
     job_list_html = files.read(self.job_list_html_path)
     joblist = reports.extract_job_list_from_html(job_list_html)
     self.assertEqual(len(joblist), 2)