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

Function test_parameter

dronekit/test/sitl/test_waypoints.py:46–118  ·  view source on GitHub ↗
(connpath)

Source from the content-addressed store, hash-verified

44
45@with_sitl
46def test_parameter(connpath):
47 vehicle = connect(connpath, wait_ready=True)
48
49 # Home should be None at first.
50 assert_equals(vehicle.home_location, None)
51
52 # Wait for home position to be real and not 0, 0, 0
53 # once we request it via cmds.download()
54 time.sleep(10)
55
56 # Initial
57 vehicle.commands.download()
58 vehicle.commands.wait_ready()
59 assert_equals(len(vehicle.commands), 0)
60 assert_not_equals(vehicle.home_location, None)
61
62 # Save home for comparison.
63 home = vehicle.home_location
64
65 # After clearing
66 vehicle.commands.clear()
67 vehicle.commands.upload()
68 vehicle.commands.download()
69 vehicle.commands.wait_ready()
70 assert_equals(len(vehicle.commands), 0)
71
72 # Upload
73 for command in [
74 Command(0, 0, 0, 0, 16, 1, 1, 0.0, 0.0, 0.0, 0.0, -35.3605, 149.172363, 747.0),
75 Command(0, 0, 0, 3, 22, 0, 1, 0.0, 0.0, 0.0, 0.0, -35.359831, 149.166334, 100.0),
76 Command(0, 0, 0, 3, 16, 0, 1, 0.0, 0.0, 0.0, 0.0, -35.363489, 149.167213, 100.0),
77 Command(0, 0, 0, 3, 16, 0, 1, 0.0, 0.0, 0.0, 0.0, -35.355491, 149.169595, 100.0),
78 Command(0, 0, 0, 3, 16, 0, 1, 0.0, 0.0, 0.0, 0.0, -35.355071, 149.175839, 100.0),
79 Command(0, 0, 0, 3, 113, 0, 1, 0.0, 0.0, 0.0, 0.0, -35.362666, 149.178715, 22222.0),
80 Command(0, 0, 0, 3, 115, 0, 1, 2.0, 22.0, 1.0, 3.0, 0.0, 0.0, 0.0),
81 Command(0, 0, 0, 3, 16, 0, 1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0),
82 ]:
83 vehicle.commands.add(command)
84 vehicle.commands.upload()
85
86 # After upload
87 vehicle.commands.download()
88 vehicle.commands.wait_ready()
89 assert_equals(len(vehicle.commands), 8)
90
91 # Test iteration.
92 count = 0
93 for cmd in vehicle.commands:
94 assert_not_equals(cmd, None)
95 count += 1
96 assert_equals(count, 8)
97
98 # Test slicing
99 count = 3
100 for cmd in vehicle.commands[2:5]:
101 assert_not_equals(cmd, None)
102 assert_equals(cmd.seq, count)
103 count += 1

Callers

nothing calls this directly

Calls 8

connectFunction · 0.90
CommandClass · 0.90
downloadMethod · 0.80
clearMethod · 0.80
uploadMethod · 0.80
addMethod · 0.80
wait_readyMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected