logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git
commit: 56ad00bc3292c345dfaa5a671844e222b5f72e5b
parent aea0f866f62eccbeb0655f436144a41eaf7175fa
Author: Cqoicebordel <Cqoicebordel@users.noreply.github.com>
Date:   Fri, 20 Feb 2015 19:03:09 +0100

Correct a few UT

Diffstat:

Msearx/tests/engines/test_blekko_images.py11++++++++---
Msearx/tests/engines/test_google_images.py11++++++++---
Msearx/tests/engines/test_yahoo.py14++------------
3 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/searx/tests/engines/test_blekko_images.py b/searx/tests/engines/test_blekko_images.py @@ -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) diff --git a/searx/tests/engines/test_google_images.py b/searx/tests/engines/test_google_images.py @@ -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) diff --git a/searx/tests/engines/test_yahoo.py b/searx/tests/engines/test_yahoo.py @@ -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">