diff options
Diffstat (limited to 'tests/unit/engines/test_swisscows.py')
-rw-r--r-- | tests/unit/engines/test_swisscows.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit/engines/test_swisscows.py b/tests/unit/engines/test_swisscows.py index dbbc044da..27f33d70a 100644 --- a/tests/unit/engines/test_swisscows.py +++ b/tests/unit/engines/test_swisscows.py @@ -126,3 +126,30 @@ class TestSwisscowsEngine(SearxTestCase): self.assertEqual(results[2]['url'], 'http://de.wikipedia.org/wiki/Datei:This should.svg') self.assertEqual(results[2]['img_src'], 'http://ts2.mm.This/should.png') self.assertEqual(results[2]['template'], 'images.html') + + def test_fetch_supported_languages(self): + html = """<html></html>""" + response = mock.Mock(text=html) + languages = swisscows._fetch_supported_languages(response) + self.assertEqual(type(languages), list) + self.assertEqual(len(languages), 0) + + html = """ + <html> + <div id="regions-popup"> + <div> + <ul> + <li><a data-val="browser"></a></li> + <li><a data-val="de-CH"></a></li> + <li><a data-val="fr-CH"></a></li> + </ul> + </div> + </div> + </html> + """ + response = mock.Mock(text=html) + languages = swisscows._fetch_supported_languages(response) + self.assertEqual(type(languages), list) + self.assertEqual(len(languages), 3) + self.assertIn('de-CH', languages) + self.assertIn('fr-CH', languages) |