🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
fixbug: fix unit test
莘权 马51a8691722fa
diff --git a/metagpt/tools/metagpt_oas3_api_svc.py b/metagpt/tools/metagpt_oas3_api_svc.pyindex 319e7efb2..8e9f4a0da 100644--- a/metagpt/tools/metagpt_oas3_api_svc.py+++ b/metagpt/tools/metagpt_oas3_api_svc.py@@ -5,6 +5,12 @@@Author : mashenquan@File : metagpt_oas3_api_svc.py@Desc : MetaGPT OpenAPI Specification 3.0 REST API service++ curl -X 'POST' \+ 'http://localhost:8080/openapi/greeting/dave' \+ -H 'accept: text/plain' \+ -H 'Content-Type: application/json' \+ -d '{}'"""from pathlib import Path@@ -15,7 +21,7 @@ import connexiondef oas_http_svc():"""Start the OAS 3.0 OpenAPI HTTP service"""print("http://localhost:8080/oas3/ui/")- specification_dir = Path(__file__).parent.parent.parent / ".well-known"+ specification_dir = Path(__file__).parent.parent.parent / "docs/.well-known"app = connexion.AsyncApp(__name__, specification_dir=str(specification_dir))app.add_api("metagpt_oas3_api.yaml")app.add_api("openapi.yaml")diff --git a/metagpt/tools/openapi_v3_hello.py b/metagpt/tools/openapi_v3_hello.pyindex c8f5de42d..d1c83eac2 100644--- a/metagpt/tools/openapi_v3_hello.py+++ b/metagpt/tools/openapi_v3_hello.py@@ -23,7 +23,7 @@ async def post_greeting(name: str) -> str:if __name__ == "__main__":- specification_dir = Path(__file__).parent.parent.parent / ".well-known"+ specification_dir = Path(__file__).parent.parent.parent / "docs/.well-known"app = connexion.AsyncApp(__name__, specification_dir=str(specification_dir))app.add_api("openapi.yaml", arguments={"title": "Hello World Example"})app.run(port=8082)diff --git a/tests/metagpt/tools/test_metagpt_oas3_api_svc.py b/tests/metagpt/tools/test_metagpt_oas3_api_svc.pyindex 1135860eb..5f52b28cc 100644--- a/tests/metagpt/tools/test_metagpt_oas3_api_svc.py+++ b/tests/metagpt/tools/test_metagpt_oas3_api_svc.py@@ -24,13 +24,14 @@ async def test_oas2_svc():process = subprocess.Popen(["python", str(script_pathname)], cwd=str(workdir), env=env)await asyncio.sleep(5)- url = "http://localhost:8080/openapi/greeting/dave"- headers = {"accept": "text/plain", "Content-Type": "application/json"}- data = {}- response = requests.post(url, headers=headers, json=data)- assert response.text == "Hello dave\n"-- process.terminate()+ try:+ url = "http://localhost:8080/openapi/greeting/dave"+ headers = {"accept": "text/plain", "Content-Type": "application/json"}+ data = {}+ response = requests.post(url, headers=headers, json=data)+ assert response.text == "Hello dave\n"+ finally:+ process.terminate()if __name__ == "__main__":diff --git a/tests/metagpt/tools/test_openapi_v3_hello.py b/tests/metagpt/tools/test_openapi_v3_hello.pyindex 3f3f79829..5726cf8e0 100644--- a/tests/metagpt/tools/test_openapi_v3_hello.py+++ b/tests/metagpt/tools/test_openapi_v3_hello.py@@ -24,13 +24,14 @@ async def test_hello():process = subprocess.Popen(["python", str(script_pathname)], cwd=workdir, env=env)await asyncio.sleep(5)- url = "http://localhost:8082/openapi/greeting/dave"- headers = {"accept": "text/plain", "Content-Type": "application/json"}- data = {}- response = requests.post(url, headers=headers, json=data)- assert response.text == "Hello dave\n"-- process.terminate()+ try:+ url = "http://localhost:8082/openapi/greeting/dave"+ headers = {"accept": "text/plain", "Content-Type": "application/json"}+ data = {}+ response = requests.post(url, headers=headers, json=data)+ assert response.text == "Hello dave\n"+ finally:+ process.terminate()if __name__ == "__main__":