/
Mihaham
/
Table-Time
Обзор
Документация
Войти
/
Mihaham
/
Table-Time
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
services/api/tests/test_game_errors.py
67 строк
2 KB
MihahamYT
feat: games catalog, 90%+ test coverage, MkDocs ready for GitVerse
14 июн 2026, 10:45
14 июн 2026, 10:45
03c79f9
Код
Авторство
О чём код?
import uuid from tests.conftest import auth_header, guest_auth def _start_game(client): token1, _ = guest_auth(client, "Host") created = client.post( "/api/v1/sessions", json={"display_name": "Host", "max_players": 4}, headers=auth_header(token1), ) code = created.json()["invite_code"] session_id = created.json()["id"] token2, _ = guest_auth(client, "P2") client.post( "/api/v1/sessions/join", json={"invite_code": code, "channel": "web", "display_name": "P2"}, headers=auth_header(token2), ) started = client.post( f"/api/v1/sessions/{session_id}/games", json={"plugin_id": "dice_board"}, headers=auth_header(token1), ) return started.json()["game_id"], token1, token2 def test_wrong_phase_action(client): game_id, token1, token2 = _start_game(client) client.post( f"/api/v1/games/{game_id}/actions", json={"action_id": str(uuid.uuid4()), "action_type": "roll_dice", "payload": {}}, headers={**auth_header(token1), "X-Channel": "web"}, ) r = client.post( f"/api/v1/games/{game_id}/actions", json={"action_id": str(uuid.uuid4()), "action_type": "roll_dice", "payload": {}}, headers={**auth_header(token1), "X-Channel": "web"}, ) assert r.status_code == 409 r2 = client.post( f"/api/v1/games/{game_id}/actions", json={"action_id": str(uuid.uuid4()), "action_type": "roll_dice", "payload": {}}, headers={**auth_header(token2), "X-Channel": "web"}, ) assert r2.status_code == 409 def test_invalid_cell_action(client): game_id, token1, _ = _start_game(client) client.post( f"/api/v1/games/{game_id}/actions", json={"action_id": str(uuid.uuid4()), "action_type": "roll_dice", "payload": {}}, headers={**auth_header(token1), "X-Channel": "web"}, ) r = client.post( f"/api/v1/games/{game_id}/actions", json={ "action_id": str(uuid.uuid4()), "action_type": "choose_cell", "payload": {"row": 6, "col": 6}, }, headers={**auth_header(token1), "X-Channel": "web"}, ) assert r.status_code in (400, 409)