diff --git a/tests/sitl/test_12.py b/tests/sitl/test_12.py index 10beb9528..17620caff 100644 --- a/tests/sitl/test_12.py +++ b/tests/sitl/test_12.py @@ -3,6 +3,7 @@ import time import sys import os +from testlib import assert_equals def current_milli_time(): return int(round(time.time() * 1000)) @@ -10,14 +11,16 @@ def current_milli_time(): def test_timeout(local_connect): v = local_connect().get_vehicles()[0] - print "Read vehicle param 'THR_MIN': %s" % v.parameters['THR_MIN'] + value = v.parameters['THR_MIN'] + assert_equals(type(value), float) - print "Write vehicle param 'THR_MIN' : 50" start = current_milli_time() - v.parameters['THR_MIN']=50 + v.parameters['THR_MIN'] = value + 10 end = current_milli_time() - - print "Read new value of param 'THR_MIN': %s" % v.parameters['THR_MIN'] - # TODO + newvalue = v.parameters['THR_MIN'] + assert_equals(type(newvalue), float) + assert_equals(newvalue, value + 10) + + # TODO once this issue is fixed # assert end - start < 1000, 'time to set parameter was %s, over 1s' % (end - start,) diff --git a/tests/sitl/test_goto.py b/tests/sitl/test_goto.py index 35e89b592..51b092cc5 100644 --- a/tests/sitl/test_goto.py +++ b/tests/sitl/test_goto.py @@ -21,23 +21,23 @@ def arm_and_takeoff(aTargetAltitude): Arms vehicle and fly to aTargetAltitude. """ - print "Basic pre-arm checks" + # print "Basic pre-arm checks" # Don't let the user try to fly autopilot is booting if vehicle.mode.name == "INITIALISING": - print "Waiting for vehicle to initialise" + # print "Waiting for vehicle to initialise" time.sleep(1) while vehicle.gps_0.fix_type < 2: - print "Waiting for GPS...:", vehicle.gps_0.fix_type + # print "Waiting for GPS...:", vehicle.gps_0.fix_type time.sleep(1) - print "Arming motors" + # print "Arming motors" # Copter should arm in GUIDED mode vehicle.mode = VehicleMode("GUIDED") vehicle.flush() i = 60 while not api.exit and vehicle.mode.name != 'GUIDED' and i > 0: - print " Waiting for guided %s seconds..." % (i,) + # print " Waiting for guided %s seconds..." % (i,) time.sleep(1) i = i - 1 @@ -46,7 +46,7 @@ def arm_and_takeoff(aTargetAltitude): i = 60 while not api.exit and not vehicle.armed and vehicle.mode.name == 'GUIDED' and i > 0: - print " Waiting for arming %s seconds..." % (i,) + # print " Waiting for arming %s seconds..." % (i,) time.sleep(1) i = i - 1 @@ -54,7 +54,7 @@ def arm_and_takeoff(aTargetAltitude): assert vehicle.armed assert_equals(vehicle.mode.name, 'GUIDED') - print "Taking off!" + # print "Taking off!" vehicle.commands.takeoff(aTargetAltitude) # Take off to target altitude vehicle.flush() @@ -62,18 +62,18 @@ def arm_and_takeoff(aTargetAltitude): # processing the goto (otherwise the command after # Vehicle.commands.takeoff will execute immediately). while not api.exit: - print " Altitude: ", vehicle.location.alt + # print " Altitude: ", vehicle.location.alt # Test for altitude just below target, in case of undershoot. if vehicle.location.alt >= aTargetAltitude * 0.95: - print "Reached target altitude" - break; + # print "Reached target altitude" + break assert_equals(vehicle.mode.name, 'GUIDED') time.sleep(1) arm_and_takeoff(10) - print "Going to first point..." + # print "Going to first point..." point1 = Location(-35.361354, 149.165218, 20, is_relative=True) vehicle.commands.goto(point1) vehicle.flush() @@ -81,7 +81,7 @@ def arm_and_takeoff(aTargetAltitude): # sleep so we can see the change in map time.sleep(3) - print "Going to second point..." + # print "Going to second point..." point2 = Location(-35.363244, 149.168801, 20, is_relative=True) vehicle.commands.goto(point2) vehicle.flush() @@ -89,6 +89,6 @@ def arm_and_takeoff(aTargetAltitude): # sleep so we can see the change in map time.sleep(3) - print "Returning to Launch" + # print "Returning to Launch" vehicle.mode = VehicleMode("RTL") vehicle.flush() diff --git a/tests/sitl/test_simple.py b/tests/sitl/test_simple.py deleted file mode 100644 index 9c4646740..000000000 --- a/tests/sitl/test_simple.py +++ /dev/null @@ -1,12 +0,0 @@ -from droneapi.lib import VehicleMode -from pymavlink import mavutil -import time -import sys -import os -from testlib import assert_equals - -def test_parameters(local_connect): - v = local_connect().get_vehicles()[0] - - # Simple parameter checks - assert_equals(type(v.parameters['THR_MIN']), float) diff --git a/tests/sitl/test_simpledemo.py b/tests/sitl/test_simpledemo.py new file mode 100644 index 000000000..53351f53e --- /dev/null +++ b/tests/sitl/test_simpledemo.py @@ -0,0 +1,25 @@ +""" +This test represents a simple demo for testing. +Feel free to copy and modify at your leisure. +""" + +from droneapi.lib import VehicleMode +from pymavlink import mavutil +import time +import sys +import os +from testlib import assert_equals + +# This test runs first! +def test_parameter(local_connect): + v = local_connect().get_vehicles()[0] + + # Perform a simple parameter check + assert_equals(type(v.parameters['THR_MIN']), float) + +# This test runs second. Add as many tests as you like +def test_mode(local_connect): + v = local_connect().get_vehicles()[0] + + # Ensure Mode is an instance of VehicleMode + assert isinstance(v.mode, VehicleMode)