|
| 1 | +from django.test import TestCase |
| 2 | +from django.urls import reverse |
| 3 | +from datetime import date |
| 4 | +from documentation.models import SportCertificate |
| 5 | +from profiles.models import SportDoctor |
| 6 | + |
| 7 | + |
| 8 | +class SportCertificateTemplatesTests(TestCase): |
| 9 | + @classmethod |
| 10 | + def setUpTestData(cls): |
| 11 | + """Create initial data for template testing.""" |
| 12 | + cls.doctor = SportDoctor.objects.create( |
| 13 | + first_name='Giovanni', |
| 14 | + last_name='Verdi', |
| 15 | + vat_number='12345678901' |
| 16 | + ) |
| 17 | + cls.certificate = SportCertificate.objects.create( |
| 18 | + facility_id='FAC123', |
| 19 | + issued_date=date(2024, 1, 1), |
| 20 | + expiration_date=date(2025, 1, 1), |
| 21 | + doctor=cls.doctor |
| 22 | + ) |
| 23 | + |
| 24 | + # Test List Template |
| 25 | + def test_sport_certificate_list_template(self): |
| 26 | + """Test that the sport certificate list template is rendered correctly.""" |
| 27 | + url = reverse('sport_certificate_list') |
| 28 | + response = self.client.get(url) |
| 29 | + self.assertTemplateUsed(response, 'documentation/sport_certificate_list.html') |
| 30 | + |
| 31 | + # Test Detail Template |
| 32 | + def test_sport_certificate_detail_template(self): |
| 33 | + """Test that the sport certificate detail template is rendered correctly.""" |
| 34 | + url = reverse('sport_certificate_detail', kwargs={'pk': self.certificate.pk}) |
| 35 | + response = self.client.get(url) |
| 36 | + self.assertTemplateUsed(response, 'documentation/sport_certificate_detail.html') |
| 37 | + |
| 38 | + # Test Form Template |
| 39 | + def test_sport_certificate_form_template(self): |
| 40 | + """Test that the sport certificate form template is rendered correctly.""" |
| 41 | + url = reverse('sport_certificate_create') |
| 42 | + response = self.client.get(url) |
| 43 | + self.assertTemplateUsed(response, 'documentation/sport_certificate_form.html') |
| 44 | + |
| 45 | + # Test Delete Template |
| 46 | + def test_sport_certificate_confirm_delete_template(self): |
| 47 | + """Test that the sport certificate delete template is rendered correctly.""" |
| 48 | + url = reverse('sport_certificate_delete', kwargs={'pk': self.certificate.pk}) |
| 49 | + response = self.client.get(url) |
| 50 | + self.assertTemplateUsed(response, 'documentation/sport_certificate_confirm_delete.html') |
| 51 | + |
0 commit comments