Add staging gameplay smoke artifact output
This commit is contained in:
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user