Files
timetracker/tests/test_session_formatting.py
T
lukas ed8589a972
Django CI/CD / test (push) Successful in 39s
Django CI/CD / build-and-push (push) Successful in 1m19s
Fix more code smells
2026-06-06 13:14:55 +02:00

33 lines
859 B
Python

from datetime import datetime
from zoneinfo import ZoneInfo
from django.conf import settings
from django.test import TestCase
from games.models import Game, Purchase, Session
ZONEINFO = ZoneInfo(settings.TIME_ZONE)
class FormatDurationTest(TestCase):
def setUp(self) -> None:
return super().setUp()
def test_duration_format(self):
g = Game(name="The Test Game")
g.save()
p = Purchase(date_purchased=datetime(2022, 9, 26, 14, 58, tzinfo=ZONEINFO))
p.save()
p.games.add(g)
p.save()
s = Session(
game=g,
timestamp_start=datetime(2022, 9, 26, 14, 58, tzinfo=ZONEINFO),
timestamp_end=datetime(2022, 9, 26, 17, 38, tzinfo=ZONEINFO),
)
s.save()
self.assertEqual(
s.duration_formatted(),
"2.7",
)