From 3f31e1ce6bcaea595a6e773c4ff729cf7a9e31e1 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Tue, 25 Aug 2015 22:56:40 +0200 Subject: [fix] piratebay tld according to wikipedia --- searx/tests/engines/test_piratebay.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'searx/tests') diff --git a/searx/tests/engines/test_piratebay.py b/searx/tests/engines/test_piratebay.py index 6ebbcf713..5699380be 100644 --- a/searx/tests/engines/test_piratebay.py +++ b/searx/tests/engines/test_piratebay.py @@ -15,7 +15,7 @@ class TestPiratebayEngine(SearxTestCase): params = piratebay.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) - self.assertIn('piratebay.am', params['url']) + self.assertIn('piratebay.se', params['url']) self.assertIn('0', params['url']) dicto['category'] = 'music' @@ -99,7 +99,7 @@ class TestPiratebayEngine(SearxTestCase): self.assertEqual(type(results), list) self.assertEqual(len(results), 2) self.assertEqual(results[0]['title'], 'This is the title') - self.assertEqual(results[0]['url'], 'https://thepiratebay.am/this.is.the.link') + self.assertEqual(results[0]['url'], 'https://thepiratebay.se/this.is.the.link') self.assertEqual(results[0]['content'], 'This is the content and should be OK') self.assertEqual(results[0]['seed'], 13) self.assertEqual(results[0]['leech'], 334) @@ -149,7 +149,7 @@ class TestPiratebayEngine(SearxTestCase): self.assertEqual(type(results), list) self.assertEqual(len(results), 1) self.assertEqual(results[0]['title'], 'This is the title') - self.assertEqual(results[0]['url'], 'https://thepiratebay.am/this.is.the.link') + self.assertEqual(results[0]['url'], 'https://thepiratebay.se/this.is.the.link') self.assertEqual(results[0]['content'], 'This is the content and should be OK') self.assertEqual(results[0]['seed'], 0) self.assertEqual(results[0]['leech'], 0) -- cgit v1.2.3 From 604f32f67276a34a3ead265ff89d3bb807902b26 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Fri, 28 Aug 2015 14:51:32 +0200 Subject: [fix] bing unicode encode error - fixes #408 --- searx/tests/engines/test_bing.py | 8 ++++---- searx/tests/engines/test_bing_images.py | 10 +++++----- searx/tests/engines/test_bing_news.py | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'searx/tests') diff --git a/searx/tests/engines/test_bing.py b/searx/tests/engines/test_bing.py index 52a049f01..bce221440 100644 --- a/searx/tests/engines/test_bing.py +++ b/searx/tests/engines/test_bing.py @@ -29,10 +29,10 @@ class TestBingEngine(SearxTestCase): self.assertRaises(AttributeError, bing.response, '') self.assertRaises(AttributeError, bing.response, '[]') - response = mock.Mock(content='') + response = mock.Mock(text='') self.assertEqual(bing.response(response), []) - response = mock.Mock(content='') + response = mock.Mock(text='') self.assertEqual(bing.response(response), []) html = """ @@ -54,7 +54,7 @@ class TestBingEngine(SearxTestCase): """ - response = mock.Mock(content=html) + response = mock.Mock(text=html) results = bing.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) @@ -81,7 +81,7 @@ class TestBingEngine(SearxTestCase): """ - response = mock.Mock(content=html) + response = mock.Mock(text=html) results = bing.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) diff --git a/searx/tests/engines/test_bing_images.py b/searx/tests/engines/test_bing_images.py index f869da79d..f42dff7e8 100644 --- a/searx/tests/engines/test_bing_images.py +++ b/searx/tests/engines/test_bing_images.py @@ -31,10 +31,10 @@ class TestBingImagesEngine(SearxTestCase): self.assertRaises(AttributeError, bing_images.response, '') self.assertRaises(AttributeError, bing_images.response, '[]') - response = mock.Mock(content='') + response = mock.Mock(text='') self.assertEqual(bing_images.response(response), []) - response = mock.Mock(content='') + response = mock.Mock(text='') self.assertEqual(bing_images.response(response), []) html = """ @@ -52,7 +52,7 @@ oh:"238",tft:"0",oi:"http://www.image.url/Images/Test%2 """ html = html.replace('\r\n', '').replace('\n', '').replace('\r', '') - response = mock.Mock(content=html) + response = mock.Mock(text=html) results = bing_images.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) @@ -75,7 +75,7 @@ oh:"238",tft:"0",oi:"http://www.image.url/Images/Test%2 style="height:144px;" width="178" height="144"/> """ - response = mock.Mock(content=html) + response = mock.Mock(text=html) results = bing_images.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 0) @@ -263,7 +263,7 @@ oh:"238",tft:"0",oi:"http://www.image.url/Images/Test%2 """ html = html.replace('\r\n', '').replace('\n', '').replace('\r', '') - response = mock.Mock(content=html) + response = mock.Mock(text=html) results = bing_images.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 10) diff --git a/searx/tests/engines/test_bing_news.py b/searx/tests/engines/test_bing_news.py index a64d59b7b..c6c402650 100644 --- a/searx/tests/engines/test_bing_news.py +++ b/searx/tests/engines/test_bing_news.py @@ -28,10 +28,10 @@ class TestBingNewsEngine(SearxTestCase): self.assertRaises(AttributeError, bing_news.response, '') self.assertRaises(AttributeError, bing_news.response, '[]') - response = mock.Mock(content='') + response = mock.Mock(text='') self.assertEqual(bing_news.response(response), []) - response = mock.Mock(content='') + response = mock.Mock(text='') self.assertEqual(bing_news.response(response), []) html = """ @@ -66,7 +66,7 @@ class TestBingNewsEngine(SearxTestCase): """ # noqa - response = mock.Mock(content=html) + response = mock.Mock(text=html) results = bing_news.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 2) @@ -105,7 +105,7 @@ class TestBingNewsEngine(SearxTestCase): """ # noqa - response = mock.Mock(content=html) + response = mock.Mock(text=html) results = bing_news.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) @@ -128,11 +128,11 @@ class TestBingNewsEngine(SearxTestCase): """ # noqa - response = mock.Mock(content=html) + response = mock.Mock(text=html) results = bing_news.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 0) html = """gabarge""" - response = mock.Mock(content=html) + response = mock.Mock(text=html) self.assertRaises(lxml.etree.XMLSyntaxError, bing_news.response, response) -- cgit v1.2.3 From 7580852bda660471f8968b4f14cdf44dad73249f Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Mon, 7 Sep 2015 19:22:01 +0200 Subject: [enh] test utils.prettify_url --- searx/tests/test_utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'searx/tests') diff --git a/searx/tests/test_utils.py b/searx/tests/test_utils.py index abe411c2b..04480791d 100644 --- a/searx/tests/test_utils.py +++ b/searx/tests/test_utils.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import mock from searx.testing import SearxTestCase from searx import utils @@ -51,6 +52,15 @@ class TestUtils(SearxTestCase): self.assertIsNotNone(utils.html_to_text(html)) self.assertEqual(utils.html_to_text(html), "Test text") + def test_prettify_url(self): + data = (('https://searx.me/', 'https://searx.me/'), + (u'https://searx.me/ű', u'https://searx.me/ű'), + ('https://searx.me/' + (100 * 'a'), 'https://searx.me/[...]aaaaaaaaaaaaaaaaa'), + (u'https://searx.me/' + (100 * u'ű'), u'https://searx.me/[...]űűűűűűűűűűűűűűűűű')) + + for test_url, expected in data: + self.assertEqual(utils.prettify_url(test_url, max_length=32), expected) + class TestHTMLTextExtractor(SearxTestCase): -- cgit v1.2.3 From 4184cece4a0b2d04b45105e755492bfee5fa1a12 Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Mon, 7 Sep 2015 23:13:04 +0200 Subject: [fix] duckduckgo unicode url - #419 --- searx/tests/engines/test_duckduckgo.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'searx/tests') diff --git a/searx/tests/engines/test_duckduckgo.py b/searx/tests/engines/test_duckduckgo.py index 6f085cbc2..14cd9cd87 100644 --- a/searx/tests/engines/test_duckduckgo.py +++ b/searx/tests/engines/test_duckduckgo.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from collections import defaultdict import mock from searx.engines import duckduckgo @@ -30,7 +31,7 @@ class TestDuckduckgoEngine(SearxTestCase): response = mock.Mock(text='') self.assertEqual(duckduckgo.response(response), []) - html = """ + html = u"""