/
Mihaham
/
Table-Time
Обзор
Документация
Войти
/
Mihaham
/
Table-Time
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
services/api/tests/test_tabletime_clock.py
81 строка
2 KB
MihahamYT
feat: full game catalog — 46 plugins, docs nav, web UI kit
14 июн 2026, 12:43
14 июн 2026, 12:43
2cd5f50
Код
Авторство
О чём код?
import pytest from app.plugins.tabletime_clock.plugin import TabletimeClockPlugin @pytest.fixture def plugin(): return TabletimeClockPlugin() @pytest.fixture def state(plugin): return plugin.initial_state(["p1", "p2"], {"p1": "A", "p2": "B"}, {"seed": 42}) def test_initial_state(plugin): s = plugin.initial_state(["p1", "p2"], {"p1": "A", "p2": "B"}, {"seed": 42}) assert s.get("phase") != "GameOver" assert "player_names" in s def test_unknown_action(plugin, state): v = plugin.validate_action(state, "bad_action", {}, "p1") assert not v.ok assert v.error_code == "UNKNOWN_ACTION" def test_game_finished_blocks(plugin, state): state["phase"] = "GameOver" state["winner_id"] = "p1" v = plugin.validate_action(state, "noop", {}, "p1") assert not v.ok assert v.error_code == "GAME_FINISHED" def test_is_finished_false_at_start(plugin, state): assert not plugin.is_finished(state) def test_get_winner_none_at_start(plugin, state): assert plugin.get_winner(state) is None def test_render_web(plugin, state): vm = plugin.render_web(state, {"p1": "A", "p2": "B"}, "p1") assert vm.phase == state.get("phase", "") def test_render_web_opponent(plugin, state): vm = plugin.render_web(state, {"p1": "A", "p2": "B"}, "p2") assert vm is not None def test_render_telegram(plugin, state): tg = plugin.render_telegram(state, {"p1": "A", "p2": "B"}) assert tg.caption def test_allowed_actions_viewer(plugin, state): acts = plugin.allowed_actions(state, "p1") assert isinstance(acts, list) def test_get_current_player(plugin, state): cp = plugin.get_current_player(state) assert cp is None or isinstance(cp, str) def test_buzz_valid(plugin, state): v = plugin.validate_action(state, "buzz", {"answer": "арбуз"}, "p1") assert v.ok def test_buzz_starts_judging(plugin, state): ns = plugin.apply_action(state, "buzz", {"answer": "a"}, "p1") ns = plugin.apply_action(ns, "buzz", {"answer": "b"}, "p2") assert ns["phase"] == "Judging" def test_judge_accept_wins(plugin, state): state["phase"] = "Judging" state["buzzes"] = [{"player_id": "p1", "answer": "x", "accepted": None}] state["scores"] = {"p1": 2, "p2": 0} ns = plugin.apply_action(state, "judge_buzz", {"index": 0, "accepted": True}, "p1") assert ns.get("winner_id") == "p1"