Skip to content

πŸ™Œ OpenHands: AI-Driven Development

remove useless mock test code (#3335)

Yufan Songda5bf6c1bfe7
diff --git a/opendevin/runtime/client/mock_test/client.py b/opendevin/runtime/client/mock_test/client.py
deleted file mode 100644
index 19a5a60f19..0000000000
--- a/opendevin/runtime/client/mock_test/client.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# client.py, this file is used in development to test the runtime client. It is not used in production.
-import asyncio
-import websockets
-
-# Function for sending commands to the server in EventStreamRuntime
-class EventStreamRuntime:
- uri = 'ws://localhost:8080'
-
- def __init__(self):
- self.websocket = None
-
- def _init_websocket(self):
- self.websocket = None
- # TODO: need to initialization globally only once
- # self.loop = asyncio.new_event_loop()
- # asyncio.set_event_loop(self.loop)
- # self.loop.run_until_complete(self._init_websocket_connect())
-
- async def execute(self, command):
- self.websocket = await websockets.connect(self.uri)
-
- print(f"Sending command: {command}")
- await self.websocket.send(command)
- print("Command sent, waiting for response...")
- try:
- output = await asyncio.wait_for(self.websocket.recv(), timeout=10)
- print("Received output")
- print(output)
- except asyncio.TimeoutError:
- print("No response received within the timeout period.")
-
- await self.websocket.close()
-
-# Function for testing sending commands to the server
-async def send_command():
- uri = "ws://localhost:8080"
- while True:
- try:
- async with websockets.connect(uri) as websocket:
- while True:
- command = input("Enter the command to execute in the Docker container (type 'exit' to quit): ")
- if command.lower() == 'exit':
- return
- await websocket.send(command)
- response = await websocket.recv()
- exit_code = response[-1].strip()\
- # command_output = '\n'.join(response[1:-1]).strip()
- # print("Yufan:", command_output)
- print("Exit Code:", exit_code)
- print(response)
- except (websockets.exceptions.ConnectionClosed, OSError) as e:
- print(f"Connection closed, retrying... ({str(e)})")
- await asyncio.sleep(1)
-
-if __name__ == "__main__":
- asyncio.run(send_command())
-
-
-# if __name__ == "__main__":
-# runtime = EventStreamRuntime()
-# asyncio.run(runtime.execute('ls -l'))
-# asyncio.run(runtime.execute('pwd'))
\ No newline at end of file
diff --git a/opendevin/runtime/client/mock_test/echo_server.py b/opendevin/runtime/client/mock_test/echo_server.py
deleted file mode 100644
index 5108f57093..0000000000
--- a/opendevin/runtime/client/mock_test/echo_server.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# echo_server.py, this file is used in development to test the runtime client. It is not used in production.
-import asyncio
-import websockets
-import pexpect
-from websockets.exceptions import ConnectionClosed
-import json
-
-def is_valid_json(s):
- try:
- json.loads(s)
- except json.JSONDecodeError:
- return False
- return True
-
-# Function for testing websocket echo
-async def echo(websocket, path):
- async for message in websocket:
- if is_valid_json(message):
- event = json.loads(message)
- print("Received:", event)
- response = json.dumps(event)
- await websocket.send(response)
- else:
- print("Received:", message)
- response = f"Echo: {message}"
- await websocket.send(response)
-
-start_server = websockets.serve(echo, "0.0.0.0", 8080)
-
-asyncio.get_event_loop().run_until_complete(start_server)
-asyncio.get_event_loop().run_forever()
diff --git a/opendevin/runtime/client/mock_test/execute_server.py b/opendevin/runtime/client/mock_test/execute_server.py
deleted file mode 100644
index e7bfbab110..0000000000
--- a/opendevin/runtime/client/mock_test/execute_server.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# execute_server.py, this file is used in development to test the runtime client. It is not used in production.
-import asyncio
-import websockets
-import pexpect
-from websockets.exceptions import ConnectionClosed
-import json
-
-# Function for testing execution of shell commands
-async def execute_command(websocket, path):
- shell = pexpect.spawn('/bin/bash', encoding='utf-8')
- shell.expect(r'[$#] ')
-
- try:
- async for message in websocket:
- try:
- print(f"Received command: {message}")
- shell.sendline(message)
- shell.expect(r'[$#] ')
- output = shell.before.strip().split('\r\n', 1)[1].strip()
- print("Yufan:",output)
- await websocket.send(output)
- except Exception as e:
- await websocket.send(f"Error: {str(e)}")
- except ConnectionClosed:
- print("Connection closed")
- finally:
- shell.close()
-
-
-start_server = websockets.serve(execute_command, "0.0.0.0", 8080)
-
-asyncio.get_event_loop().run_until_complete(start_server)
-asyncio.get_event_loop().run_forever()