From 772c048d01c7585fd60afca1ce30a1914e6e5b4a Mon Sep 17 00:00:00 2001 From: Marc Abonce Seguin Date: Wed, 28 Feb 2018 22:30:48 -0600 Subject: refactor engine's search language handling Add match_language function in utils to match any user given language code with a list of engine's supported languages. Also add language_aliases dict on each engine to translate standard language codes into the custom codes used by the engine. --- tests/unit/engines/test_wikidata.py | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/unit/engines/test_wikidata.py') diff --git a/tests/unit/engines/test_wikidata.py b/tests/unit/engines/test_wikidata.py index 453133b64..1ad21768c 100644 --- a/tests/unit/engines/test_wikidata.py +++ b/tests/unit/engines/test_wikidata.py @@ -9,6 +9,7 @@ from searx.testing import SearxTestCase class TestWikidataEngine(SearxTestCase): def test_request(self): + wikidata.supported_languages = ['en', 'es'] query = 'test_query' dicto = defaultdict(dict) dicto['language'] = 'en-US' -- cgit v1.2.3 From 96877862269f35aefc0b3ca7a7cb8812b1555dc4 Mon Sep 17 00:00:00 2001 From: Marc Abonce Seguin Date: Sun, 8 Apr 2018 23:31:24 -0500 Subject: update unit tests for google news and wikidata --- tests/unit/engines/test_wikidata.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tests/unit/engines/test_wikidata.py') diff --git a/tests/unit/engines/test_wikidata.py b/tests/unit/engines/test_wikidata.py index 1ad21768c..545ef9ed8 100644 --- a/tests/unit/engines/test_wikidata.py +++ b/tests/unit/engines/test_wikidata.py @@ -9,20 +9,15 @@ from searx.testing import SearxTestCase class TestWikidataEngine(SearxTestCase): def test_request(self): - wikidata.supported_languages = ['en', 'es'] query = 'test_query' dicto = defaultdict(dict) - dicto['language'] = 'en-US' params = wikidata.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) self.assertIn('wikidata.org', params['url']) - self.assertIn('en', params['url']) - dicto['language'] = 'es-ES' params = wikidata.request(query, dicto) self.assertIn(query, params['url']) - self.assertIn('es', params['url']) # successful cases are not tested here to avoid sending additional requests def test_response(self): @@ -31,6 +26,7 @@ class TestWikidataEngine(SearxTestCase): self.assertRaises(AttributeError, wikidata.response, '') self.assertRaises(AttributeError, wikidata.response, '[]') + wikidata.supported_languages = ['en', 'es'] response = mock.Mock(text='', search_params={"language": "en"}) self.assertEqual(wikidata.response(response), []) -- cgit v1.2.3 From 0a37f909900f3d4a04c963430c93977d2c96f520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Bourrel?= Date: Fri, 6 Jul 2018 11:15:43 +0200 Subject: Fix wikidata tests with updated path to media --- tests/unit/engines/test_wikidata.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'tests/unit/engines/test_wikidata.py') diff --git a/tests/unit/engines/test_wikidata.py b/tests/unit/engines/test_wikidata.py index 545ef9ed8..62a409781 100644 --- a/tests/unit/engines/test_wikidata.py +++ b/tests/unit/engines/test_wikidata.py @@ -123,9 +123,10 @@ class TestWikidataEngine(SearxTestCase):
- - image.png - +
+ image.png +
2,687 × 3,356; 1.22 MB +
@@ -156,9 +157,10 @@ class TestWikidataEngine(SearxTestCase):
- - icon.png - +
+ icon.png +
671 × 671; 18 KB
+
@@ -179,9 +181,10 @@ class TestWikidataEngine(SearxTestCase):
- - logo.png - +
+ logo.png +
170 × 170; 1 KB +
-- cgit v1.2.3