mirror of
https://github.com/searxng/searxng
synced 2024-11-07 03:20:28 +00:00
Correct a few UT
This commit is contained in:
parent
aea0f866f6
commit
56ad00bc32
@ -12,9 +12,14 @@ class TestBlekkoImagesEngine(SearxTestCase):
|
|||||||
dicto['pageno'] = 0
|
dicto['pageno'] = 0
|
||||||
dicto['safesearch'] = 1
|
dicto['safesearch'] = 1
|
||||||
params = blekko_images.request(query, dicto)
|
params = blekko_images.request(query, dicto)
|
||||||
self.assertTrue('url' in params)
|
self.assertIn('url', params)
|
||||||
self.assertTrue(query in params['url'])
|
self.assertIn(query, params['url'])
|
||||||
self.assertTrue('blekko.com' in params['url'])
|
self.assertIn('blekko.com', params['url'])
|
||||||
|
self.assertIn('page', params['url'])
|
||||||
|
|
||||||
|
dicto['pageno'] = 1
|
||||||
|
params = blekko_images.request(query, dicto)
|
||||||
|
self.assertNotIn('page', params['url'])
|
||||||
|
|
||||||
def test_response(self):
|
def test_response(self):
|
||||||
self.assertRaises(AttributeError, blekko_images.response, None)
|
self.assertRaises(AttributeError, blekko_images.response, None)
|
||||||
|
@ -11,9 +11,14 @@ class TestGoogleImagesEngine(SearxTestCase):
|
|||||||
dicto = defaultdict(dict)
|
dicto = defaultdict(dict)
|
||||||
dicto['pageno'] = 1
|
dicto['pageno'] = 1
|
||||||
params = google_images.request(query, dicto)
|
params = google_images.request(query, dicto)
|
||||||
self.assertTrue('url' in params)
|
self.assertIn('url', params)
|
||||||
self.assertTrue(query in params['url'])
|
self.assertIn(query, params['url'])
|
||||||
self.assertTrue('googleapis.com' in params['url'])
|
self.assertIn('googleapis.com', params['url'])
|
||||||
|
self.assertIn('safe=on', params['url'])
|
||||||
|
|
||||||
|
dicto['safesearch'] = 0
|
||||||
|
params = google_images.request(query, dicto)
|
||||||
|
self.assertIn('safe=off', params['url'])
|
||||||
|
|
||||||
def test_response(self):
|
def test_response(self):
|
||||||
self.assertRaises(AttributeError, google_images.response, None)
|
self.assertRaises(AttributeError, google_images.response, None)
|
||||||
|
@ -75,12 +75,6 @@ class TestYahooEngine(SearxTestCase):
|
|||||||
<li>
|
<li>
|
||||||
<div class="dd algo lst Sr">
|
<div class="dd algo lst Sr">
|
||||||
<div class="compTitle">
|
<div class="compTitle">
|
||||||
<h3 class="title"><a class=" td-u" href="http://r.search.yahoo.com/_ylt=AwrBT7zgEudUW.wAe2ZXNyoA;
|
|
||||||
_ylu=X3oDMTBybGY3bmpvBGNvbG8DYmYxBHBvcwMyBHZ0aWQDBHNlYwNzcg--/RV=2\/RE=1424458593/RO=10
|
|
||||||
/RU=https%3a%2f%2fthis.is.the.second.url%2f/RK=0/RS=jIctjj_cBH1Efj88GCgHKp3__Qk-"
|
|
||||||
target="_blank" data-bid="54e712e136926">
|
|
||||||
This is the second <b><b>title</b></b></a>
|
|
||||||
</h3>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="compText aAbs">
|
<div class="compText aAbs">
|
||||||
<p class="lh-18">This is the second content</p>
|
<p class="lh-18">This is the second content</p>
|
||||||
@ -102,16 +96,12 @@ class TestYahooEngine(SearxTestCase):
|
|||||||
"""
|
"""
|
||||||
response = mock.Mock(text=html)
|
response = mock.Mock(text=html)
|
||||||
results = yahoo.response(response)
|
results = yahoo.response(response)
|
||||||
print results
|
|
||||||
self.assertEqual(type(results), list)
|
self.assertEqual(type(results), list)
|
||||||
self.assertEqual(len(results), 3)
|
self.assertEqual(len(results), 2)
|
||||||
self.assertEqual(results[0]['title'], 'This is the title')
|
self.assertEqual(results[0]['title'], 'This is the title')
|
||||||
self.assertEqual(results[0]['url'], 'https://this.is.the.url/')
|
self.assertEqual(results[0]['url'], 'https://this.is.the.url/')
|
||||||
self.assertEqual(results[0]['content'], 'This is the content')
|
self.assertEqual(results[0]['content'], 'This is the content')
|
||||||
self.assertEqual(results[1]['title'], 'This is the second title')
|
self.assertEqual(results[1]['suggestion'], 'This is the suggestion')
|
||||||
self.assertEqual(results[1]['url'], 'https://this.is.the.second.url/')
|
|
||||||
self.assertEqual(results[1]['content'], 'This is the second content')
|
|
||||||
self.assertEqual(results[2]['suggestion'], 'This is the suggestion')
|
|
||||||
|
|
||||||
html = """
|
html = """
|
||||||
<ol class="reg mb-15 searchCenterMiddle">
|
<ol class="reg mb-15 searchCenterMiddle">
|
||||||
|
Loading…
Reference in New Issue
Block a user