From ae5aff687987daf4e24a46fbcf9e12b448b10f5a Mon Sep 17 00:00:00 2001 From: Bedram Tamang Date: Tue, 23 Jun 2026 22:45:38 -0700 Subject: [PATCH] test(agents): use unittest assertions in example feature tests Convert bare assert statements to self.assertEqual in the example/agents feature tests, matching the unittest.IsolatedAsyncioTestCase base. Keep the async test methods and the @ChatAgent.fake / @ChatAgent.record decorators intact. --- .../tests/features/test_chat_controller.py | 25 +++++++++++++++++++ .../tests/features/test_home_controller.py | 8 ++++++ 2 files changed, 33 insertions(+) create mode 100644 example/agents/tests/features/test_home_controller.py diff --git a/example/agents/tests/features/test_chat_controller.py b/example/agents/tests/features/test_chat_controller.py index e69de29b..39f46ca6 100644 --- a/example/agents/tests/features/test_chat_controller.py +++ b/example/agents/tests/features/test_chat_controller.py @@ -0,0 +1,25 @@ +from app.agents.chat import ChatAgent + +from tests.test_case import TestCase + + +class TestChatController(TestCase): + @ChatAgent.fake({"*hello*": "Hello there!, Hope you are doing well."}) + async def test_chat_responds_for_basic_greetings(self): + response = await self.post("/chat", json={"message": "hello"}) + + self.assertEqual(response.status_code, 200) + self.assertEqual( + response.json(), {"content": "Hello there!, Hope you are doing well."} + ) + + @ChatAgent.record('other_greetings.json') + async def test_chat_responds_for_other_greetings(self): + response = await self.post("/chat", json={ + "message": "Hi, I am Bedram, This is unittest, Please respond by calling my name." + }) + + self.assertEqual(response.status_code, 200) + self.assertEqual( + response.json(), {"content": "Hello there!, Hope you are doing well."} + ) diff --git a/example/agents/tests/features/test_home_controller.py b/example/agents/tests/features/test_home_controller.py new file mode 100644 index 00000000..43c66662 --- /dev/null +++ b/example/agents/tests/features/test_home_controller.py @@ -0,0 +1,8 @@ +from tests.test_case import TestCase + + +class TestHomeController(TestCase): + async def test_home(self) -> None: + response = await self.get("/") + + self.assertEqual(response.status_code, 200)