Skip to content

Commit 29efded

Browse files
committed
test(profiles/trainers): add tests for model Trainer
1 parent 7f9a32b commit 29efded

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

profiles/tests/trainers/__init__.py

Whitespace-only changes.
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 profiles.models import Trainer
3+
4+
5+
class TrainerModelTest(TestCase):
6+
@classmethod
7+
def setUpTestData(cls):
8+
"""Create a valid instance of Trainer shared by all tests."""
9+
cls.trainer = Trainer.objects.create(
10+
first_name='Paolo',
11+
last_name='Bianchi',
12+
fiscal_code='BNCPLO80A01H211B',
13+
)
14+
15+
def test_trainer_creation(self):
16+
"""Test that a valid Trainer instance is created correctly."""
17+
self.assertEqual(self.trainer.first_name, 'Paolo')
18+
self.assertEqual(self.trainer.last_name, 'Bianchi')
19+
self.assertEqual(self.trainer.fiscal_code, 'BNCPLO80A01H211B')
20+
21+
def test_trainer_required_fields(self):
22+
"""Test that required fields cannot be left blank."""
23+
pass
24+
25+
def test_trainer_fiscal_code_uniqueness(self):
26+
"""Test that the fiscal_code field is unique."""
27+
pass
28+
29+
def test_trainer_string_representation(self):
30+
"""Test __str__ method."""
31+
self.assertEqual(
32+
str(self.trainer),
33+
'Paolo Bianchi (BNCPLO80A01H211B)'
34+
)
35+
36+
def test_trainer_repr_representation(self):
37+
"""Test __repr__ method."""
38+
self.assertEqual(
39+
repr(self.trainer),
40+
'Trainer(first_name=Paolo, last_name=Bianchi, fiscal_code=BNCPLO80A01H211B)'
41+
)
42+

0 commit comments

Comments
 (0)