Add staging gameplay smoke artifact output
All checks were successful
CI / test-and-quality (pull_request) Successful in 2m2s
CI / test-and-quality (push) Successful in 2m8s

This commit is contained in:
2026-03-01 06:39:51 +00:00
parent 046212d29a
commit b782f73f49
4 changed files with 73 additions and 2 deletions

View File

@@ -1,4 +1,7 @@
import json
import tempfile
from datetime import timedelta
from pathlib import Path
from django.contrib.auth import get_user_model
from django.core.management import call_command
@@ -972,3 +975,31 @@ class SmokeStagingCommandTests(TestCase):
session = GameSession.objects.latest("created_at")
self.assertEqual(session.status, GameSession.Status.FINISHED)
self.assertEqual(Player.objects.filter(session=session).count(), 3)
def test_smoke_staging_writes_artifact_when_requested(self):
with tempfile.TemporaryDirectory() as tmp_dir:
artifact_path = Path(tmp_dir) / "smoke.json"
call_command("smoke_staging", artifact=str(artifact_path))
self.assertTrue(artifact_path.exists())
payload = json.loads(artifact_path.read_text(encoding="utf-8"))
self.assertTrue(payload["ok"])
self.assertEqual(payload["command"], "smoke_staging")
self.assertEqual(payload["players"], ["P1", "P2", "P3"])
self.assertIn("generated_at", payload)
self.assertIn("session_code", payload)
self.assertEqual(
payload["steps"],
[
"create_session",
"join_players",
"start_round",
"show_question",
"submit_lies",
"mix_answers",
"submit_guesses",
"calculate_scores",
"reveal_scoreboard",
"finish_game",
],
)