reordered Pope cards in Earthman deck; addressed two pipeline errors concerning card deck via setUp helper
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
63
src/apps/epic/migrations/0016_reorder_earthman_popes.py
Normal file
63
src/apps/epic/migrations/0016_reorder_earthman_popes.py
Normal file
@@ -0,0 +1,63 @@
|
||||
"""
|
||||
Data migration: reorder the five Pope cards.
|
||||
|
||||
New assignment (card number → title):
|
||||
1 → Chancellor 2 → President 3 → Tsar 4 → Chairman 5 → Emperor
|
||||
"""
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
POPE_RENAMES = {
|
||||
1: ("Pope 1: Chancellor", "pope-1-chancellor"),
|
||||
2: ("Pope 2: President", "pope-2-president"),
|
||||
3: ("Pope 3: Tsar", "pope-3-tsar"),
|
||||
4: ("Pope 4: Chairman", "pope-4-chairman"),
|
||||
5: ("Pope 5: Emperor", "pope-5-emperor"),
|
||||
}
|
||||
|
||||
POPE_ORIGINALS = {
|
||||
1: ("Pope 1: President", "pope-1-president"),
|
||||
2: ("Pope 2: Tsar", "pope-2-tsar"),
|
||||
3: ("Pope 3: Chairman", "pope-3-chairman"),
|
||||
4: ("Pope 4: Emperor", "pope-4-emperor"),
|
||||
5: ("Pope 5: Chancellor", "pope-5-chancellor"),
|
||||
}
|
||||
|
||||
|
||||
def rename_forward(apps, schema_editor):
|
||||
TarotCard = apps.get_model("epic", "TarotCard")
|
||||
DeckVariant = apps.get_model("epic", "DeckVariant")
|
||||
|
||||
earthman = DeckVariant.objects.filter(slug="earthman").first()
|
||||
if not earthman:
|
||||
return
|
||||
|
||||
for number, (new_name, new_slug) in POPE_RENAMES.items():
|
||||
TarotCard.objects.filter(
|
||||
deck_variant=earthman, arcana="MAJOR", number=number
|
||||
).update(name=new_name, slug=new_slug)
|
||||
|
||||
|
||||
def rename_reverse(apps, schema_editor):
|
||||
TarotCard = apps.get_model("epic", "TarotCard")
|
||||
DeckVariant = apps.get_model("epic", "DeckVariant")
|
||||
|
||||
earthman = DeckVariant.objects.filter(slug="earthman").first()
|
||||
if not earthman:
|
||||
return
|
||||
|
||||
for number, (old_name, old_slug) in POPE_ORIGINALS.items():
|
||||
TarotCard.objects.filter(
|
||||
deck_variant=earthman, arcana="MAJOR", number=number
|
||||
).update(name=old_name, slug=old_slug)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("epic", "0015_rename_classical_element_earth_to_stone"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(rename_forward, reverse_code=rename_reverse),
|
||||
]
|
||||
@@ -3,7 +3,7 @@ from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
from .base import FunctionalTest
|
||||
from apps.epic.models import Room
|
||||
from apps.epic.models import DeckVariant, Room
|
||||
from apps.lyric.models import Token, User
|
||||
|
||||
|
||||
@@ -12,8 +12,15 @@ class GameKitTest(FunctionalTest):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.earthman, _ = DeckVariant.objects.get_or_create(
|
||||
slug="earthman",
|
||||
defaults={"name": "Earthman Deck", "card_count": 108, "is_default": True},
|
||||
)
|
||||
self.create_pre_authenticated_session("gamer@kit.io")
|
||||
self.gamer = User.objects.get(email="gamer@kit.io")
|
||||
self.gamer.equipped_deck = self.earthman
|
||||
self.gamer.save(update_fields=["equipped_deck"])
|
||||
self.gamer.unlocked_decks.add(self.earthman)
|
||||
self.token = self.gamer.tokens.filter(token_type=Token.COIN).first()
|
||||
self.room = Room.objects.create(name="Kit Room", owner=self.gamer)
|
||||
self.gate_url = self.live_server_url + f"/gameboard/room/{self.room.id}/gate/"
|
||||
|
||||
Reference in New Issue
Block a user