diff options
author | Marc Abonce Seguin <marc-abonce@mailbox.org> | 2018-11-25 23:32:48 -0600 |
---|---|---|
committer | Marc Abonce Seguin <marc-abonce@mailbox.org> | 2019-01-06 20:31:57 -0600 |
commit | 5568f24d6ca9ae9a7eca27c107982b2689e40105 (patch) | |
tree | c67749e9dfeb4a27cef9a550fe366b291ead3373 /tests | |
parent | 3c95d64ff8f5f42a69b05d721265c6e484edc451 (diff) | |
download | searxng-5568f24d6ca9ae9a7eca27c107982b2689e40105.tar.gz searxng-5568f24d6ca9ae9a7eca27c107982b2689e40105.zip |
[fix] check language aliases when setting search language
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/engines/test_bing_images.py | 1 | ||||
-rw-r--r-- | tests/unit/engines/test_bing_videos.py | 1 | ||||
-rw-r--r-- | tests/unit/engines/test_google.py | 9 | ||||
-rw-r--r-- | tests/unit/engines/test_google_news.py | 1 | ||||
-rw-r--r-- | tests/unit/engines/test_qwant.py | 1 | ||||
-rw-r--r-- | tests/unit/engines/test_swisscows.py | 1 | ||||
-rw-r--r-- | tests/unit/engines/test_wikidata.py | 1 | ||||
-rw-r--r-- | tests/unit/engines/test_wikipedia.py | 9 |
8 files changed, 21 insertions, 3 deletions
diff --git a/tests/unit/engines/test_bing_images.py b/tests/unit/engines/test_bing_images.py index cb1d550d9..e65e6cc04 100644 --- a/tests/unit/engines/test_bing_images.py +++ b/tests/unit/engines/test_bing_images.py @@ -9,6 +9,7 @@ class TestBingImagesEngine(SearxTestCase): def test_request(self): bing_images.supported_languages = ['fr-FR', 'en-US'] + bing_images.language_aliases = {} query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 1 diff --git a/tests/unit/engines/test_bing_videos.py b/tests/unit/engines/test_bing_videos.py index 24387c888..1ae1fad37 100644 --- a/tests/unit/engines/test_bing_videos.py +++ b/tests/unit/engines/test_bing_videos.py @@ -9,6 +9,7 @@ class TestBingVideosEngine(SearxTestCase): def test_request(self): bing_videos.supported_languages = ['fr-FR', 'en-US'] + bing_videos.language_aliases = {} query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 1 diff --git a/tests/unit/engines/test_google.py b/tests/unit/engines/test_google.py index 413b67769..5282c6713 100644 --- a/tests/unit/engines/test_google.py +++ b/tests/unit/engines/test_google.py @@ -15,7 +15,8 @@ class TestGoogleEngine(SearxTestCase): return response def test_request(self): - google.supported_languages = ['en', 'fr', 'zh-CN'] + google.supported_languages = ['en', 'fr', 'zh-CN', 'iw'] + google.language_aliases = {'he': 'iw'} query = 'test_query' dicto = defaultdict(dict) @@ -41,6 +42,12 @@ class TestGoogleEngine(SearxTestCase): self.assertIn('zh-CN', params['url']) self.assertIn('zh-CN', params['headers']['Accept-Language']) + dicto['language'] = 'he' + params = google.request(query, dicto) + self.assertIn('google.com', params['url']) + self.assertIn('iw', params['url']) + self.assertIn('iw', params['headers']['Accept-Language']) + def test_response(self): self.assertRaises(AttributeError, google.response, None) self.assertRaises(AttributeError, google.response, []) diff --git a/tests/unit/engines/test_google_news.py b/tests/unit/engines/test_google_news.py index a041a79b9..f363444be 100644 --- a/tests/unit/engines/test_google_news.py +++ b/tests/unit/engines/test_google_news.py @@ -10,6 +10,7 @@ class TestGoogleNewsEngine(SearxTestCase): def test_request(self): google_news.supported_languages = ['en-US', 'fr-FR'] + google_news.language_aliases = {} query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 1 diff --git a/tests/unit/engines/test_qwant.py b/tests/unit/engines/test_qwant.py index 86bfb22da..0cd1bd832 100644 --- a/tests/unit/engines/test_qwant.py +++ b/tests/unit/engines/test_qwant.py @@ -8,6 +8,7 @@ class TestQwantEngine(SearxTestCase): def test_request(self): qwant.supported_languages = ['en-US', 'fr-CA', 'fr-FR'] + qwant.language_aliases = {} query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 0 diff --git a/tests/unit/engines/test_swisscows.py b/tests/unit/engines/test_swisscows.py index 133f636de..6013abd89 100644 --- a/tests/unit/engines/test_swisscows.py +++ b/tests/unit/engines/test_swisscows.py @@ -8,6 +8,7 @@ class TestSwisscowsEngine(SearxTestCase): def test_request(self): swisscows.supported_languages = ['de-AT', 'de-DE'] + swisscows.language_aliases = {} query = 'test_query' dicto = defaultdict(dict) dicto['pageno'] = 1 diff --git a/tests/unit/engines/test_wikidata.py b/tests/unit/engines/test_wikidata.py index 62a409781..e5870fd00 100644 --- a/tests/unit/engines/test_wikidata.py +++ b/tests/unit/engines/test_wikidata.py @@ -27,6 +27,7 @@ class TestWikidataEngine(SearxTestCase): self.assertRaises(AttributeError, wikidata.response, '[]') wikidata.supported_languages = ['en', 'es'] + wikidata.language_aliases = {} response = mock.Mock(text='<html></html>', search_params={"language": "en"}) self.assertEqual(wikidata.response(response), []) diff --git a/tests/unit/engines/test_wikipedia.py b/tests/unit/engines/test_wikipedia.py index 21d0225ed..5b7408f41 100644 --- a/tests/unit/engines/test_wikipedia.py +++ b/tests/unit/engines/test_wikipedia.py @@ -8,7 +8,8 @@ from searx.testing import SearxTestCase class TestWikipediaEngine(SearxTestCase): def test_request(self): - wikipedia.supported_languages = ['fr', 'en'] + wikipedia.supported_languages = ['fr', 'en', 'no'] + wikipedia.language_aliases = {'nb': 'no'} query = 'test_query' dicto = defaultdict(dict) @@ -25,9 +26,13 @@ class TestWikipediaEngine(SearxTestCase): self.assertIn('Test_Query', params['url']) self.assertNotIn('test_query', params['url']) + dicto['language'] = 'nb' + params = wikipedia.request(query, dicto) + self.assertIn('no.wikipedia.org', params['url']) + dicto['language'] = 'xx' params = wikipedia.request(query, dicto) - self.assertIn('en', params['url']) + self.assertIn('en.wikipedia.org', params['url']) def test_response(self): dicto = defaultdict(dict) |