Skip to content

Commit

Permalink
✅ Add admin test for full coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
CharString committed Dec 22, 2023
1 parent dd55ebd commit 1ec55cd
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Empty file.
48 changes: 48 additions & 0 deletions src/openklant/components/referentielijsten/tests/test_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import datetime

from django.contrib.auth import get_user_model
from django.test import TestCase
from django.urls import reverse

from ..api.tests import factories


class ReferentielijstenAdminTests(TestCase):
def setUp(self):
super().setUp()
self.client.force_login(
get_user_model()._default_manager.create(
username="root", is_superuser=True, is_staff=True
)
)

def test_landadmin_indicatie_actief_true(self):
factories.LandFactory(ingangsdatum_land=datetime.date.today())
url = reverse("admin:referentielijsten_land_changelist")

response = self.client.get(url)

self.assertContains(
response,
'<td class="field-indicatie_actief"><img src="/static/admin/img/icon-yes.svg" alt="True"></td>',
)
self.assertNotContains(
response,
'<td class="field-indicatie_actief"><img src="/static/admin/img/icon-no.svg" alt="False"></td>',
)

def test_landadmin_indicatie_actief_false(self):
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
factories.LandFactory(ingangsdatum_land=tomorrow)
url = reverse("admin:referentielijsten_land_changelist")

response = self.client.get(url)

self.assertNotContains(
response,
'<td class="field-indicatie_actief"><img src="/static/admin/img/icon-yes.svg" alt="True"></td>',
)
self.assertContains(
response,
'<td class="field-indicatie_actief"><img src="/static/admin/img/icon-no.svg" alt="False"></td>',
)

0 comments on commit 1ec55cd

Please sign in to comment.