5 Unit tests for the fgFDM library 8 from __future__
import print_function
11 from pymavlink.fgFDM import fgFDMError, fgFDMVariable, fgFDMVariableList, fgFDM
16 Class to test fgFDMError 19 """Constructor, set up some data that is reused in many tests""" 20 super(fgFDMErrorTest, self).
__init__(*args, **kwargs)
23 ex =
fgFDMError(
"Test Exception {0}".format(1))
25 assert ex.message ==
"fgFDMError: Test Exception 1" 29 Class to test fgFDMVariable 32 """Constructor, set up some data that is reused in many tests""" 33 super(fgFDMVariableTest, self).
__init__(*args, **kwargs)
36 """Test the constructor""" 39 assert varry.index == 0
40 assert varry.arraylength == 3
41 assert varry.units ==
'radians' 46 Class to test fgFDMVariableList 49 """Constructor, set up some data that is reused in many tests""" 50 super(fgFDMVariableListTest, self).
__init__(*args, **kwargs)
53 """Test the constructor and adding variables""" 55 mapping.add(
'longitude', units=
'radians')
56 mapping.add(
'stall_warning')
59 assert mapping._nextidx == 6
60 assert mapping.vars[
'longitude'].index == 0
61 assert mapping.vars[
'longitude'].units ==
'radians' 62 assert mapping.vars[
'rpm'].index == 2
63 assert mapping.vars[
'rpm'].units
is None 71 """Constructor, set up some data that is reused in many tests""" 72 super(fgFDMTest, self).
__init__(*args, **kwargs)
75 """Test the constructor""" 78 assert fdm.FG_NET_FDM_VERSION == 24
81 """Test the getting and setting and unit conversion of variables""" 84 fdm.set(
'latitude', 67.4, units=
'degrees')
85 fdm.set(
'longitude', 120.6, units=
'degrees')
86 fdm.set(
'num_engines', 1)
87 fdm.set(
'vcas', 44, units=
'mps')
89 assert fdm.get(
'latitude', units=
'degrees') == 67.4
90 assert round(fdm.get(
'vcas', units=
'knots'), 2) == 85.53
93 """Test the packing and parsing of an fgFDM packet""" 96 fdm.set(
'latitude', 67.4, units=
'degrees')
97 fdm.set(
'longitude', 120.6, units=
'degrees')
98 fdm.set(
'num_engines', 1)
99 fdm.set(
'vcas', 44, units=
'mps')
101 packedBytes = fdm.pack()
104 parsedObj.parse(packedBytes)
106 assert parsedObj.get(
'latitude', units=
'degrees') == 67.4
107 assert round(parsedObj.get(
'vcas', units=
'knots'), 2) == 85.53
109 if __name__ ==
'__main__':
def __init__(self, args, kwargs)
def test_constructor(self)
def __init__(self, args, kwargs)
def test_constructor(self)
def test_constructor(self)
def __init__(self, args, kwargs)
def test_constructor(self)
def __init__(self, args, kwargs)