Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
infra
spot
Commits
b63d645a
Commit
b63d645a
authored
Jan 06, 2019
by
Noémi Ványi
Browse files
Revert "remove 'all' option from search languages"
This reverts commit
4d177039
.
parent
491792c1
Changes
51
Hide whitespace changes
Inline
Side-by-side
tests/unit/engines/test_qwant.py
View file @
b63d645a
...
...
@@ -21,11 +21,10 @@ class TestQwantEngine(SearxTestCase):
self
.
assertIn
(
'qwant.com'
,
params
[
'url'
])
self
.
assertIn
(
'fr_fr'
,
params
[
'url'
])
dicto
[
'language'
]
=
'
en-US
'
dicto
[
'language'
]
=
'
all
'
qwant
.
categories
=
[
'news'
]
params
=
qwant
.
request
(
query
,
dicto
)
self
.
assertFalse
(
'fr'
in
params
[
'url'
])
self
.
assertIn
(
'en_us'
,
params
[
'url'
])
self
.
assertIn
(
'news'
,
params
[
'url'
])
dicto
[
'language'
]
=
'fr'
...
...
tests/unit/engines/test_startpage.py
View file @
b63d645a
...
...
@@ -21,6 +21,10 @@ class TestStartpageEngine(SearxTestCase):
self
.
assertIn
(
'with_language'
,
params
[
'data'
])
self
.
assertIn
(
'lang_fr'
,
params
[
'data'
][
'with_language'
])
dicto
[
'language'
]
=
'all'
params
=
startpage
.
request
(
query
,
dicto
)
self
.
assertNotIn
(
'with_language'
,
params
[
'data'
])
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
startpage
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
startpage
.
response
,
[])
...
...
tests/unit/engines/test_subtitleseeker.py
View file @
b63d645a
...
...
@@ -73,6 +73,42 @@ class TestSubtitleseekerEngine(SearxTestCase):
results
=
subtitleseeker
.
response
(
response
)
self
.
assertEqual
(
results
[
0
][
'url'
],
'http://this.is.the.url/Brazilian/'
)
html
=
"""
<div class="boxRows">
<div class="boxRowsInner" style="width:600px;">
<img src="http://static.subtitleseeker.com/images/movie.gif"
style="width:16px; height:16px;" class="icon">
<a href="http://this.is.the.url/"
class="blue" title="Title subtitle" >
This is the Title
</a>
</div>
<div class="boxRowsInner f12b red" style="width:70px;">
1998
</div>
<div class="boxRowsInner grey-web f12" style="width:120px;">
<img src="http://static.subtitleseeker.com/images/basket_put.png"
style="width:16px; height:16px;" class="icon">
1039 Subs
</div>
<div class="boxRowsInner grey-web f10" style="width:130px;">
<img src="http://static.subtitleseeker.com/images/arrow_refresh_small.png"
style="width:16px; height:16px;" class="icon">
1 hours ago
</div>
<div class="clear"></div>
</div>
"""
dicto
[
'language'
]
=
'all'
response
=
mock
.
Mock
(
text
=
html
,
search_params
=
dicto
)
results
=
subtitleseeker
.
response
(
response
)
self
.
assertEqual
(
type
(
results
),
list
)
self
.
assertEqual
(
len
(
results
),
1
)
self
.
assertEqual
(
results
[
0
][
'title'
],
'This is the Title'
)
self
.
assertEqual
(
results
[
0
][
'url'
],
'http://this.is.the.url/'
)
self
.
assertIn
(
'1998'
,
results
[
0
][
'content'
])
self
.
assertIn
(
'1039 Subs'
,
results
[
0
][
'content'
])
html
=
"""
<div class="boxRows">
<div class="boxRowsInner" style="width:600px;">
...
...
tests/unit/engines/test_swisscows.py
View file @
b63d645a
...
...
@@ -20,6 +20,11 @@ class TestSwisscowsEngine(SearxTestCase):
self
.
assertTrue
(
'uiLanguage=de'
in
params
[
'url'
])
self
.
assertTrue
(
'region=de-DE'
in
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
swisscows
.
request
(
query
,
dicto
)
self
.
assertTrue
(
'uiLanguage=browser'
in
params
[
'url'
])
self
.
assertTrue
(
'region=browser'
in
params
[
'url'
])
dicto
[
'category'
]
=
'images'
params
=
swisscows
.
request
(
query
,
dicto
)
self
.
assertIn
(
'image'
,
params
[
'url'
])
...
...
tests/unit/engines/test_twitter.py
View file @
b63d645a
...
...
@@ -20,6 +20,12 @@ class TestTwitterEngine(SearxTestCase):
self
.
assertIn
(
'lang'
,
params
[
'cookies'
])
self
.
assertIn
(
'fr'
,
params
[
'cookies'
][
'lang'
])
dicto
[
'language'
]
=
'all'
params
=
twitter
.
request
(
query
,
dicto
)
self
.
assertIn
(
'cookies'
,
params
)
self
.
assertIn
(
'lang'
,
params
[
'cookies'
])
self
.
assertIn
(
'en'
,
params
[
'cookies'
][
'lang'
])
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
twitter
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
twitter
.
response
,
[])
...
...
tests/unit/engines/test_wikidata.py
View file @
b63d645a
...
...
@@ -11,11 +11,13 @@ class TestWikidataEngine(SearxTestCase):
def
test_request
(
self
):
query
=
'test_query'
dicto
=
defaultdict
(
dict
)
dicto
[
'language'
]
=
'all'
params
=
wikidata
.
request
(
query
,
dicto
)
self
.
assertIn
(
'url'
,
params
)
self
.
assertIn
(
query
,
params
[
'url'
])
self
.
assertIn
(
'wikidata.org'
,
params
[
'url'
])
dicto
[
'language'
]
=
'es_ES'
params
=
wikidata
.
request
(
query
,
dicto
)
self
.
assertIn
(
query
,
params
[
'url'
])
...
...
tests/unit/engines/test_wikipedia.py
View file @
b63d645a
...
...
@@ -26,9 +26,15 @@ class TestWikipediaEngine(SearxTestCase):
self
.
assertIn
(
'Test_Query'
,
params
[
'url'
])
self
.
assertNotIn
(
'test_query'
,
params
[
'url'
])
<<<<<<<
HEAD
dicto
[
'language'
]
=
'nb'
params
=
wikipedia
.
request
(
query
,
dicto
)
self
.
assertIn
(
'no.wikipedia.org'
,
params
[
'url'
])
=======
dicto
[
'language'
]
=
'all'
params
=
wikipedia
.
request
(
query
,
dicto
)
self
.
assertIn
(
'en'
,
params
[
'url'
])
>>>>>>>
Revert
"remove 'all' option from search languages"
dicto
[
'language'
]
=
'xx'
params
=
wikipedia
.
request
(
query
,
dicto
)
...
...
tests/unit/engines/test_yacy.py
View file @
b63d645a
...
...
@@ -17,6 +17,11 @@ class TestYacyEngine(SearxTestCase):
self
.
assertIn
(
'localhost'
,
params
[
'url'
])
self
.
assertIn
(
'fr'
,
params
[
'url'
])
dicto
[
'language'
]
=
'all'
params
=
yacy
.
request
(
query
,
dicto
)
self
.
assertIn
(
'url'
,
params
)
self
.
assertNotIn
(
'lr=lang_'
,
params
[
'url'
])
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
yacy
.
response
,
None
)
self
.
assertRaises
(
AttributeError
,
yacy
.
response
,
[])
...
...
tests/unit/engines/test_yahoo.py
View file @
b63d645a
...
...
@@ -50,6 +50,13 @@ class TestYahooEngine(SearxTestCase):
self
.
assertIn
(
'zh_cht'
,
params
[
'url'
])
self
.
assertIn
(
'zh_cht'
,
params
[
'cookies'
][
'sB'
])
dicto
[
'language'
]
=
'all'
params
=
yahoo
.
request
(
query
,
dicto
)
self
.
assertIn
(
'cookies'
,
params
)
self
.
assertIn
(
'sB'
,
params
[
'cookies'
])
self
.
assertIn
(
'en'
,
params
[
'cookies'
][
'sB'
])
self
.
assertIn
(
'en'
,
params
[
'url'
])
def
test_no_url_in_request_year_time_range
(
self
):
dicto
=
defaultdict
(
dict
)
query
=
'test_query'
...
...
tests/unit/engines/test_yahoo_news.py
View file @
b63d645a
...
...
@@ -23,6 +23,13 @@ class TestYahooNewsEngine(SearxTestCase):
self
.
assertIn
(
'sB'
,
params
[
'cookies'
])
self
.
assertIn
(
'fr'
,
params
[
'cookies'
][
'sB'
])
dicto
[
'language'
]
=
'all'
params
=
yahoo_news
.
request
(
query
,
dicto
)
self
.
assertIn
(
'cookies'
,
params
)
self
.
assertIn
(
'sB'
,
params
[
'cookies'
])
self
.
assertIn
(
'en'
,
params
[
'cookies'
][
'sB'
])
self
.
assertIn
(
'en'
,
params
[
'url'
])
def
test_sanitize_url
(
self
):
url
=
"test.url"
self
.
assertEqual
(
url
,
yahoo_news
.
sanitize_url
(
url
))
...
...
tests/unit/test_preferences.py
View file @
b63d645a
...
...
@@ -90,30 +90,25 @@ class TestSettings(SearxTestCase):
# search language settings
def
test_lang_setting_valid_choice
(
self
):
setting
=
SearchLanguageSetting
(
'
en
'
,
choices
=
[
'de'
,
'en'
])
setting
=
SearchLanguageSetting
(
'
all
'
,
choices
=
[
'all'
,
'de'
,
'en'
])
setting
.
parse
(
'de'
)
self
.
assertEquals
(
setting
.
get_value
(),
'de'
)
def
test_lang_setting_invalid_choice
(
self
):
setting
=
SearchLanguageSetting
(
'
en
'
,
choices
=
[
'de'
,
'en'
])
setting
=
SearchLanguageSetting
(
'
all
'
,
choices
=
[
'all'
,
'de'
,
'en'
])
setting
.
parse
(
'xx'
)
self
.
assertEquals
(
setting
.
get_value
(),
'
en
'
)
self
.
assertEquals
(
setting
.
get_value
(),
'
all
'
)
def
test_lang_setting_old_cookie_choice
(
self
):
setting
=
SearchLanguageSetting
(
'
en
'
,
choices
=
[
'
en
'
,
'es'
,
'es-ES'
])
setting
=
SearchLanguageSetting
(
'
all
'
,
choices
=
[
'
all
'
,
'es'
,
'es-ES'
])
setting
.
parse
(
'es_XA'
)
self
.
assertEquals
(
setting
.
get_value
(),
'es'
)
def
test_lang_setting_old_cookie_format
(
self
):
setting
=
SearchLanguageSetting
(
'
en
'
,
choices
=
[
'
en
'
,
'es'
,
'es-ES'
])
setting
=
SearchLanguageSetting
(
'
all
'
,
choices
=
[
'
all
'
,
'es'
,
'es-ES'
])
setting
.
parse
(
'es_ES'
)
self
.
assertEquals
(
setting
.
get_value
(),
'es-ES'
)
def
test_lang_setting_old_default
(
self
):
setting
=
SearchLanguageSetting
(
'en'
,
choices
=
[
'en'
,
'es'
,
'de'
])
setting
.
parse
(
'all'
)
self
.
assertEquals
(
setting
.
get_value
(),
'en'
)
# plugins settings
def
test_plugins_setting_all_default_enabled
(
self
):
plugin1
=
PluginStub
(
'plugin1'
,
True
)
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment