77
88
99class DummyServer :
10- """A dummy server to simulate server behavior for testing purposes."""
10+ def __init__ (self , host , port , loglevel ):
11+ self .host = host
12+ self .port = port
13+ self .loglevel = loglevel
1114
12- def __init__ (self , port , update_callback ):
13- """
14- Initialize the DummyServer with a port and update callback.
15+ def set_fn_new_client (self , fn ):
16+ pass
1517
16- Args:
17- port (int): The port number for the dummy server.
18- update_callback (callable): The callback function for updates.
19- """
20- self .port = port
21- self .update_callback = update_callback
22- self .started = False
18+ def set_fn_client_left (self , fn ):
19+ pass
2320
24- def start (self ):
25- """Simulate starting the dummy server."""
26- self .started = True
21+ def set_fn_message_received (self , fn ):
22+ pass
2723
28- def stop (self ):
29- """Simulate stopping the dummy server."""
30- self .started = False
24+ def deny_new_connections (self ):
25+ pass
26+
27+ def allow_new_connections (self ):
28+ pass
29+
30+ def send_message (self , client , message ):
31+ pass
32+
33+ def run_forever (self , threaded = True ):
34+ pass
35+
36+ def shutdown_gracefully (self ):
37+ pass
3138
3239
3340class DummyConsumer :
@@ -60,6 +67,8 @@ def stop(self):
6067def manager (monkeypatch ):
6168 """Fixture to provide a Manager instance with patched dependencies for testing."""
6269
70+ monkeypatch .setattr ("manager.comms.websocket_server.WebsocketServer" , DummyServer )
71+
6372 # Patch subprocess.check_output for ROS_DISTRO and IMAGE_TAG
6473 def fake_check_output (cmd , * a , ** k ):
6574 if "ROS_DISTRO" in cmd [- 1 ]:
@@ -76,11 +85,10 @@ def fake_check_output(cmd, *a, **k):
7685 )
7786
7887 def dummy_run (self , start_pose = None ):
79- print (' run around' )
88+ print (" run around" )
8089
8190 monkeypatch .setattr (
82- "manager.manager.launcher.launcher_robot.LauncherRobot.run" ,
83- dummy_run
91+ "manager.manager.launcher.launcher_robot.LauncherRobot.run" , dummy_run
8492 )
8593
8694 # Patch os.makedirs and os.path.isdir to avoid real FS operations
0 commit comments