Updated Python client unit tests.
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<OutputPath>.</OutputPath>
|
<OutputPath>.</OutputPath>
|
||||||
<Name>XPlaneConnect</Name>
|
<Name>XPlaneConnect</Name>
|
||||||
<RootNamespace>XPlaneConnect</RootNamespace>
|
<RootNamespace>XPlaneConnect</RootNamespace>
|
||||||
<InterpreterId>{2af0f10d-7135-4994-9156-5d01c9c11b7e}</InterpreterId>
|
<InterpreterId>{9a7a9026-48c1-4688-9d5d-e5699d47d074}</InterpreterId>
|
||||||
<InterpreterVersion>2.7</InterpreterVersion>
|
<InterpreterVersion>2.7</InterpreterVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
<Folder Include="src\" />
|
<Folder Include="src\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<InterpreterReference Include="{2af0f10d-7135-4994-9156-5d01c9c11b7e}\2.7" />
|
<InterpreterReference Include="{9a7a9026-48c1-4688-9d5d-e5699d47d074}\2.7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ class XPCTests(unittest.TestCase):
|
|||||||
"""Tests the functionality of the XPlaneConnect class."""
|
"""Tests the functionality of the XPlaneConnect class."""
|
||||||
|
|
||||||
def test_init(self):
|
def test_init(self):
|
||||||
xpc = xplaneConnect.XPlaneConnect(49062, "127.0.0.1", 49009)
|
xpc = xplaneConnect.XPlaneConnect()
|
||||||
self.assertTrue(True)
|
self.assertTrue(True)
|
||||||
|
|
||||||
def test_close(self):
|
def test_close(self):
|
||||||
xpc = xplaneConnect.XPlaneConnect(49063, "127.0.0.1", 49009)
|
xpc = xplaneConnect.XPlaneConnect("127.0.0.1", 49009, 49063)
|
||||||
xpc.close()
|
xpc.close()
|
||||||
self.assertIsNone(xpc.socket)
|
self.assertIsNone(xpc.socket)
|
||||||
xpc = xplaneConnect.XPlaneConnect(49063, "127.0.0.1", 49009)
|
xpc = xplaneConnect.XPlaneConnect("127.0.0.1", 49009, 49063)
|
||||||
self.assertTrue(True)
|
self.assertTrue(True)
|
||||||
|
|
||||||
def test_send_read(self):
|
def test_send_read(self):
|
||||||
@@ -23,12 +23,12 @@ class XPCTests(unittest.TestCase):
|
|||||||
test = "\x00\x01\x02\x03\x05"
|
test = "\x00\x01\x02\x03\x05"
|
||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
sender = xplaneConnect.XPlaneConnect(49064, "127.0.0.1", 49063)
|
sender = xplaneConnect.XPlaneConnect("127.0.0.1", 49063, 49064)
|
||||||
receiver = xplaneConnect.XPlaneConnect(49063, "127.0.0.1", 49009)
|
receiver = xplaneConnect.XPlaneConnect("127.0.0.1", 49009, 49063)
|
||||||
|
|
||||||
# Execution
|
# Execution
|
||||||
sender.send_udp(test)
|
sender.sendUDP(test)
|
||||||
buf = receiver.read_udp()
|
buf = receiver.readUDP()
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
sender.close()
|
sender.close()
|
||||||
@@ -39,20 +39,15 @@ class XPCTests(unittest.TestCase):
|
|||||||
self.assertEqual(a, b)
|
self.assertEqual(a, b)
|
||||||
|
|
||||||
def test_request_dref(self):
|
def test_request_dref(self):
|
||||||
# Init
|
|
||||||
dref_array = []
|
|
||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
sender = xplaneConnect.XPlaneConnect(49064, "127.0.0.1", 49009)
|
xpc = xplaneConnect.XPlaneConnect()
|
||||||
dref_array.append("sim/cockpit/switches/gear_handle_status")
|
drefs = ["sim/cockpit/switches/gear_handle_status", "cockpit2/switches/panel_brightness_ratio"]
|
||||||
dref_array.append("cockpit2/switches/panel_brightness_ratio")
|
|
||||||
|
|
||||||
# Execution
|
# Execution
|
||||||
result = sender.request_dref(dref_array)
|
result = xpc.getDREFs(drefs)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
sender.close()
|
xpc.close()
|
||||||
receiver.close()
|
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
self.assertEqual(2, len(result))
|
self.assertEqual(2, len(result))
|
||||||
@@ -60,21 +55,16 @@ class XPCTests(unittest.TestCase):
|
|||||||
self.assertEqual(4, len(result[1]))
|
self.assertEqual(4, len(result[1]))
|
||||||
|
|
||||||
def test_send_dref(self):
|
def test_send_dref(self):
|
||||||
# Init
|
|
||||||
dref_array = []
|
|
||||||
|
|
||||||
# Setup
|
# Setup
|
||||||
sender = xplaneConnect.XPlaneConnect(49066, "127.0.0.1", 49009)
|
xpc = xplaneConnect.XPlaneConnect()
|
||||||
receiver = xplaneConnect.XPlaneConnect(49008, "127.0.0.1", 49009)
|
dref = "sim/cockpit/switches/gear_handle_status"
|
||||||
dref_array.append("sim/cockpit/switches/gear_handle_status")
|
|
||||||
|
|
||||||
# Execution
|
# Execution
|
||||||
sender.send_dref(dref_array[0])
|
sender.sendDREF(dref_array)
|
||||||
result = receiver.request_dref(dref_array)
|
result = receiver.getDREF(dref_array)
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
sender.close()
|
xpc.close();
|
||||||
receiver.close()
|
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
self.assertEqual(1, len(result))
|
self.assertEqual(1, len(result))
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<OutputPath>.</OutputPath>
|
<OutputPath>.</OutputPath>
|
||||||
<Name>Tests</Name>
|
<Name>Tests</Name>
|
||||||
<RootNamespace>Tests</RootNamespace>
|
<RootNamespace>Tests</RootNamespace>
|
||||||
<InterpreterId>{2af0f10d-7135-4994-9156-5d01c9c11b7e}</InterpreterId>
|
<InterpreterId>{9a7a9026-48c1-4688-9d5d-e5699d47d074}</InterpreterId>
|
||||||
<InterpreterVersion>2.7</InterpreterVersion>
|
<InterpreterVersion>2.7</InterpreterVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
<Compile Include="Tests.py" />
|
<Compile Include="Tests.py" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<InterpreterReference Include="{2af0f10d-7135-4994-9156-5d01c9c11b7e}\2.7" />
|
<InterpreterReference Include="{9a7a9026-48c1-4688-9d5d-e5699d47d074}\2.7" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
|
|||||||
Reference in New Issue
Block a user