diff --git a/konova/tests/test_views.py b/konova/tests/test_views.py index ff99ea3c..d84c0516 100644 --- a/konova/tests/test_views.py +++ b/konova/tests/test_views.py @@ -466,11 +466,15 @@ class KonovaViewTestCase(BaseViewTestCase): """ Holds tests for all regular views, which are not app specific """ - @classmethod - def setUpTestData(cls) -> None: - super().setUpTestData() + def setUp(self) -> None: + super().setUp() - 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): """ Check correct status code for all requests @@ -504,6 +508,24 @@ class KonovaViewTestCase(BaseViewTestCase): ] 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): @classmethod