def scan(self, task): """Wrapper method around _frequency and _bookmarks. It calls one of the wrapped functions matching the task.mode value :param task: object that represent a scanning task :type task: object from ScanningTask :raises: none :returns: updates the scanning task object with the new activity found """ if (not task or not task.mode or task.mode.lower() not in SUPPORTED_SCANNING_MODES): logger.exception("Invalid scan mode provided:" "{}".format(task.mode)) raise InvalidScanModeError log = LogFile() try: log.open(task.log_filename) except IOError: logger.exception("Error while opening the log file.") raise if task.mode.lower() == "bookmarks": task = self._bookmarks(task, log) elif task.mode.lower() == "frequency": task = self._frequency(task, log) log.close()
def scan(self, task): """Wrapper method around _frequency and _bookmarks. It calls one of the wrapped functions matching the task.mode value :param task: object that represent a scanning task :type task: object from ScanningTask :raises: none :returns: updates the scanning task object with the new activity found """ if (not task or not task.mode or task.mode.lower() not in SUPPORTED_SCANNING_MODES): logger.exception("Invalid scan mode provided:{}".format(task.mode)) raise InvalidScanModeError log = LogFile() log.open(task.log_filename) if task.mode.lower() == "bookmarks": task = self._bookmarks(task, log) elif task.mode.lower() == "frequency": task = self._frequency(task, log) log.close()
def test_bad_data3(): lf = LogFile() lf.open("/tmp/nofile") with pytest.raises(IndexError): lf.write("B", ["122"], "2")
def test_bad_data2(): lf = LogFile() lf.open("/tmp/nofile") with pytest.raises(TypeError): lf.write("C", ("122"), ["2", "2"])
def test_bad_data3(): lf=LogFile() lf.open("/tmp/nofile") with pytest.raises(IndexError): lf.write("B",["122"],"2")
def test_bad_data2(): lf=LogFile() lf.open("/tmp/nofile") with pytest.raises(TypeError): lf.write("C",("122"),["2","2"])