Fix friend_code max length issues in tests, and fix in_game_name length issues, also update tests to fit more scenarios
This commit is contained in:
parent
0d4655bf80
commit
b9c4d7a61d
10 changed files with 558 additions and 66 deletions
|
|
@ -36,16 +36,18 @@ class Deck(models.Model):
|
|||
|
||||
class Card(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
name = models.CharField(max_length=128)
|
||||
name = models.CharField(max_length=64)
|
||||
decks = models.ManyToManyField("Deck")
|
||||
cardset = models.CharField(max_length=8)
|
||||
cardset = models.CharField(max_length=32)
|
||||
cardnum = models.IntegerField()
|
||||
style = models.CharField(max_length=255, null=False)
|
||||
rarity_icon = models.CharField(max_length=8)
|
||||
style = models.CharField(max_length=16)
|
||||
rarity_icon = models.CharField(max_length=12)
|
||||
rarity_level = models.IntegerField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('cardset', 'cardnum')
|
||||
|
||||
def __str__(self):
|
||||
# For display, we show the original rarity icons.
|
||||
return f"{self.name} {self.rarity_icon} {self.cardset}"
|
||||
return f"{self.name} ({self.cardset} #{self.cardnum})"
|
||||
|
|
@ -9,6 +9,7 @@ from accounts.models import CustomUser, FriendCode
|
|||
from cards.models import Card, Deck, DeckNameTranslation, CardNameTranslation
|
||||
from trades.models import TradeOffer, TradeOfferHaveCard, TradeOfferWantCard
|
||||
from cards.templatetags import card_badge, card_multiselect
|
||||
from tests.utils.rarity import RARITY_MAPPING
|
||||
|
||||
class CardsModelsTests(TestCase):
|
||||
def setUp(self):
|
||||
|
|
@ -19,15 +20,15 @@ class CardsModelsTests(TestCase):
|
|||
name="Test Card",
|
||||
cardset="A",
|
||||
cardnum=1,
|
||||
style="color: blue;",
|
||||
rarity_icon="★",
|
||||
style="default",
|
||||
rarity_icon=RARITY_MAPPING[1],
|
||||
rarity_level=1
|
||||
)
|
||||
# Establish many-to-many relationship.
|
||||
self.card.decks.add(self.deck)
|
||||
|
||||
def test_card_str(self):
|
||||
expected = f"{self.card.name} {self.card.rarity_icon} {self.card.cardset}"
|
||||
expected = f"{self.card.name} ({self.card.cardset} #{self.card.cardnum})"
|
||||
self.assertEqual(str(self.card), expected)
|
||||
|
||||
def test_deck_str(self):
|
||||
|
|
@ -158,8 +159,8 @@ class CardsViewsTests(TestCase):
|
|||
name="Test Card",
|
||||
cardset="A",
|
||||
cardnum=1,
|
||||
style="background: red;",
|
||||
rarity_icon="★",
|
||||
style="default",
|
||||
rarity_icon=RARITY_MAPPING[1],
|
||||
rarity_level=1
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue