forked from Ponysearch/Ponysearch
minor fix of BASE engine
This commit is contained in:
parent
d20bba6dc7
commit
5954a8e16a
2 changed files with 4 additions and 4 deletions
|
@ -73,7 +73,7 @@ def request(query, params):
|
||||||
def response(resp):
|
def response(resp):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
search_results = etree.XML(resp.text)
|
search_results = etree.XML(resp.content)
|
||||||
|
|
||||||
for entry in search_results.xpath('./result/doc'):
|
for entry in search_results.xpath('./result/doc'):
|
||||||
content = "No description available"
|
content = "No description available"
|
||||||
|
|
|
@ -21,10 +21,10 @@ class TestBaseEngine(SearxTestCase):
|
||||||
self.assertRaises(AttributeError, base.response, '')
|
self.assertRaises(AttributeError, base.response, '')
|
||||||
self.assertRaises(AttributeError, base.response, '[]')
|
self.assertRaises(AttributeError, base.response, '[]')
|
||||||
|
|
||||||
response = mock.Mock(text='<response></response>')
|
response = mock.Mock(content=b'<response></response>')
|
||||||
self.assertEqual(base.response(response), [])
|
self.assertEqual(base.response(response), [])
|
||||||
|
|
||||||
xml_mock = """<?xml version="1.0"?>
|
xml_mock = b"""<?xml version="1.0"?>
|
||||||
<response>
|
<response>
|
||||||
<lst name="responseHeader">
|
<lst name="responseHeader">
|
||||||
<int name="status">0</int>
|
<int name="status">0</int>
|
||||||
|
@ -83,7 +83,7 @@ class TestBaseEngine(SearxTestCase):
|
||||||
</result>
|
</result>
|
||||||
</response>"""
|
</response>"""
|
||||||
|
|
||||||
response = mock.Mock(text=xml_mock.encode('utf-8'))
|
response = mock.Mock(content=xml_mock)
|
||||||
results = base.response(response)
|
results = base.response(response)
|
||||||
self.assertEqual(type(results), list)
|
self.assertEqual(type(results), list)
|
||||||
self.assertEqual(len(results), 1)
|
self.assertEqual(len(results), 1)
|
||||||
|
|
Loading…
Reference in a new issue