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

Method test_with_open

bindings/python/test_rot.py:54–117  ·  view source on GitHub ↗

Call all the methods that depend on open()

(self, model, rot_file, serial_speed)

Source from the content-addressed store, hash-verified

52
53 @pytest.mark.skipif('config.getoption("model") != Hamlib.ROT_MODEL_DUMMY')
54 def test_with_open(self, model, rot_file, serial_speed):
55 """Call all the methods that depend on open()"""
56 rot = Hamlib.Rot(model)
57 assert rot is not None
58
59 assert rot.state.comm_state == 0
60 # first try a known string because rot_file is None during "make check"
61 assert rot.set_conf("rot_pathname", "foo") is None
62 assert rot.get_conf("rot_pathname") == "foo"
63 assert rot.set_conf("rot_pathname", rot_file) is None
64 assert rot.set_conf("serial_speed", str(serial_speed)) is None
65 assert rot.open() is None
66 assert rot.state.comm_state == 1
67 info = rot.get_info()
68 assert isinstance(info, str)
69 assert rot.set_position(1.23, 4.56) is None
70 # When the Dummy rotator simulates movement, this test is too fast
71 # to see a changed position
72 assert rot.get_position() == [0.0, 0.0] # should be [1.23, 4.56]
73 assert rot.move(0, 0) is None
74 speed = 4
75 assert rot.move(Hamlib.ROT_MOVE_UP, speed) is None
76 assert rot.move(Hamlib.ROT_MOVE_LEFT, speed) is None
77 # When the Dummy rotator simulates movement, this test is too fast
78 # to see a changed position
79 assert rot.get_position() == [0.0, 0.0] # should be [-90.0, 90.0]
80 value = Hamlib.value_t()
81 value.i = 3
82 assert rot.set_level(Hamlib.ROT_LEVEL_SPEED, value) is None
83 assert rot.get_level(Hamlib.ROT_LEVEL_NONE) is None
84 assert rot.get_level(Hamlib.ROT_LEVEL_SPEED) == 3
85 with raises(AttributeError):
86 assert rot.status() is None
87 assert rot.stop() is None
88 assert rot.park() is None
89 assert rot.reset(Hamlib.ROT_RESET_ALL) is None
90
91 assert rot.set_ext_func(self.TOK_EL_ROT_MAGICEXTFUNC, 5) is None
92 assert rot.get_ext_func(self.TOK_EL_ROT_MAGICEXTFUNC) == 5
93
94 value.i = 6
95 assert rot.set_ext_level(self.TOK_EL_ROT_MAGICLEVEL, value) is None
96 assert rot.get_ext_level(self.TOK_EL_ROT_MAGICLEVEL) == 6
97
98 value.i = 7
99 assert rot.set_ext_parm(self.TOK_EP_ROT_MAGICPARM, value) is None
100 assert rot.get_ext_parm(self.TOK_EP_ROT_MAGICPARM) == 7
101
102 # Dummy rotator doesn't support functions
103 assert rot.has_set_func(Hamlib.ROT_FUNC_NONE) == Hamlib.ROT_FUNC_NONE
104 assert rot.has_get_func(Hamlib.ROT_FUNC_NONE) == Hamlib.ROT_FUNC_NONE
105 status = 0
106 assert rot.set_func(Hamlib.ROT_FUNC_NONE, status) is None
107 assert rot.get_func(Hamlib.ROT_FUNC_NONE) is None
108
109 # Dummy rotator doesn't support parameters
110 value.i = 5
111 assert rot.set_parm(Hamlib.ROT_PARM_NONE, value) is None

Callers

nothing calls this directly

Calls 6

openMethod · 0.45
moveMethod · 0.45
stopMethod · 0.45
parkMethod · 0.45
resetMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected