mirror of
https://github.com/searxng/searxng.git
synced 2025-08-29 06:46:49 +02:00
tests for _fetch_supported_languages in engines
and refactor method to make it testable without making requests
This commit is contained in:
parent
e0c270bd72
commit
af35eee10b
27 changed files with 387 additions and 3388 deletions
|
@ -14,7 +14,6 @@
|
|||
from urllib import urlencode
|
||||
from urlparse import unquote
|
||||
from lxml import html
|
||||
from requests import get
|
||||
from searx.engines.xpath import extract_text, extract_url
|
||||
|
||||
# engine dependent config
|
||||
|
@ -144,13 +143,12 @@ def response(resp):
|
|||
|
||||
|
||||
# get supported languages from their site
|
||||
def fetch_supported_languages():
|
||||
def _fetch_supported_languages(resp):
|
||||
supported_languages = []
|
||||
response = get(supported_languages_url)
|
||||
dom = html.fromstring(response.text)
|
||||
dom = html.fromstring(resp.text)
|
||||
options = dom.xpath('//div[@id="yschlang"]/span/label/input')
|
||||
for option in options:
|
||||
code = option.xpath('./@value')[0][5:]
|
||||
code = option.xpath('./@value')[0][5:].replace('_', '-')
|
||||
supported_languages.append(code)
|
||||
|
||||
return supported_languages
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue