Skip to content

Commit

Permalink
Updates collectors tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandBordage committed Apr 18, 2018
1 parent ca0214f commit e829b29
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions wagtail/core/tests/test_collectors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db import connection
from django.test import TestCase
Expand Down Expand Up @@ -267,6 +268,9 @@ def test_rich_text_block(self):
class GetAllUsesTest(TestCase):
def setUp(self):
self.is_sqlite = connection.vendor == 'sqlite'
self.has_postgres_search = connection.vendor == 'postgresql' and any(
conf['BACKEND'] == 'wagtail.contrib.postgres_search.backend'
for conf in settings.WAGTAILSEARCH_BACKENDS.values())

i = 0

Expand Down Expand Up @@ -300,26 +304,27 @@ def create_page(body):
ContentType.objects.clear_cache()

def test_empty(self):
with self.assertNumQueries(54):
with self.assertNumQueries(56 if self.has_postgres_search else 54):
uses = list(get_all_uses(self.obj0))
self.assertListEqual(uses, [])

def test_foreign_key(self):
with self.assertNumQueries(55 if self.is_sqlite else 54):
with self.assertNumQueries(56 if self.has_postgres_search
else (55 if self.is_sqlite else 54)):
uses = list(get_all_uses(self.obj1))
self.assertListEqual(uses, [self.obj2])

def test_rich_text(self):
with self.assertNumQueries(57):
with self.assertNumQueries(58 if self.has_postgres_search else 57):
uses = list(get_all_uses(self.obj3))
self.assertListEqual(uses, [self.obj4])

def test_streamfield(self):
with self.assertNumQueries(57):
with self.assertNumQueries(58 if self.has_postgres_search else 57):
uses = list(get_all_uses(self.obj3))
self.assertListEqual(uses, [self.obj4])

def test_multiple(self):
with self.assertNumQueries(49 if self.is_sqlite else 48):
with self.assertNumQueries(49 if self.is_sqlite or self.has_postgres_search else 48):
uses = list(get_all_uses(self.obj7))
self.assertListEqual(uses, [self.obj8, self.obj9, self.obj10])

0 comments on commit e829b29

Please sign in to comment.