role select channels FTs: get_or_create DeckVariant in _equip_earthman_deck — fixes CI flush wipe
TransactionTestCase.flush() wipes all rows (incl. migration-seeded DeckVariants) after every test. Landscape runs first (alphabetically), consumes the seeded deck, then flush removes it. Subsequent tests called filter().first() → None → silently skipped → data-equipped-deck="" → JS no-deck warning instead of opening fan. Code architected by Disco DeDisco <discodedisco@outlook.com> Git commit message Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,9 +14,12 @@ from apps.lyric.models import User
|
|||||||
|
|
||||||
|
|
||||||
def _equip_earthman_deck(user):
|
def _equip_earthman_deck(user):
|
||||||
"""Equip the Earthman DeckVariant so the role-select no-deck guard passes."""
|
# get_or_create: TransactionTestCase.flush() wipes migration-seeded DeckVariants
|
||||||
deck = DeckVariant.objects.filter(name__icontains="Earthman").first()
|
# between tests, so subsequent tests in the same run can't find it via filter().
|
||||||
if deck:
|
deck, _ = DeckVariant.objects.get_or_create(
|
||||||
|
slug="earthman",
|
||||||
|
defaults={"name": "Earthman", "card_count": 106, "is_default": True},
|
||||||
|
)
|
||||||
user.equipped_deck = deck
|
user.equipped_deck = deck
|
||||||
user.save(update_fields=["equipped_deck"])
|
user.save(update_fields=["equipped_deck"])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user