30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
|
"""Test the race views."""
|
||
|
from unittest import mock
|
||
|
|
||
|
from django.test import TestCase
|
||
|
from django.utils.timezone import now
|
||
|
|
||
|
from races.models import Race, Racer, RaceUpdate
|
||
|
|
||
|
|
||
|
class RaceViewTest(TestCase):
|
||
|
"""Test races views."""
|
||
|
|
||
|
def setUp(self):
|
||
|
"""Do pre-test stuff."""
|
||
|
self.client = self.client_class()
|
||
|
|
||
|
def test_race_display(self):
|
||
|
"""Test the display of race info when it's been somewhat populated."""
|
||
|
race = Race.objects.create(key='test')
|
||
|
racer_a = Racer.objects.create(nick='hank', race=race)
|
||
|
racer_b = Racer.objects.create(nick='bob', race=race)
|
||
|
RaceUpdate.objects.create(race=race, racer=racer_a, update="test 1")
|
||
|
RaceUpdate.objects.create(race=race, racer=racer_b, update="test 2")
|
||
|
RaceUpdate.objects.create(race=race, racer=racer_a, update="test 3")
|
||
|
|
||
|
resp = self.client.get('/races/race/test/')
|
||
|
self.assertIn(b'hank — test 1', resp.content)
|
||
|
self.assertIn(b'bob — test 2', resp.content)
|
||
|
self.assertIn(b'hank — test 3', resp.content)
|