#121 Deferred parcels test

* adds test for htmx-parcel fetching
This commit is contained in:
mpeltriaux 2022-02-21 15:53:09 +01:00
parent a4f6519601
commit fe409605aa

View File

@ -466,11 +466,15 @@ class KonovaViewTestCase(BaseViewTestCase):
""" Holds tests for all regular views, which are not app specific """ Holds tests for all regular views, which are not app specific
""" """
@classmethod def setUp(self) -> None:
def setUpTestData(cls) -> None: super().setUp()
super().setUpTestData()
cls.home_url = reverse("home") geom = self.create_dummy_geometry()
self.geom_1 = Geometry.objects.create(
geom=geom,
)
self.home_url = reverse("home")
def test_views_logged_in_no_groups(self): def test_views_logged_in_no_groups(self):
""" Check correct status code for all requests """ Check correct status code for all requests
@ -504,6 +508,24 @@ class KonovaViewTestCase(BaseViewTestCase):
] ]
self.assert_url_fail(client, urls) self.assert_url_fail(client, urls)
def test_htmx_parcel_fetch(self):
""" Tests that the htmx geometry-parcel fetch returns a proper status code and content
Returns:
"""
client_user = Client()
client_user.login(username=self.superuser.username, password=self.superuser_pw)
has_parcels = self.geom_1.parcels.all().exists()
if not has_parcels:
self.geom_1.update_parcels()
htmx_url = reverse("geometry-parcels", args=(self.geom_1.id,))
response = client_user.get(htmx_url)
self.assertEqual(response.status_code, 286, "Unexpected status code for HTMX fetch")
self.assertGreater(len(response.content), 0)
class AutocompleteTestCase(BaseViewTestCase): class AutocompleteTestCase(BaseViewTestCase):
@classmethod @classmethod