Example #1
1
def test_rig_reset():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_antenna("testparam")
Example #2
0
def test_set_frequency(hostname, port, fake_target):
    DEFAULT_CONFIG["hostname"] = "127.0.0.1"
    DEFAULT_CONFIG["port"] = "80"
    rigctl = RigCtl(fake_target)
    rigctl._request = MagicMock()
    rigctl.set_frequency("1000000")
    rigctl._request.assert_called_once_with('F 1000000', None)
Example #3
0
def test_get_frequency(fake_target):
    DEFAULT_CONFIG["hostname"] = "127.0.0.1"
    DEFAULT_CONFIG["port"] = "80"
    rigctl = RigCtl(fake_target)
    rigctl._request = MagicMock()
    rigctl._request.return_value = "f"
    rigctl.get_frequency()
    rigctl._request == "f"
Example #4
0
def scan_task():

    params = {}
    scanq = ""
    mode = "bookmarks"
    rig = None
    bookmark_list = []
    new_bookmark_list = []
    params["txt_range_min"] = TestStr("100")
    params["txt_range_max"] = TestStr("50")
    params["txt_delay"] = TestStr("1")
    params["txt_passes"] = TestStr("0")
    params["txt_sgn_level"] = TestStr("50")
    params["txt_interval"] = TestStr("100000")
    params["ckb_record"] = TestBool(False)
    params["ckb_log"] = TestBool(False)
    params["ckb_wait"] = TestBool(False)
    params["delay"] = 1
    params["ckb_auto_bookmark"] = TestBool(False)

    fake_target = {}
    fake_target["hostname"] = "127.0.0.1"
    fake_target["port"] = 80
    fake_target["rig_number"] = 1

    scan_task = ScanningTask(scanq, mode, bookmark_list, new_bookmark_list,
                             params, RigCtl(fake_target), "")
    return scan_task
Example #5
0
def test_bad_param(scanq, mode, bookmark_list, new_bookmark_list, min_freq,
                   max_freq, delay, passes, sgn_level, interval, record, log,
                   wait, auto_bookmark, fake_target):
    with pytest.raises(ValueError):

        params = {}
        params["txt_range_min"] = TestStr(min_freq)
        params["txt_range_max"] = TestStr(max_freq)
        params["txt_delay"] = TestStr(delay)
        params["txt_passes"] = TestStr(passes)
        params["txt_sgn_level"] = TestStr(sgn_level)
        params["txt_interval"] = TestStr(interval)
        params["ckb_record"] = TestBool(record)
        params["ckb_log"] = TestBool(log)
        params["ckb_wait"] = TestBool(wait)
        params["ckb_auto_bookmark"] = TestBool(auto_bookmark)

        ScanningTask(scanq, mode, bookmark_list, new_bookmark_list, params,
                     RigCtl(fake_target), "")
Example #6
0
def test_unsupported_scan_mode(fake_target):

    params = {}
    scanq = None
    mode = "test"
    bookmark_list = []
    new_bookmark_list = []
    params["txt_range_min"] = TestStr("100")
    params["txt_range_max"] = TestStr("50")
    params["txt_delay"] = TestStr("1")
    params["txt_passes"] = TestStr("0")
    params["txt_sgn_level"] = TestStr("50")
    params["txt_interval"] = TestStr("100000")
    params["ckb_record"] = TestBool(False)
    params["ckb_log"] = TestBool(False)
    params["ckb_wait"] = TestBool(False)
    params["ckb_auto_bookmark"] = TestBool(False)

    with pytest.raises(UnsupportedScanningConfigError):
        scan_task = ScanningTask(scanq, mode, bookmark_list, new_bookmark_list,
                                 params, RigCtl(fake_target), "")
Example #7
0
def test_mode_1():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_mode(22)
Example #8
0
def test_mode_2(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_mode("testmode")
Example #9
0
def test_split_freq():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_split_freq("testvfo")
Example #10
0
def test_parm_1():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_parm(22)
Example #11
0
def test_set_antenna():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_antenna("testreset")
Example #12
0
def test_vfo_1():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_vfo(22)
Example #13
0
def test_split_freq(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_split_freq("testvfo")
Example #14
0
def test_set_frequency():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_frequency("test")
Example #15
0
def test_rit(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_rit("testrit")
Example #16
0
def test_request_socket_error(fake_target):
    telnetlib.Telnet = MagicMock(side_effect=socket.error)
    rigctl = RigCtl(fake_target)
    with pytest.raises(socket.error):
        rigctl.get_frequency()
Example #17
0
def test_antenna(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_antenna("testparm")
Example #18
0
def test_func_2(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_func("testvfo")
Example #19
0
def test_rig_control():
    with pytest.raises(TypeError):
        rigctl = RigCtl("test")
Example #20
0
def test_set_mode(fake_target):
    rigctl = RigCtl(fake_target)
    rigctl._request = MagicMock()
    rigctl.set_mode("AM")
    rigctl._request.assert_called_once_with('M AM', None)
Example #21
0
def test_get_level(fake_target):
    rigctl = RigCtl(fake_target)
    rigctl._request = MagicMock()
    rigctl._request.return_value = "22"
    assert(rigctl.get_level() == "22")
Example #22
0
def test_get_connection_refused(hostname, port):
    DEFAULT_CONFIG["hostname"] = hostname
    DEFAULT_CONFIG["port"] = port
    rigctl = RigCtl()
    with pytest.raises(socket.error):
        rigctl.get_frequency()
Example #23
0
def test_set_bad_frequency(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_frequency("test")
Example #24
0
def test_rig_reset():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.rig_reset("testreset")
Example #25
0
def test_set_bad_mode(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_mode(5)
Example #26
0
def test_xit():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_xit(22)
Example #27
0
def test_split_mode_1(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_split_mode(22)
Example #28
0
def test_vfo_2():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_vfo("testvfo")
Example #29
0
def test_get_antenna(fake_target):
    rigctl = RigCtl(fake_target)
    rigctl._request = MagicMock()
    rigctl._request.return_value = 22
    assert(rigctl.get_antenna() == 22)
Example #30
0
def test_rit():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_rit("testrit")
Example #31
0
def test_mode_2():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_mode("testmode")
Example #32
0
def test_parm_2():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_parm("testparm")
Example #33
0
def test_func_1():
    rigctl = RigCtl()
    with pytest.raises(ValueError):
        rigctl.set_func(22)
Example #34
0
def test_get_mode(fake_target):
    rigctl = RigCtl(fake_target)
    rigctl._request = MagicMock()
    rigctl._request.return_value = "m"
    assert(rigctl.get_mode() == "m")
Example #35
0
def test_parm_1(fake_target):
    rigctl = RigCtl(fake_target)
    with pytest.raises(ValueError):
        rigctl.set_parm(22)
Example #36
0
def test_get_mode_error(fake_target):
    rigctl = RigCtl(fake_target)
    rigctl._request = MagicMock()
    rigctl._request.return_value = 22
    with pytest.raises(ValueError):
        rigctl.get_mode()
Example #37
0
def test_get_antenna_error(fake_target):
    rigctl = RigCtl(fake_target)
    rigctl._request = MagicMock()
    rigctl._request.return_value = "22"
    with pytest.raises(ValueError):
        rigctl.get_antenna()