summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2017-02-24 20:21:48 -0600
committerAdam Tauber <asciimoo@gmail.com>2017-03-18 23:44:21 +0100
commit805fb02ed1fb7f8e006c8def7d76a0d1958364bf (patch)
tree530b3b98842965c2343ee5e9568853acc7fd064a /tests
parente4d46d21c7ed2793edf446c4292971a853ed0e3d (diff)
downloadsearxng-805fb02ed1fb7f8e006c8def7d76a0d1958364bf.tar.gz
searxng-805fb02ed1fb7f8e006c8def7d76a0d1958364bf.zip
add language support for qwant
closes issue #863
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/engines/test_qwant.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unit/engines/test_qwant.py b/tests/unit/engines/test_qwant.py
index c4c0b0690..b7133c076 100644
--- a/tests/unit/engines/test_qwant.py
+++ b/tests/unit/engines/test_qwant.py
@@ -25,6 +25,11 @@ class TestQwantEngine(SearxTestCase):
self.assertFalse('fr' in params['url'])
self.assertIn('news', params['url'])
+ qwant.supported_languages = ['en', 'fr-FR', 'fr-CA']
+ dicto['language'] = 'fr'
+ params = qwant.request(query, dicto)
+ self.assertIn('fr_fr', params['url'])
+
def test_response(self):
self.assertRaises(AttributeError, qwant.response, None)
self.assertRaises(AttributeError, qwant.response, [])
@@ -315,3 +320,19 @@ class TestQwantEngine(SearxTestCase):
results = qwant.response(response)
self.assertEqual(type(results), list)
self.assertEqual(len(results), 0)
+
+ def test_fetch_supported_languages(self):
+ page = """some code...
+ config_set('project.regionalisation', {"continents":{},"languages":
+ {"de":{"code":"de","name":"Deutsch","countries":["DE","CH","AT"]},
+ "it":{"code":"it","name":"Italiano","countries":["IT","CH"]}}});
+ some more code..."""
+ response = mock.Mock(text=page)
+ languages = qwant._fetch_supported_languages(response)
+ self.assertEqual(type(languages), list)
+ self.assertEqual(len(languages), 5)
+ self.assertIn('de-DE', languages)
+ self.assertIn('de-CH', languages)
+ self.assertIn('de-AT', languages)
+ self.assertIn('it-IT', languages)
+ self.assertIn('it-CH', languages)