do a simple Game test of the string repr

Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
Brian S. Stephan 2024-05-14 21:17:51 -05:00
parent 27fcecd8aa
commit 497619e0ff
Signed by: bss
GPG Key ID: 3DE06D3180895FCB
2 changed files with 28 additions and 0 deletions

View File

@ -29,6 +29,10 @@ class Game(models.Model):
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
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.

View 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)"