new DRAMA & BILLBOARD apps to start provenance system; new billboard.html & _scroll.html templates; admin area now displays game event log; new CLAUDE.md file to free up Claude Code's memory.md space; minor additions to apps.epic.views to ensure new systems just described adhere to existing game views
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
44
src/apps/drama/tests/unit/test_models.py
Normal file
44
src/apps/drama/tests/unit/test_models.py
Normal file
@@ -0,0 +1,44 @@
|
||||
from django.test import TestCase
|
||||
|
||||
from apps.drama.models import GameEvent, record
|
||||
from apps.epic.models import Room
|
||||
from apps.lyric.models import User
|
||||
|
||||
|
||||
class GameEventModelTest(TestCase):
|
||||
def setUp(self):
|
||||
self.user = User.objects.create(email="actor@test.io")
|
||||
self.room = Room.objects.create(name="Test Room", owner=self.user)
|
||||
|
||||
def test_record_creates_game_event(self):
|
||||
event = record(self.room, GameEvent.SLOT_FILLED, actor=self.user, slot_number=1, token_type="tithe")
|
||||
self.assertEqual(GameEvent.objects.count(), 1)
|
||||
self.assertEqual(event.room, self.room)
|
||||
self.assertEqual(event.actor, self.user)
|
||||
self.assertEqual(event.verb, GameEvent.SLOT_FILLED)
|
||||
self.assertEqual(event.data, {"slot_number": 1, "token_type": "tithe"})
|
||||
|
||||
def test_record_without_actor(self):
|
||||
event = record(self.room, GameEvent.ROOM_CREATED)
|
||||
self.assertIsNone(event.actor)
|
||||
self.assertEqual(event.verb, GameEvent.ROOM_CREATED)
|
||||
|
||||
def test_events_ordered_by_timestamp(self):
|
||||
record(self.room, GameEvent.ROOM_CREATED)
|
||||
record(self.room, GameEvent.SLOT_RESERVED, actor=self.user)
|
||||
record(self.room, GameEvent.SLOT_FILLED, actor=self.user)
|
||||
verbs = list(GameEvent.objects.values_list("verb", flat=True))
|
||||
self.assertEqual(verbs, [
|
||||
GameEvent.ROOM_CREATED,
|
||||
GameEvent.SLOT_RESERVED,
|
||||
GameEvent.SLOT_FILLED,
|
||||
])
|
||||
|
||||
def test_str_includes_actor_and_verb(self):
|
||||
event = record(self.room, GameEvent.ROLE_SELECTED, actor=self.user, role="PC")
|
||||
self.assertIn("actor@test.io", str(event))
|
||||
self.assertIn(GameEvent.ROLE_SELECTED, str(event))
|
||||
|
||||
def test_str_without_actor_shows_system(self):
|
||||
event = record(self.room, GameEvent.ROLES_REVEALED)
|
||||
self.assertIn("system", str(event))
|
||||
Reference in New Issue
Block a user