Ejemplo n.º 1
0
def test_tune():
    st = scan_task()
    st.passes = 4
    log = LogFile()
    freq = "test"
    s = Scanning()
    with pytest.raises(ValueError):
        s._frequency_tune(st, freq)
Ejemplo n.º 2
0
def test_2_tune():
    st = scan_task()
    st.passes = 4
    log = LogFile()
    freq = st.params["range_min"]
    s = Scanning()
    try:
        s._frequency_tune(st, freq)
    except Exception:
        pass
    assert (s.scan_active == False)
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
def test_bad_data3():
    lf = LogFile()
    lf.open("/tmp/nofile")
    with pytest.raises(IndexError):
        lf.write("B", ["122"], "2")
Ejemplo n.º 6
0
def test_bad_data2():
    lf = LogFile()
    lf.open("/tmp/nofile")
    with pytest.raises(TypeError):
        lf.write("C", ("122"), ["2", "2"])
Ejemplo n.º 7
0
def test_no_logfile():
    lf = LogFile()
    with pytest.raises(AttributeError):
        lf.write("B", ("122"), ["2", "2"])
Ejemplo n.º 8
0
def test_bad_data3():
    lf=LogFile()
    lf.open("/tmp/nofile")
    with pytest.raises(IndexError):
        lf.write("B",["122"],"2")
Ejemplo n.º 9
0
def test_bad_data2():
    lf=LogFile()
    lf.open("/tmp/nofile")
    with pytest.raises(TypeError):
        lf.write("C",("122"),["2","2"])
Ejemplo n.º 10
0
def test_no_logfile():
    lf=LogFile()
    with pytest.raises(AttributeError):
        lf.write("B",("122"),["2","2"])