MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / test_with_open

Method test_with_open

bindings/python/test_amp.py:46–90  ·  view source on GitHub ↗

Call all the methods that depend on open()

(self, model, amp_file, serial_speed)

Source from the content-addressed store, hash-verified

44
45 @pytest.mark.skipif('config.getoption("model") != Hamlib.AMP_MODEL_DUMMY')
46 def test_with_open(self, model, amp_file, serial_speed):
47 """Call all the methods that depend on open()"""
48 amp = Hamlib.Amp(model)
49 assert amp is not None
50
51 assert amp.state.comm_state == 0
52 # first try a known string because amp_file is None during "make check"
53 assert amp.set_conf("amp_pathname", "foo") is None
54 assert amp.get_conf("amp_pathname") == "foo"
55 assert amp.set_conf("amp_pathname", amp_file) is None
56 assert amp.set_conf("serial_speed", str(serial_speed)) is None
57 assert amp.open() is None
58 assert amp.state.comm_state == 1
59 info = amp.get_info()
60 assert isinstance(info, str)
61 assert amp.reset(Hamlib.AMP_RESET_FAULT) is None
62 assert amp.set_freq(0) is None
63 assert amp.set_freq(123.45) is None
64 assert amp.get_freq() == 123.45
65
66 assert amp.has_set_level(Hamlib.AMP_LEVEL_SWR) == Hamlib.AMP_LEVEL_NONE
67 assert amp.has_get_level(Hamlib.AMP_LEVEL_SWR) == Hamlib.AMP_LEVEL_SWR
68 assert amp.get_level(Hamlib.AMP_LEVEL_NONE) is None
69 level = amp.get_level(Hamlib.AMP_LEVEL_SWR)
70 assert isinstance(level, float)
71 level = amp.get_level(Hamlib.AMP_LEVEL_PWR_REFLECTED)
72 assert isinstance(level, int)
73 level = amp.get_level(Hamlib.AMP_LEVEL_FAULT)
74 assert isinstance(level, str)
75 level = amp.get_level(123456)
76 assert level is None
77 value = Hamlib.value_t()
78 value.i = 2
79 assert amp.set_level(Hamlib.AMP_LEVEL_SWR, value) is None
80 assert amp.set_ext_level(Hamlib.AMP_LEVEL_SWR, value) is None
81 level = amp.get_ext_level(Hamlib.AMP_LEVEL_SWR)
82 assert level is None
83
84 assert amp.set_powerstat(Hamlib.RIG_POWER_ON) is None
85 assert amp.get_powerstat() == Hamlib.RIG_POWER_ON
86
87 assert amp.close() is None
88 assert amp.state.comm_state == 0
89 info = amp.get_info()
90 assert info is None
91
92
93 @pytest.mark.skipif('config.getoption("model") != Hamlib.AMP_MODEL_DUMMY')

Callers

nothing calls this directly

Calls 3

openMethod · 0.45
resetMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected