Correct a few UT

This commit is contained in:
Cqoicebordel 2015-02-20 19:03:09 +01:00
parent aea0f866f6
commit 56ad00bc32
3 changed files with 18 additions and 18 deletions

View file

@ -12,9 +12,14 @@ class TestBlekkoImagesEngine(SearxTestCase):
dicto['pageno'] = 0
dicto['safesearch'] = 1
params = blekko_images.request(query, dicto)
self.assertTrue('url' in params)
self.assertTrue(query in params['url'])
self.assertTrue('blekko.com' in params['url'])
self.assertIn('url', params)
self.assertIn(query, 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):
self.assertRaises(AttributeError, blekko_images.response, None)

View file

@ -11,9 +11,14 @@ class TestGoogleImagesEngine(SearxTestCase):
dicto = defaultdict(dict)
dicto['pageno'] = 1
params = google_images.request(query, dicto)
self.assertTrue('url' in params)
self.assertTrue(query in params['url'])
self.assertTrue('googleapis.com' in params['url'])
self.assertIn('url', params)
self.assertIn(query, 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):
self.assertRaises(AttributeError, google_images.response, None)

View file

@ -75,12 +75,6 @@ class TestYahooEngine(SearxTestCase):
<li>
<div class="dd algo lst Sr">
<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 class="compText aAbs">
<p class="lh-18">This is the second content</p>
@ -102,16 +96,12 @@ class TestYahooEngine(SearxTestCase):
"""
response = mock.Mock(text=html)
results = yahoo.response(response)
print results
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]['url'], 'https://this.is.the.url/')
self.assertEqual(results[0]['content'], 'This is the content')
self.assertEqual(results[1]['title'], 'This is the second title')
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')
self.assertEqual(results[1]['suggestion'], 'This is the suggestion')
html = """
<ol class="reg mb-15 searchCenterMiddle">