From fa4c0340fd5c44569871ebcb722a292aff67ba11 Mon Sep 17 00:00:00 2001 From: bridge Date: Sun, 11 Jan 2026 22:48:05 +0800 Subject: [PATCH] fix pytest --- tests/test_init_status_api.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/tests/test_init_status_api.py b/tests/test_init_status_api.py index b47c23b..44433aa 100644 --- a/tests/test_init_status_api.py +++ b/tests/test_init_status_api.py @@ -155,12 +155,19 @@ class TestUpdateInitProgress: class TestNewGameEndpoint: - """Tests for /api/game/new endpoint.""" + """Tests for /api/game/start endpoint.""" def test_new_game_starts_initialization(self, client, reset_game_instance): - """Test /api/game/new starts initialization process.""" + """Test /api/game/start starts initialization process.""" with patch.object(main, 'init_game_async', new_callable=AsyncMock) as mock_init: - response = client.post("/api/game/new") + # Prepare minimal valid request data + payload = { + "init_npc_num": 10, + "sect_num": 2, + "protagonist": "none", + "npc_awakening_rate_per_month": 0.01 + } + response = client.post("/api/game/start", json=payload) assert response.status_code == 200 data = response.json() @@ -169,16 +176,22 @@ class TestNewGameEndpoint: assert game_instance["init_status"] == "pending" def test_new_game_rejects_when_in_progress(self, client, reset_game_instance): - """Test /api/game/new rejects request when already initializing.""" + """Test /api/game/start rejects request when already initializing.""" game_instance["init_status"] = "in_progress" - response = client.post("/api/game/new") + payload = { + "init_npc_num": 10, + "sect_num": 2, + "protagonist": "none", + "npc_awakening_rate_per_month": 0.01 + } + response = client.post("/api/game/start", json=payload) assert response.status_code == 400 assert "already initializing" in response.json()["detail"].lower() def test_new_game_clears_existing_state(self, client, reset_game_instance): - """Test /api/game/new clears existing game state when ready.""" + """Test /api/game/start clears existing game state when ready.""" mock_world = MagicMock() mock_sim = MagicMock() game_instance["world"] = mock_world @@ -186,7 +199,13 @@ class TestNewGameEndpoint: game_instance["init_status"] = "ready" with patch.object(main, 'init_game_async', new_callable=AsyncMock): - response = client.post("/api/game/new") + payload = { + "init_npc_num": 10, + "sect_num": 2, + "protagonist": "none", + "npc_awakening_rate_per_month": 0.01 + } + response = client.post("/api/game/start", json=payload) assert response.status_code == 200 assert game_instance["world"] is None