def test_rig_reset(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_antenna("testparam")
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)
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"
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
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), "")
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), "")
def test_mode_1(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_mode(22)
def test_mode_2(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_mode("testmode")
def test_split_freq(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_split_freq("testvfo")
def test_parm_1(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_parm(22)
def test_set_antenna(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_antenna("testreset")
def test_vfo_1(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_vfo(22)
def test_split_freq(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_split_freq("testvfo")
def test_set_frequency(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_frequency("test")
def test_rit(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_rit("testrit")
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()
def test_antenna(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_antenna("testparm")
def test_func_2(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_func("testvfo")
def test_rig_control(): with pytest.raises(TypeError): rigctl = RigCtl("test")
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)
def test_get_level(fake_target): rigctl = RigCtl(fake_target) rigctl._request = MagicMock() rigctl._request.return_value = "22" assert(rigctl.get_level() == "22")
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()
def test_set_bad_frequency(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_frequency("test")
def test_rig_reset(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.rig_reset("testreset")
def test_set_bad_mode(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_mode(5)
def test_xit(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_xit(22)
def test_split_mode_1(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_split_mode(22)
def test_vfo_2(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_vfo("testvfo")
def test_get_antenna(fake_target): rigctl = RigCtl(fake_target) rigctl._request = MagicMock() rigctl._request.return_value = 22 assert(rigctl.get_antenna() == 22)
def test_rit(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_rit("testrit")
def test_mode_2(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_mode("testmode")
def test_parm_2(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_parm("testparm")
def test_func_1(): rigctl = RigCtl() with pytest.raises(ValueError): rigctl.set_func(22)
def test_get_mode(fake_target): rigctl = RigCtl(fake_target) rigctl._request = MagicMock() rigctl._request.return_value = "m" assert(rigctl.get_mode() == "m")
def test_parm_1(fake_target): rigctl = RigCtl(fake_target) with pytest.raises(ValueError): rigctl.set_parm(22)
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()
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()