コード例 #1
0
    def test_descending_sort_by_frequency_with_default_order(self):
        query = FieldSearchQuery(args={'sort_by': 'frequency'})

        search = query.get_search()
        sort_field = search.to_dict()['sort'][0]

        expected_sort_dict = {'periodicity_index': {'order': 'desc'}}
        self.assertDictEqual(expected_sort_dict, sort_field)
コード例 #2
0
    def test_descending_sort_by_hits_90_days_with_default_order(self):
        query = FieldSearchQuery(args={'sort_by': 'hits_90_days'})

        search = query.get_search()
        sort_field = search.to_dict()['sort'][0]

        expected_sort_dict = {'hits': {'order': 'desc'}}
        self.assertDictEqual(expected_sort_dict, sort_field)
コード例 #3
0
    def test_ascending_sort_by_frequency_with_specified_order(self):
        query = FieldSearchQuery(args={'sort_by': 'frequency', 'sort': 'asc'})

        search = query.get_search()
        sort_list = search.to_dict()['sort']
        # Como no es el campo _score, no hace falta especificarle un "order" y puede ser un string

        expected_sort_list = ['periodicity_index']
        self.assertListEqual(expected_sort_list, sort_list)
コード例 #4
0
    def test_min_score_not_added_without_querystring(self):
        query = FieldSearchQuery(args={'limit': 0, 'start': 0})

        search = query.get_search()
        self.assertNotIn('min_score', search.to_dict())
コード例 #5
0
    def test_min_score(self):
        query = FieldSearchQuery(args={'limit': 0, 'start': 0, 'q': 'hola'})

        search = query.get_search()
        min_score = search.to_dict()['min_score']
        self.assertEqual(min_score, MetadataConfig.get_solo().min_score)
コード例 #6
0
    def test_sort_by_not_added_if_relevance_specified(self):
        query = FieldSearchQuery(args={'sort_by': 'relevance'})

        search = query.get_search()
        self.assertNotIn('sort', search.to_dict().keys())