Used assertCountEqual() in contrib.postgres.search tests.

This commit is contained in:
Tim Graham 2018-11-29 14:43:53 -05:00 committed by GitHub
parent 9fa0d3786f
commit 41db8cb252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -153,7 +153,7 @@ class MultipleFieldsTest(GrailTestData, PostgreSQLTestCase):
searched = Line.objects.annotate( searched = Line.objects.annotate(
search=SearchVector('scene__setting', 'dialogue'), search=SearchVector('scene__setting', 'dialogue'),
).filter(search='bedemir') ).filter(search='bedemir')
self.assertEqual(set(searched), {self.bedemir0, self.bedemir1, self.crowd, self.witch, self.duck}) self.assertCountEqual(searched, [self.bedemir0, self.bedemir1, self.crowd, self.witch, self.duck])
def test_search_with_non_text(self): def test_search_with_non_text(self):
searched = Line.objects.annotate( searched = Line.objects.annotate(
@ -186,7 +186,7 @@ class MultipleFieldsTest(GrailTestData, PostgreSQLTestCase):
def test_raw_search(self): def test_raw_search(self):
line_qs = Line.objects.annotate(search=SearchVector('dialogue')) line_qs = Line.objects.annotate(search=SearchVector('dialogue'))
searched = line_qs.filter(search=SearchQuery('Robin', search_type='raw')) searched = line_qs.filter(search=SearchQuery('Robin', search_type='raw'))
self.assertEqual(set(searched), {self.verse0, self.verse1}) self.assertCountEqual(searched, [self.verse0, self.verse1])
searched = line_qs.filter(search=SearchQuery("Robin & !'Camelot'", search_type='raw')) searched = line_qs.filter(search=SearchQuery("Robin & !'Camelot'", search_type='raw'))
self.assertSequenceEqual(searched, [self.verse1]) self.assertSequenceEqual(searched, [self.verse1])
@ -233,7 +233,7 @@ class TestCombinations(GrailTestData, PostgreSQLTestCase):
searched = Line.objects.annotate( searched = Line.objects.annotate(
search=SearchVector('scene__setting') + SearchVector('character__name'), search=SearchVector('scene__setting') + SearchVector('character__name'),
).filter(search='bedemir') ).filter(search='bedemir')
self.assertEqual(set(searched), {self.bedemir0, self.bedemir1, self.crowd, self.witch, self.duck}) self.assertCountEqual(searched, [self.bedemir0, self.bedemir1, self.crowd, self.witch, self.duck])
def test_vector_add_multi(self): def test_vector_add_multi(self):
searched = Line.objects.annotate( searched = Line.objects.annotate(
@ -243,7 +243,7 @@ class TestCombinations(GrailTestData, PostgreSQLTestCase):
SearchVector('dialogue') SearchVector('dialogue')
), ),
).filter(search='bedemir') ).filter(search='bedemir')
self.assertEqual(set(searched), {self.bedemir0, self.bedemir1, self.crowd, self.witch, self.duck}) self.assertCountEqual(searched, [self.bedemir0, self.bedemir1, self.crowd, self.witch, self.duck])
def test_query_and(self): def test_query_and(self):
searched = Line.objects.annotate( searched = Line.objects.annotate(
@ -264,17 +264,17 @@ class TestCombinations(GrailTestData, PostgreSQLTestCase):
def test_query_or(self): def test_query_or(self):
searched = Line.objects.filter(dialogue__search=SearchQuery('kneecaps') | SearchQuery('nostrils')) searched = Line.objects.filter(dialogue__search=SearchQuery('kneecaps') | SearchQuery('nostrils'))
self.assertEqual(set(searched), {self.verse1, self.verse2}) self.assertCountEqual(searched, [self.verse1, self.verse2])
def test_query_multiple_or(self): def test_query_multiple_or(self):
searched = Line.objects.filter( searched = Line.objects.filter(
dialogue__search=SearchQuery('kneecaps') | SearchQuery('nostrils') | SearchQuery('Sir Robin') dialogue__search=SearchQuery('kneecaps') | SearchQuery('nostrils') | SearchQuery('Sir Robin')
) )
self.assertEqual(set(searched), {self.verse1, self.verse2, self.verse0}) self.assertCountEqual(searched, [self.verse1, self.verse2, self.verse0])
def test_query_invert(self): def test_query_invert(self):
searched = Line.objects.filter(character=self.minstrel, dialogue__search=~SearchQuery('kneecaps')) searched = Line.objects.filter(character=self.minstrel, dialogue__search=~SearchQuery('kneecaps'))
self.assertEqual(set(searched), {self.verse0, self.verse2}) self.assertCountEqual(searched, [self.verse0, self.verse2])
def test_query_config_mismatch(self): def test_query_config_mismatch(self):
with self.assertRaisesMessage(TypeError, "SearchQuery configs don't match."): with self.assertRaisesMessage(TypeError, "SearchQuery configs don't match."):