Skip to content

Commit

Permalink
Add Ctrls integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julianneswinoga committed Jan 1, 2024
1 parent 639d211 commit 0f3049c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_integration_FG_Ctrls.py
@@ -0,0 +1,36 @@
import pytest

from flightgear_python.fg_if import CtrlsConnection


pytestmark = pytest.mark.fg_integration
ctrls_version = 27 # FlightGear-2020.3.19-x86_64.AppImage


def test_ctrls_rx_and_tx_integration():
def rx_cb(ctrls_data, event_pipe):
(run_idx,) = event_pipe.child_recv()
child_callback_version = ctrls_data['version']
event_pipe.child_send(
(
run_idx,
child_callback_version,
)
)
return ctrls_data

ctrls_c = CtrlsConnection(ctrls_version)
ctrls_c.connect_rx('localhost', 5503, rx_cb)
ctrls_c.connect_tx('localhost', 5504)

for i in range(10):
ctrls_c.event_pipe.parent_send((i,))
# manually call the process instead of having the process spawn
ctrls_c._fg_packet_roundtrip()
run_idx, parent_callback_version = ctrls_c.event_pipe.parent_recv()
assert run_idx == i
assert parent_callback_version == ctrls_version

# Prevent 'ResourceWarning: unclosed' warning
ctrls_c.fg_rx_sock.close()
ctrls_c.fg_tx_sock.close()

0 comments on commit 0f3049c

Please sign in to comment.