From 335630e16d172cfec078257a32e33f18ff8dba78 Mon Sep 17 00:00:00 2001 From: moanos Date: Sun, 10 Aug 2025 17:50:17 +0200 Subject: [PATCH] feat(test): Add test for search by location --- src/tests/test_views/test_basic_views.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tests/test_views/test_basic_views.py b/src/tests/test_views/test_basic_views.py index 5341af8..a70bf08 100644 --- a/src/tests/test_views/test_basic_views.py +++ b/src/tests/test_views/test_basic_views.py @@ -2,7 +2,8 @@ from django.test import TestCase from django.urls import reverse from docs.conf import language -from fellchensammlung.models import User, TrustLevel, AdoptionNotice, Species, Rule, Language, Comment, ReportComment +from fellchensammlung.models import User, TrustLevel, AdoptionNotice, Species, Rule, Language, Comment, ReportComment, \ + Location, ImportantLocation from model_bakery import baker @@ -40,6 +41,10 @@ class BasicViewTest(TestCase): report_comment1.save() report_comment1.reported_broken_rules.set({rule1, }) + berlin = Location.get_location_from_string("Berlin") + cls.important_berlin = ImportantLocation(location=berlin, slug="berlin", name="Berlin") + cls.important_berlin.save() + def test_index_logged_in(self): self.client.login(username='testuser0', password='12345') @@ -165,3 +170,13 @@ class BasicViewTest(TestCase): response = self.client.get(reverse('add-adoption')) self.assertEqual(response.status_code, 302) self.assertEqual(response.url, "/accounts/login/?next=/vermitteln/") + + def test_important_location_logged_in(self): + self.client.login(username='testuser0', password='12345') + + response = self.client.get(reverse('search-by-location', args=(self.important_berlin.slug,))) + self.assertEqual(response.status_code, 200) + + def test_important_location_anonymous(self): + response = self.client.get(reverse('search-by-location', args=(self.important_berlin.slug,))) + self.assertEqual(response.status_code, 200)