Skip to content

Commit bacc006

Browse files
committed
test(profiles/trainers): add tests for Trainer templates
1 parent 73d20aa commit bacc006

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

profiles/tests/sport_doctors/test_templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ def test_sport_doctor_confirm_delete_template(self):
3939
"""Test that the sport_doctor delete template is rendered correctly."""
4040
url = reverse('sport_doctor_delete', kwargs={'pk': self.sport_doctor.pk})
4141
response = self.client.get(url)
42-
self.assertTemplateUsed(response, 'profiles/sport_doctor_confirm_delete.html')
42+
self.assertTemplateUsed(response, 'profiles/sport_doctor_confirm_delete.html')
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from django.test import TestCase
2+
from django.urls import reverse
3+
from profiles.models import Trainer
4+
5+
6+
class TrainerTemplatesTests(TestCase):
7+
@classmethod
8+
def setUpTestData(cls):
9+
"""Create initial data for template testing."""
10+
cls.trainer = Trainer.objects.create(
11+
first_name='Giovanni',
12+
last_name='Verdi',
13+
fiscal_code='ABCDEF12G34H567I',
14+
)
15+
16+
# Test List Template
17+
def test_trainer_list_template(self):
18+
"""Test that the trainer list template is rendered correctly."""
19+
url = reverse('trainer_list')
20+
response = self.client.get(url)
21+
self.assertTemplateUsed(response, 'profiles/trainer_list.html')
22+
23+
# Test Detail Template
24+
def test_trainer_detail_template(self):
25+
"""Test that the trainer detail template is rendered correctly."""
26+
url = reverse('trainer_detail', kwargs={'pk': self.trainer.pk})
27+
response = self.client.get(url)
28+
self.assertTemplateUsed(response, 'profiles/trainer_detail.html')
29+
30+
# Test Form Template
31+
def test_trainer_form_template(self):
32+
"""Test that the trainer form template is rendered correctly."""
33+
url = reverse('trainer_create')
34+
response = self.client.get(url)
35+
self.assertTemplateUsed(response, 'profiles/trainer_form.html')
36+
37+
# Test Delete Template
38+
def test_trainer_confirm_delete_template(self):
39+
"""Test that the trainer delete template is rendered correctly."""
40+
url = reverse('trainer_delete', kwargs={'pk': self.trainer.pk})
41+
response = self.client.get(url)
42+
self.assertTemplateUsed(response, 'profiles/trainer_confirm_delete.html')

0 commit comments

Comments
 (0)