summaryrefslogtreecommitdiff
path: root/tests/unit/engines/test_bing.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2016-12-28 20:09:57 +0100
committerGitHub <noreply@github.com>2016-12-28 20:09:57 +0100
commit9743bde25ef2ce6b765b8192aafcdc0a15739b17 (patch)
tree00fd6b0b14773c0e20425d4a6478d67f244d64ed /tests/unit/engines/test_bing.py
parentea034fafa994227ea89662710901e73cb901e28c (diff)
parent8bff42f049dcac77559beaf2932a47921feb1d49 (diff)
Merge pull request #748 from a01200356/languages
[mod] Allow users to search in most engine supported languages
Diffstat (limited to 'tests/unit/engines/test_bing.py')
-rw-r--r--tests/unit/engines/test_bing.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/unit/engines/test_bing.py b/tests/unit/engines/test_bing.py
index 886584229..61f8629d0 100644
--- a/tests/unit/engines/test_bing.py
+++ b/tests/unit/engines/test_bing.py
@@ -86,3 +86,35 @@ class TestBingEngine(SearxTestCase):
self.assertEqual(results[0]['title'], 'This should be the title')
self.assertEqual(results[0]['url'], 'http://this.should.be.the.link/')
self.assertEqual(results[0]['content'], 'This should be the content.')
+
+ def test_fetch_supported_languages(self):
+ html = """<html></html>"""
+ response = mock.Mock(text=html)
+ results = bing._fetch_supported_languages(response)
+ self.assertEqual(type(results), list)
+ self.assertEqual(len(results), 0)
+
+ html = """
+ <html>
+ <body>
+ <form>
+ <div id="limit-languages">
+ <div>
+ <div><input id="es" value="es"></input></div>
+ </div>
+ <div>
+ <div><input id="pt_BR" value="pt_BR"></input></div>
+ <div><input id="pt_PT" value="pt_PT"></input></div>
+ </div>
+ </div>
+ </form>
+ </body>
+ </html>
+ """
+ response = mock.Mock(text=html)
+ languages = bing._fetch_supported_languages(response)
+ self.assertEqual(type(languages), list)
+ self.assertEqual(len(languages), 3)
+ self.assertIn('es', languages)
+ self.assertIn('pt-BR', languages)
+ self.assertIn('pt-PT', languages)