Skip to content

Commit

Permalink
Hot fix provider_choices (#3810)
Browse files Browse the repository at this point in the history
Co-authored-by: Jean-Etienne Castagnede <[email protected]>
  • Loading branch information
juggler31 and submarcos authored Oct 26, 2023
1 parent 6621017 commit f47a875
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 49 deletions.
16 changes: 8 additions & 8 deletions geotrek/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,17 +888,17 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = PathFactory.create(provider='my_provider1')
signage2 = PathFactory.create(provider='my_provider2')
path1 = PathFactory.create(provider='my_provider1')
path2 = PathFactory.create(provider='my_provider2')

filter_set = PathFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(path1, filter_set.qs)
self.assertIn(path2, filter_set.qs)


class TrailFilterTest(CommonTest, AuthentFixturesTest):
Expand All @@ -913,14 +913,14 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = TrailFactory.create(provider='my_provider1')
signage2 = TrailFactory.create(provider='my_provider2')
trail1 = TrailFactory.create(provider='my_provider1')
trail2 = TrailFactory.create(provider='my_provider2')

filter_set = TrailFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(trail1, filter_set.qs)
self.assertIn(trail2, filter_set.qs)
8 changes: 4 additions & 4 deletions geotrek/infrastructure/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = InfrastructureFactory.create(provider='my_provider1')
signage2 = InfrastructureFactory.create(provider='my_provider2')
infrastructure1 = InfrastructureFactory.create(provider='my_provider1')
infrastructure2 = InfrastructureFactory.create(provider='my_provider2')

filter_set = InfrastructureFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(infrastructure1, filter_set.qs)
self.assertIn(infrastructure2, filter_set.qs)
16 changes: 8 additions & 8 deletions geotrek/outdoor/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,17 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = SiteFactory.create(provider='my_provider1')
signage2 = SiteFactory.create(provider='my_provider2')
site1 = SiteFactory.create(provider='my_provider1')
site2 = SiteFactory.create(provider='my_provider2')

filter_set = SiteFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(site1, filter_set.qs)
self.assertIn(site2, filter_set.qs)


class CourseFilterTest(TestCase):
Expand All @@ -201,14 +201,14 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = CourseFactory.create(provider='my_provider1')
signage2 = CourseFactory.create(provider='my_provider2')
course1 = CourseFactory.create(provider='my_provider1')
course2 = CourseFactory.create(provider='my_provider2')

filter_set = CourseFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(course1, filter_set.qs)
self.assertIn(course2, filter_set.qs)
8 changes: 4 additions & 4 deletions geotrek/sensitivity/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,14 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = SensitiveAreaFactory.create(provider='my_provider1')
signage2 = SensitiveAreaFactory.create(provider='my_provider2')
sensitive_area1 = SensitiveAreaFactory.create(provider='my_provider1')
sensitive_area2 = SensitiveAreaFactory.create(provider='my_provider2')

filter_set = SensitiveAreaFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(sensitive_area1, filter_set.qs)
self.assertIn(sensitive_area2, filter_set.qs)
5 changes: 0 additions & 5 deletions geotrek/signage/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ def implantation_year_choices(self):
.order_by('-implantation_year').distinct('implantation_year') \
.values_list('implantation_year', flat=True)
return tuple((value, value) for value in values)

# def provider_choices(self):
# providers = self.get_queryset().existing().exclude(provider__exact='') \
# .distinct('provider').values_list('provider', 'provider')
# return providers
16 changes: 8 additions & 8 deletions geotrek/tourism/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,17 +581,17 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = TouristicContentFactory.create(provider='my_provider1')
signage2 = TouristicContentFactory.create(provider='my_provider2')
touristic_content1 = TouristicContentFactory.create(provider='my_provider1')
touristic_content2 = TouristicContentFactory.create(provider='my_provider2')

filter_set = TouristicContentFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(touristic_content1, filter_set.qs)
self.assertIn(touristic_content2, filter_set.qs)


class TouristicEventFilterTest(TestCase):
Expand All @@ -606,14 +606,14 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = TouristicEventFactory.create(provider='my_provider1')
signage2 = TouristicEventFactory.create(provider='my_provider2')
touristic_event1 = TouristicEventFactory.create(provider='my_provider1')
touristic_event2 = TouristicEventFactory.create(provider='my_provider2')

filter_set = TouristicEventFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(touristic_event1, filter_set.qs)
self.assertIn(touristic_event2, filter_set.qs)
24 changes: 12 additions & 12 deletions geotrek/trekking/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1668,17 +1668,17 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = TrekFactory.create(provider='my_provider1')
signage2 = TrekFactory.create(provider='my_provider2')
trek1 = TrekFactory.create(provider='my_provider1')
trek2 = TrekFactory.create(provider='my_provider2')

filter_set = TrekFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(trek1, filter_set.qs)
self.assertIn(trek2, filter_set.qs)


class POIFilterTest(TestCase):
Expand All @@ -1693,17 +1693,17 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = POIFactory.create(provider='my_provider1')
signage2 = POIFactory.create(provider='my_provider2')
poi1 = POIFactory.create(provider='my_provider1')
poi2 = POIFactory.create(provider='my_provider2')

filter_set = POIFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(poi1, filter_set.qs)
self.assertIn(poi2, filter_set.qs)


class ServiceFilterTest(TestCase):
Expand All @@ -1718,14 +1718,14 @@ def test_provider_filter_without_provider(self):
self.assertEqual(0, filter_set.qs.count())

def test_provider_filter_with_providers(self):
signage1 = ServiceFactory.create(provider='my_provider1')
signage2 = ServiceFactory.create(provider='my_provider2')
service1 = ServiceFactory.create(provider='my_provider1')
service2 = ServiceFactory.create(provider='my_provider2')

filter_set = ServiceFilterSet()
filter_form = filter_set.form

self.assertIn('<option value="my_provider1">my_provider1</option>', filter_form.as_p())
self.assertIn('<option value="my_provider2">my_provider2</option>', filter_form.as_p())

self.assertIn(signage1, filter_set.qs)
self.assertIn(signage2, filter_set.qs)
self.assertIn(service1, filter_set.qs)
self.assertIn(service2, filter_set.qs)

0 comments on commit f47a875

Please sign in to comment.