def test_get_query_size(self): instance = AutocompleteChoicesPagesOverride() self.assertNotEqual( instance.get_query_size(), settings.AGNOCOMPLETE_DEFAULT_QUERYSIZE) self.assertNotEqual( instance.get_query_size_min(), settings.AGNOCOMPLETE_MIN_QUERYSIZE) self.assertEqual( instance.get_query_size(), AutocompleteChoicesPagesOverride.query_size) self.assertEqual( instance.get_query_size_min(), AutocompleteChoicesPagesOverride.query_size_min)
def test_get_page_size(self): instance = AutocompleteChoicesPagesOverride() self.assertEqual(instance.get_page_size(), 30) # over the limit params, back to default instance = AutocompleteChoicesPagesOverride(page_size=1000) self.assertEqual(instance.get_page_size(), 30) instance = AutocompleteChoicesPagesOverride(page_size=1) self.assertEqual(instance.get_page_size(), 30) # Reasonable overriding instance = AutocompleteChoicesPagesOverride(page_size=12) self.assertEqual(instance.get_page_size(), 12)
def test_get_query_size(self): instance = AutocompleteChoicesPagesOverride() self.assertNotEqual(instance.get_query_size(), settings.AGNOCOMPLETE_DEFAULT_QUERYSIZE) self.assertNotEqual(instance.get_query_size_min(), settings.AGNOCOMPLETE_MIN_QUERYSIZE) self.assertEqual(instance.get_query_size(), AutocompleteChoicesPagesOverride.query_size) self.assertEqual(instance.get_query_size_min(), AutocompleteChoicesPagesOverride.query_size_min)
def test_items_page_size(self): instance = AutocompleteChoicesPagesOverride() result = list(instance.items(query='choice')) # item number is greater than the default page size self.assertNotEqual(len(result), 15) self.assertEqual(len(result), 30)