diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/engines/test_qwant.py | 21 |
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) |