Esempio n. 1
0
    def test_search(self):
        # XXX: Solr 7 has a new query param 'q.op' which can not be passed to
        # the search method in Python.
        # This is why we have commented out code here.
        search_request = getData("search_request.txt").rstrip(b"\n")
        search_request_py2 = getData("search_request_py2.txt").rstrip(b"\n")
        search_response = getData("search_response.txt")
        c = SolrConnection(host="localhost:8983", persistent=True)
        output = fakehttp(c, search_response)
        parameters = {
            "q": "+id:[* TO *]",
            "fl": "* score",
            "wt": "xml",
            "rows": "10",
            "indent": "on",
            "q.op": "AND",
            "lowercaseOperators": "true",
            "sow": "true",
        }

        res = c.search(**parameters)
        res = fromstring(res.read())
        normalize = lambda x: sorted(x.split(b"&"))  # sort request params
        self.assertIn(
            normalize(output.get()),
            [normalize(search_request),
             normalize(search_request_py2)],
        )
        self.failUnless(res.find((".//doc")))
Esempio n. 2
0
 def test_search(self):
     search_request = getData('search_request.txt')
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, search_response)
     res = c.search(q='+id:[* TO *]', wt='xml', rows='10', indent='on')
     res = fromstring(res.read())
     self.failUnlessEqual(str(output), search_request)
     self.failUnless(res.find(('.//doc')))
Esempio n. 3
0
 def test_search(self):
     search_request = getData('search_request.txt')
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, search_response)
     res = c.search(q='+id:[* TO *]', wt='xml', rows='10', indent='on')
     res = fromstring(res.read())
     self.failUnlessEqual(str(output), search_request)
     self.failUnless(res.find(('.//doc')))
Esempio n. 4
0
 def test_search(self):
     search_request = getData('search_request.txt')
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, search_response)
     res = c.search(q='+id:[* TO *]', fl='* score', wt='xml', rows='10', indent='on')
     res = fromstring(res.read())
     normalize = lambda x: sorted(x.split('&'))      # sort request params
     self.assertEqual(normalize(output.get()), normalize(search_request))
     self.failUnless(res.find(('.//doc')))
 def test_search(self):
     search_request = getData('search_request.txt')
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     output = fakehttp(c, search_response)
     res = c.search(
         q='+id:[* TO *]', fl='* score', wt='xml', rows='10', indent='on')
     res = fromstring(res.read())
     normalize = lambda x: sorted(x.split('&'))      # sort request params
     self.assertEqual(normalize(output.get()), normalize(search_request))
     self.failUnless(res.find(('.//doc')))
Esempio n. 6
0
    def test_search(self):
        # XXX: Solr 7 has a new query param 'q.op' which can not be passed to
        # the search method in Python.
        # This is why we have commented out code here.
        search_request = getData('search_request.txt').rstrip('\n')
        search_response = getData('search_response.txt')
        c = SolrConnection(host='localhost:8983', persistent=True)
        output = fakehttp(c, search_response)
        parameters = {'q': '+id:[* TO *]',
                      'fl': '* score',
                      'wt': 'xml',
                      'rows': '10',
                      'indent': 'on',
                      'q.op': 'AND',
                      'lowercaseOperators': 'true',
                      'sow': 'true'}

        res = c.search(**parameters)
        res = fromstring(res.read())
        normalize = lambda x: sorted(x.split('&'))      # sort request params
        self.assertEqual(normalize(output.get()), normalize(search_request))
        self.failUnless(res.find(('.//doc')))
Esempio n. 7
0
 def test_search_with_custom_request_handler(self):
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     fakehttp(c, search_response)
     c.search(request_handler='custom', q='+id:[* TO *]')
     self.assertEqual('/solr/custom', c.conn.url)
Esempio n. 8
0
 def test_search_with_custom_request_handler(self):
     search_response = getData("search_response.txt")
     c = SolrConnection(host="localhost:8983", persistent=True)
     fakehttp(c, search_response)
     c.search(request_handler="custom", q="+id:[* TO *]")
     self.assertEqual("/solr/plone/custom", c.conn.url)
Esempio n. 9
0
 def test_search_with_custom_request_handler(self):
     search_response = getData('search_response.txt')
     c = SolrConnection(host='localhost:8983', persistent=True)
     fakehttp(c, search_response)
     c.search(request_handler='custom', q='+id:[* TO *]')
     self.assertEqual('/solr/plone/custom', c.conn.url)