|
| 1 | +from django.test import TestCase |
| 2 | +from documentation.models import SportCertificate |
| 3 | +from profiles.models import SportDoctor |
| 4 | +from datetime import date |
| 5 | + |
| 6 | + |
| 7 | +class SportCertificateModelTest(TestCase): |
| 8 | + @classmethod |
| 9 | + def setUpTestData(cls): |
| 10 | + """Create a valid instance of SportDoctor shared by all tests.""" |
| 11 | + cls.sport_doctor = SportDoctor.objects.create( |
| 12 | + first_name='Giovanni', |
| 13 | + last_name='Verdi', |
| 14 | + vat_number='12345678901' |
| 15 | + ) |
| 16 | + |
| 17 | + def setUp(self): |
| 18 | + """Create a valid instance of SportCertificate for each test.""" |
| 19 | + self.certificate = SportCertificate.objects.create( |
| 20 | + facility_id='FAC123', |
| 21 | + issued_date=date(2024, 1, 1), |
| 22 | + expiration_date=date(2025, 1, 1), |
| 23 | + doctor=self.sport_doctor |
| 24 | + ) |
| 25 | + |
| 26 | + def test_sport_certificate_creation(self): |
| 27 | + """Test that a valid SportCertificate instance is created correctly.""" |
| 28 | + self.assertEqual(self.certificate.facility_id, 'FAC123') |
| 29 | + self.assertEqual(self.certificate.issued_date, date(2024, 1, 1)) |
| 30 | + self.assertEqual(self.certificate.expiration_date, date(2025, 1, 1)) |
| 31 | + self.assertEqual(self.certificate.doctor, self.sport_doctor) |
| 32 | + |
| 33 | + def test_sport_certificate_required_fields(self): |
| 34 | + """Test that required fields cannot be left blank.""" |
| 35 | + pass |
| 36 | + |
| 37 | + def test_sport_certificate_valid_dates(self): |
| 38 | + """Test that issued_date must be before expiration_date.""" |
| 39 | + pass |
| 40 | + |
| 41 | + def test_sport_certificate_string_representation(self): |
| 42 | + """Test __str__ method.""" |
| 43 | + self.assertEqual( |
| 44 | + str(self.certificate), |
| 45 | + 'Certificato FAC123 - Emesso il 2024-01-01 da Giovanni Verdi - P.IVA: 12345678901' |
| 46 | + ) |
| 47 | + |
| 48 | + def test_sport_certificate_repr_representation(self): |
| 49 | + """Test __repr__ method.""" |
| 50 | + self.assertEqual( |
| 51 | + repr(self.certificate), |
| 52 | + 'SportCertificate(facility_id=FAC123, issued_date=2024-01-01, ' |
| 53 | + 'expiration_date=2025-01-01, doctor=Giovanni Verdi - P.IVA: 12345678901)' |
| 54 | + ) |
| 55 | + |
| 56 | + def test_sport_certificate_ordering(self): |
| 57 | + """Test ordering.""" |
| 58 | + pass |
0 commit comments