MCPcopy
hub / github.com/dronekit/dronekit-python / test_115

Function test_115

dronekit/test/sitl/test_115.py:10–47  ·  view source on GitHub ↗
(connpath)

Source from the content-addressed store, hash-verified

8
9@with_sitl
10def test_115(connpath):
11 v = connect(connpath, wait_ready=True)
12
13 # Dummy callback
14 def mavlink_callback(*args):
15 mavlink_callback.count += 1
16
17 mavlink_callback.count = 0
18
19 # Set the callback.
20 v.add_message_listener('*', mavlink_callback)
21
22 # Change the vehicle into STABILIZE mode
23 v.mode = VehicleMode("STABILIZE")
24 # NOTE wait crudely for ACK on mode update
25 time.sleep(3)
26
27 # Expect the callback to have been called
28 assert mavlink_callback.count > 0
29
30 # Unset the callback.
31 v.remove_message_listener('*', mavlink_callback)
32 savecount = mavlink_callback.count
33
34 # Disarm. A callback of None should not throw errors
35 v.armed = False
36 # NOTE wait crudely for ACK on mode update
37 time.sleep(3)
38
39 # Expect the callback to have been called
40 assert_equals(savecount, mavlink_callback.count)
41
42 # Re-arm should not throw errors.
43 v.armed = True
44 # NOTE wait crudely for ACK on mode update
45 time.sleep(3)
46
47 v.close()

Callers

nothing calls this directly

Calls 5

connectFunction · 0.90
VehicleModeClass · 0.90
add_message_listenerMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected