do a simple Game test of the string repr
Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
parent
27fcecd8aa
commit
497619e0ff
@ -29,6 +29,10 @@ class Game(models.Model):
|
|||||||
models.UniqueConstraint("active", "channel", name="one_game_per_channel"),
|
models.UniqueConstraint("active", "channel", name="one_game_per_channel"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
"""Provide a string representation of the game."""
|
||||||
|
return f"{self.name} in {self.channel} ({'active' if self.active else 'inactive'})"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def level_formula(current_level: int = 0, base_time: datetime = None) -> timedelta:
|
def level_formula(current_level: int = 0, base_time: datetime = None) -> timedelta:
|
||||||
"""DRY the formula for determining when a character's next level would be.
|
"""DRY the formula for determining when a character's next level would be.
|
||||||
|
24
tests/test_idlerpg_game.py
Normal file
24
tests/test_idlerpg_game.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
"""Test IdleRPG game operations.
|
||||||
|
|
||||||
|
SPDX-FileCopyrightText: © 2024 Brian S. Stephan <bss@incorporeal.org>
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
from idlerpg.models import Game
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class GameTest(TestCase):
|
||||||
|
"""Test the Character model."""
|
||||||
|
|
||||||
|
fixtures = ['tests/fixtures/simple_character.json']
|
||||||
|
|
||||||
|
def test_string_repr(self):
|
||||||
|
"""Test the basic string summary."""
|
||||||
|
game = Game.objects.get(pk=1)
|
||||||
|
logger.debug(str(game))
|
||||||
|
assert str(game) == "test in #test on default (active)"
|
Loading…
x
Reference in New Issue
Block a user