Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Oct 27, 2023
1 parent 7d8fa19 commit 935e6d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
16 changes: 7 additions & 9 deletions geotrek/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@ def test_draft_path_layer_cache(self):
obj = self.modelfactory(draft=False)
self.modelfactory(draft=True)

# There are 7 queries to get layer without drafts
with self.assertNumQueries(5):
with self.assertNumQueries(4):
response = self.client.get(obj.get_layer_url(), {"_no_draft": "true"})
self.assertEqual(len(response.json()['features']), 1)

Expand Down Expand Up @@ -599,7 +598,7 @@ def test_draft_path_layer_cache(self):
self.modelfactory(draft=False)

# Cache was updated, the path was not a draft : we get 7 queries
with self.assertNumQueries(5):
with self.assertNumQueries(4):
self.client.get(obj.get_layer_url(), {"_no_draft": "true"})

def test_path_layer_cache(self):
Expand All @@ -612,8 +611,7 @@ def test_path_layer_cache(self):
obj = self.modelfactory(draft=False)
self.modelfactory(draft=True)

# There are 7 queries to get layer without drafts
with self.assertNumQueries(5):
with self.assertNumQueries(4):
response = self.client.get(obj.get_layer_url())
self.assertEqual(len(response.json()['features']), 2)

Expand All @@ -636,13 +634,13 @@ def test_path_layer_cache(self):
self.modelfactory(draft=True)

# Cache is updated when we add a draft path
with self.assertNumQueries(5):
with self.assertNumQueries(4):
self.client.get(obj.get_layer_url())

self.modelfactory(draft=False)

# Cache is updated when we add a path
with self.assertNumQueries(5):
with self.assertNumQueries(4):
self.client.get(obj.get_layer_url())


Expand Down Expand Up @@ -695,7 +693,7 @@ def test_denormalized_path_trails(self):
PathFactory.create_batch(size=50)
TrailFactory.create_batch(size=50)
self.login()
with self.assertNumQueries(6):
with self.assertNumQueries(5):
self.client.get(reverse('core:path-drf-list', kwargs={'format': 'datatables'}))


Expand Down Expand Up @@ -799,7 +797,7 @@ def test_add_trail_from_existing_topology(self):

def test_perfs_export_csv(self):
self.modelfactory.create()
with self.assertNumQueries(14):
with self.assertNumQueries(11):
self.client.get(self.model.get_format_list_url() + '?format=csv')


Expand Down
2 changes: 1 addition & 1 deletion geotrek/tourism/tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_csv_participants_count(self):
total_count = sum(map(attrgetter('count'), counts))
self.assertEqual(event.participants_total, total_count)
self.assertEqual(event.participants_total_verbose_name, "Number of participants")
with self.assertNumQueries(18):
with self.assertNumQueries(15):
response = self.client.get(event.get_format_list_url())
self.assertEqual(response.status_code, 200)
self.assertEqual(response.get('Content-Type'), 'text/csv')
Expand Down
8 changes: 4 additions & 4 deletions geotrek/trekking/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ def test_listing_number_queries(self):
self.modelfactory.build_batch(1000)
DistrictFactory.build_batch(10)

with self.assertNumQueries(6):
with self.assertNumQueries(5):
self.client.get(self.model.get_datatablelist_url())

with self.assertNumQueries(10):
with self.assertNumQueries(8):
self.client.get(self.model.get_format_list_url())

def test_list_in_csv(self):
Expand Down Expand Up @@ -1515,10 +1515,10 @@ def test_listing_number_queries(self):
self.modelfactory.build_batch(1000)
DistrictFactory.build_batch(10)

with self.assertNumQueries(6):
with self.assertNumQueries(5):
self.client.get(self.model.get_datatablelist_url())

with self.assertNumQueries(7):
with self.assertNumQueries(4):
self.client.get(self.model.get_format_list_url())

def test_services_on_treks_do_not_exist(self):
Expand Down

0 comments on commit 935e6d2

Please sign in to comment.