Esempio n. 1
0
 def test_can_generate_correct_querystrings_using_q_objects_and_negations(self):
     # Setup
     query = Query(self.search)
     # Run & check
     self.assertEqual(
         query.filter(Q(foo='bar') | ~Q(foo='test'), xyz='xyz')._qs,
         '((*:*) AND ((foo:bar) OR ((*:* -foo:test)))) AND (xyz:xyz)')
Esempio n. 2
0
 def test_can_generate_correct_querystrings_using_simple_parameters(self):
     # Setup
     query = Query(self.search)
     # Run & check
     self.assertTrue(
         query.filter(foo='bar', xyz='test')._qs in
         ['(*:*) AND (foo:bar AND xyz:test)', '(*:*) AND (xyz:test AND foo:bar)'])
Esempio n. 3
0
    def test_can_use_filters_mapping(self):
        # Setup
        class NewSearch(Search):
            filters_mapping = {
                'author': '(Auteur_tri:*{author}* OR Auteur_fac:*{author}*)',
            }

        search = NewSearch(self.client)
        query = Query(search)

        # Run & check
        self.assertEqual(
            query.filter(author='test')._qs,
            '(*:*) AND ((Auteur_tri:*test* OR Auteur_fac:*test*))')
Esempio n. 4
0
 def test_can_generate_correct_querystrings_using_q_objects(self):
     # Setup
     query = Query(self.search)
     # Run & check
     self.assertEqual(
         query.filter(Q(foo='bar'))._qs,
         '(*:*) AND (foo:bar)')
     self.assertEqual(
         query.filter(Q(foo='bar') | Q(foo='test'))._qs,
         '(*:*) AND ((foo:bar) OR (foo:test))')
     self.assertEqual(
         query.filter(Q(foo='bar') & Q(foo='test'))._qs,
         '(*:*) AND ((foo:bar) AND (foo:test))')
     self.assertEqual(
         query.filter((Q(foo='bar') | Q(foo='test')) & Q(xyz='xyz'))._qs,
         '(*:*) AND (((foo:bar) OR (foo:test)) AND (xyz:xyz))')