diff options
| author | marc <a01200356@itesm.mx> | 2016-12-15 00:34:43 -0600 |
|---|---|---|
| committer | marc <a01200356@itesm.mx> | 2016-12-15 00:40:21 -0600 |
| commit | af35eee10b98940c51c6e5e18629de514b4bd48d (patch) | |
| tree | 804b0a4cfe08bb897541e9e8571b921a78e07992 /tests/unit/engines/test_yahoo.py | |
| parent | e0c270bd72f7b2a40222e3ed264e25d36cb0fc30 (diff) | |
tests for _fetch_supported_languages in engines
and refactor method to make it testable without making requests
Diffstat (limited to 'tests/unit/engines/test_yahoo.py')
| -rw-r--r-- | tests/unit/engines/test_yahoo.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/unit/engines/test_yahoo.py b/tests/unit/engines/test_yahoo.py index 303295e2f..82c4d99bb 100644 --- a/tests/unit/engines/test_yahoo.py +++ b/tests/unit/engines/test_yahoo.py @@ -147,3 +147,33 @@ class TestYahooEngine(SearxTestCase): results = yahoo.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 0) + + def test_fetch_supported_languages(self): + html = """<html></html>""" + response = mock.Mock(text=html) + results = yahoo._fetch_supported_languages(response) + self.assertEqual(type(results), list) + self.assertEqual(len(results), 0) + + html = """ + <html> + <div> + <div id="yschlang"> + <span> + <label><input value="lang_ar"></input></label> + </span> + <span> + <label><input value="lang_zh_chs"></input></label> + <label><input value="lang_zh_cht"></input></label> + </span> + </div> + </div> + </html> + """ + response = mock.Mock(text=html) + languages = yahoo._fetch_supported_languages(response) + self.assertEqual(type(languages), list) + self.assertEqual(len(languages), 3) + self.assertIn('ar', languages) + self.assertIn('zh-chs', languages) + self.assertIn('zh-cht', languages) |