SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Issue #357: How to easily test flask API? (#615)
Anish Karthik2b32e23f1b4a
diff --git a/tests/test_server.py b/tests/test_server.pynew file mode 100644index 00000000..304fcfcd--- /dev/null+++ b/tests/test_server.py@@ -0,0 +1,39 @@+from __future__ import annotations++import pytest+from flask_socketio import SocketIOTestClient++from sweagent.api.server import app, socketio+++def client():+ with app.test_client() as client:+ with app.app_context():+ yield client+++def socket_client():+ client = SocketIOTestClient(app, socketio)+ yield client+ client.disconnect()+++def test_index(client):+ """Test the index page"""+ response = client.get("/")+ assert response.status_code == 200+++def test_run_options(client):+ """Test the /run endpoint OPTIONS method for CORS preflight"""+ response = client.open("/run", method="OPTIONS")+ assert response.status_code == 200+ assert response.headers["Access-Control-Allow-Origin"] == "*"+++def test_stop(client):+ """Test the /stop endpoint"""+ response = client.get("/stop")+ assert response.status_code == 202