(client: TestClient)
| 22 | |
| 23 | |
| 24 | def test_challenge_lifecycle(client: TestClient) -> None: |
| 25 | me = client.get("/api/me").json()["participant"] |
| 26 | assert me["id"].startswith("p_") |
| 27 | |
| 28 | created = client.post( |
| 29 | "/api/challenges", |
| 30 | json={ |
| 31 | "name": "点亮测试公园", |
| 32 | "place_name": "测试公园", |
| 33 | "center_lat": 39.9042, |
| 34 | "center_lng": 116.4074, |
| 35 | "radius_m": 300, |
| 36 | "duration_hours": 24, |
| 37 | "h3_resolution": 10, |
| 38 | }, |
| 39 | ).json()["challenge"] |
| 40 | assert created["stats"]["total_cells"] > 0 |
| 41 | |
| 42 | detail = client.get(f"/api/challenges/{created['id']}").json() |
| 43 | first_cell = detail["cells"][0] |
| 44 | unlock = client.post( |
| 45 | f"/api/challenges/{created['id']}/unlock", |
| 46 | json={"cell_ids": [first_cell["cell_id"]], "source": "test"}, |
| 47 | ).json() |
| 48 | assert unlock["inserted"] == 1 |
| 49 | assert unlock["stats"]["unlocked_cells"] == 1 |
| 50 | |
| 51 | duplicate = client.post( |
| 52 | f"/api/challenges/{created['id']}/unlock", |
| 53 | json={"cell_ids": [first_cell["cell_id"]], "source": "test"}, |
| 54 | ).json() |
| 55 | assert duplicate["inserted"] == 0 |
| 56 | |
| 57 | leaderboard = client.get(f"/api/challenges/{created['id']}/leaderboard").json() |
| 58 | assert leaderboard["leaderboard"][0]["unlocked_cells"] == 1 |
| 59 | |
| 60 | |
| 61 | def test_position_filters(client: TestClient) -> None: |
nothing calls this directly
no outgoing calls
no test coverage detected