@@ -156,7 +156,7 @@ def side_effect(*args, **kwargs):
156156 nonlocal call_count
157157 call_count += 1
158158 payload = kwargs .get ("payload" ) or args [0 ] if args else None
159-
159+
160160 if payload == "XQ" :
161161 return None
162162 if payload == "V" :
@@ -165,7 +165,8 @@ def side_effect(*args, **kwargs):
165165 return "V 3.5.0-dev SIGNALduino"
166166 return None
167167
168- controller .send_command = Mock (side_effect = side_effect )
168+ mocked_send_command = Mock (side_effect = side_effect )
169+ controller .commands ._send = mocked_send_command
169170
170171 # Use very short intervals for testing by patching the imported constants in the controller module
171172 import signalduino .controller
@@ -178,7 +179,7 @@ def side_effect(*args, **kwargs):
178179
179180 try :
180181 controller .initialize ()
181- time .sleep (1.5 ) # Wait for timers and retries
182+ time .sleep (3.0 ) # Wait for timers and retries (increased from 1.5s due to potential race condition)
182183
183184 # Verify calls:
184185 # 1. XQ
@@ -189,7 +190,8 @@ def side_effect(*args, **kwargs):
189190 # Note: Depending on timing and implementation details, call count might vary slighty
190191 # but we expect at least XQ, failed V, successful V, XE.
191192
192- calls = [c .kwargs .get ('payload' ) or c .args [0 ] for c in controller .send_command .call_args_list ]
193+ calls = [c .kwargs .get ('payload' ) or c .args [0 ] for c in mocked_send_command .call_args_list ]
194+
193195 assert "XQ" in calls
194196 assert calls .count ("V" ) >= 2
195197 assert "XE" in calls
0 commit comments