Correct the one-controller claim: the drone takes over, it does not refuse
Tested on the aircraft. A second ARSDK handshake is accepted and telemetry is redirected to it; the first session's frames stop while it still reports connected = True. So the claim inherited from pyparrot's error text, which had reached our error messages, tool descriptions, simulator behaviour and a test name, was wrong in the most misleading direction: a refusal would be loud, and this is silent. The simulator now models the takeover by default; refusal stays available because a client must handle a non-zero status anyway.
This commit is contained in:
+31
-2
@@ -74,6 +74,16 @@ def sim():
|
||||
yield fake
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sim_factory():
|
||||
"""For tests that need the refusing simulator rather than the default.
|
||||
|
||||
The default models the aircraft: a second controller is accepted and the
|
||||
first is starved. Refusal is the opt-in mode.
|
||||
"""
|
||||
return FakeBebop
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def controller(sim):
|
||||
client = Controller(sim)
|
||||
@@ -165,15 +175,34 @@ def test_handshake_is_accepted_and_names_a_c2d_port(sim, controller):
|
||||
assert sim.handshakes[0]["controller_name"] == "test"
|
||||
|
||||
|
||||
def test_a_second_controller_is_refused(sim, controller):
|
||||
def test_a_second_controller_is_accepted_by_default(sim, controller):
|
||||
"""Matching the aircraft, which accepts a newcomer and starves the first.
|
||||
|
||||
Tested on the real drone 2026-10-02. The refusal this test used to assert
|
||||
was folklore inherited from pyparrot's error text.
|
||||
"""
|
||||
second = Controller(sim)
|
||||
try:
|
||||
assert second.reply["status"] == 1
|
||||
assert second.reply["status"] == 0
|
||||
finally:
|
||||
second.close()
|
||||
|
||||
|
||||
def test_a_second_controller_can_be_refused_when_asked(sim_factory):
|
||||
"""Kept because a client must still handle a non-zero status."""
|
||||
with sim_factory(single_controller=True) as strict:
|
||||
first = Controller(strict)
|
||||
second = Controller(strict)
|
||||
try:
|
||||
assert first.reply["status"] == 0
|
||||
assert second.reply["status"] == 1
|
||||
finally:
|
||||
second.close()
|
||||
first.close()
|
||||
|
||||
|
||||
def test_the_slot_is_free_again_after_release(sim, controller):
|
||||
"""Only meaningful in the strict mode; the default never withholds a slot."""
|
||||
assert sim.occupied
|
||||
sim.release()
|
||||
third = Controller(sim)
|
||||
|
||||
Reference in New Issue
Block a user