Updated Python client unit tests.

This commit is contained in:
Jason Watkins
2015-04-27 15:34:33 -07:00
parent 2a874eb514
commit 31095b716b
3 changed files with 20 additions and 30 deletions

View File

@@ -12,7 +12,7 @@
<OutputPath>.</OutputPath>
<Name>XPlaneConnect</Name>
<RootNamespace>XPlaneConnect</RootNamespace>
<InterpreterId>{2af0f10d-7135-4994-9156-5d01c9c11b7e}</InterpreterId>
<InterpreterId>{9a7a9026-48c1-4688-9d5d-e5699d47d074}</InterpreterId>
<InterpreterVersion>2.7</InterpreterVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@@ -30,7 +30,7 @@
<Folder Include="src\" />
</ItemGroup>
<ItemGroup>
<InterpreterReference Include="{2af0f10d-7135-4994-9156-5d01c9c11b7e}\2.7" />
<InterpreterReference Include="{9a7a9026-48c1-4688-9d5d-e5699d47d074}\2.7" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@@ -8,14 +8,14 @@ class XPCTests(unittest.TestCase):
"""Tests the functionality of the XPlaneConnect class."""
def test_init(self):
xpc = xplaneConnect.XPlaneConnect(49062, "127.0.0.1", 49009)
xpc = xplaneConnect.XPlaneConnect()
self.assertTrue(True)
def test_close(self):
xpc = xplaneConnect.XPlaneConnect(49063, "127.0.0.1", 49009)
xpc = xplaneConnect.XPlaneConnect("127.0.0.1", 49009, 49063)
xpc.close()
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)
def test_send_read(self):
@@ -23,12 +23,12 @@ class XPCTests(unittest.TestCase):
test = "\x00\x01\x02\x03\x05"
# Setup
sender = xplaneConnect.XPlaneConnect(49064, "127.0.0.1", 49063)
receiver = xplaneConnect.XPlaneConnect(49063, "127.0.0.1", 49009)
sender = xplaneConnect.XPlaneConnect("127.0.0.1", 49063, 49064)
receiver = xplaneConnect.XPlaneConnect("127.0.0.1", 49009, 49063)
# Execution
sender.send_udp(test)
buf = receiver.read_udp()
sender.sendUDP(test)
buf = receiver.readUDP()
# Cleanup
sender.close()
@@ -39,20 +39,15 @@ class XPCTests(unittest.TestCase):
self.assertEqual(a, b)
def test_request_dref(self):
# Init
dref_array = []
# Setup
sender = xplaneConnect.XPlaneConnect(49064, "127.0.0.1", 49009)
dref_array.append("sim/cockpit/switches/gear_handle_status")
dref_array.append("cockpit2/switches/panel_brightness_ratio")
xpc = xplaneConnect.XPlaneConnect()
drefs = ["sim/cockpit/switches/gear_handle_status", "cockpit2/switches/panel_brightness_ratio"]
# Execution
result = sender.request_dref(dref_array)
result = xpc.getDREFs(drefs)
# Cleanup
sender.close()
receiver.close()
xpc.close()
# Tests
self.assertEqual(2, len(result))
@@ -60,21 +55,16 @@ class XPCTests(unittest.TestCase):
self.assertEqual(4, len(result[1]))
def test_send_dref(self):
# Init
dref_array = []
# Setup
sender = xplaneConnect.XPlaneConnect(49066, "127.0.0.1", 49009)
receiver = xplaneConnect.XPlaneConnect(49008, "127.0.0.1", 49009)
dref_array.append("sim/cockpit/switches/gear_handle_status")
xpc = xplaneConnect.XPlaneConnect()
dref = "sim/cockpit/switches/gear_handle_status"
# Execution
sender.send_dref(dref_array[0])
result = receiver.request_dref(dref_array)
sender.sendDREF(dref_array)
result = receiver.getDREF(dref_array)
# Cleanup
sender.close()
receiver.close()
xpc.close();
# Tests
self.assertEqual(1, len(result))

View File

@@ -12,7 +12,7 @@
<OutputPath>.</OutputPath>
<Name>Tests</Name>
<RootNamespace>Tests</RootNamespace>
<InterpreterId>{2af0f10d-7135-4994-9156-5d01c9c11b7e}</InterpreterId>
<InterpreterId>{9a7a9026-48c1-4688-9d5d-e5699d47d074}</InterpreterId>
<InterpreterVersion>2.7</InterpreterVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@@ -27,7 +27,7 @@
<Compile Include="Tests.py" />
</ItemGroup>
<ItemGroup>
<InterpreterReference Include="{2af0f10d-7135-4994-9156-5d01c9c11b7e}\2.7" />
<InterpreterReference Include="{9a7a9026-48c1-4688-9d5d-e5699d47d074}\2.7" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>