예제 #1
0
 def test_scan_get(self):
     force = False
     probes = probe_list()
     scan = scan_files(FILEPATHS, force, probes)
     while not scan.is_finished():
         time.sleep(1)
         scan = scan_get(scan.id)
     self._check_scan(scan, scan.id, ["finished"],
                      FILENAMES, [scan.probes_total], [scan.probes_total],
                      scan.date, force, True, True)
예제 #2
0
    def _test_scan_file(self,
                        filelist,
                        probelist,
                        force=True,
                        mimetype_filtering=None,
                        resubmit_files=None,
                        timeout=SCAN_TIMEOUT_SEC):
        nb_probes = len(probelist)
        nb_files = len(filelist)
        nb_jobs = nb_probes * nb_files
        filenames = map(lambda f: os.path.basename(f), filelist)
        scan = scan_new(verbose=DEBUG)
        self.assertIsNot(scan.id, None)
        scanid = scan.id
        self.assertIsNot(scan.date, None)
        self.assertEqual(len(scan.results), 0)

        scan = scan_add(scan.id, filelist, verbose=DEBUG)
        self._check_results(scan.results, scanid, filenames, [0], [0],
                            True, True)

        scan = scan_launch(scan.id, force=force, probe=probelist,
                           mimetype_filtering=mimetype_filtering,
                           resubmit_files=resubmit_files,
                           verbose=DEBUG)
        start = time.time()
        while not scan.is_finished():
            self._check_results(scan.results, scanid, filenames,
                                range(nb_probes + 1), range(nb_jobs + 1),
                                True, True)
            time.sleep(BEFORE_NEXT_PROGRESS)
            now = time.time()
            self.assertLessEqual(now, start + timeout, "Results Timeout")
            scan = scan_get(scan.id)

        # Scan finished
        self._check_results(scan.results, scanid, filenames,
                            [scan.probes_total], [scan.probes_total],
                            True, True)
        res = {}
        for get_result in scan.results:
            file_result = scan_proberesults(get_result.result_id,
                                            formatted=True, verbose=DEBUG)
            self.assertIn(file_result.status, [-1, 0, 1])
            self.assertEqual(file_result.probes_finished,
                             file_result.probes_total)
            self.assertEqual(len(file_result.probe_results),
                             file_result.probes_total)
            res[get_result.name] = {}
            for pr in file_result.probe_results:
                res[get_result.name][pr.name] = pr
        return res
예제 #3
0
 def test_file_results_formatted(self):
     force = False
     probes = probe_list()
     scan = scan_files(FILEPATHS, force, probes)
     while not scan.is_finished():
         time.sleep(1)
         scan = scan_get(scan.id)
     for get_result in scan.results:
         self.assertTrue(self._validate_uuid(str(get_result.result_id)))
         res = scan_proberesults(get_result.result_id)
         self.assertIn(res.name, FILENAMES)
         self.assertEqual(type(res.probe_results), list)
         self.assertEqual(type(res.probe_results[0]), IrmaProbeResult)
         self.assertEqual(len(res.probe_results), res.probes_finished)