Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
searx-engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
searx-engine
Commits
e0c270bd
Commit
e0c270bd
authored
Dec 14, 2016
by
marc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for language support in engines
parent
1b46ecd2
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
5 deletions
+54
-5
.yandex.py.swp
searx/engines/.yandex.py.swp
+0
-0
duckduckgo.py
searx/engines/duckduckgo.py
+4
-2
subtitleseeker.py
searx/engines/subtitleseeker.py
+1
-1
preferences.py
searx/preferences.py
+1
-1
test_duckduckgo.py
tests/unit/engines/test_duckduckgo.py
+11
-0
test_gigablast.py
tests/unit/engines/test_gigablast.py
+6
-0
test_subtitleseeker.py
tests/unit/engines/test_subtitleseeker.py
+5
-0
test_wikipedia.py
tests/unit/engines/test_wikipedia.py
+4
-0
test_preferences.py
tests/unit/test_preferences.py
+22
-1
No files found.
searx/engines/.yandex.py.swp
0 → 100644
View file @
e0c270bd
File added
searx/engines/duckduckgo.py
View file @
e0c270bd
...
...
@@ -53,14 +53,16 @@ def request(query, params):
locale
=
None
elif
params
[
'language'
][:
2
]
==
'ja'
:
locale
=
'jp-jp'
elif
params
[
'language'
][:
2
]
==
'sl'
:
locale
=
'sl-sl'
elif
params
[
'language'
]
==
'zh-TW'
:
locale
=
'tw-tzh'
elif
params
[
'language'
]
==
'zh-HK'
:
locale
=
'hk-tzh'
elif
params
[
'language'
][
-
2
:]
==
'SA'
:
locale
=
'xa'
+
params
[
'language'
]
.
split
(
'-'
)[
0
]
locale
=
'xa
-
'
+
params
[
'language'
]
.
split
(
'-'
)[
0
]
elif
params
[
'language'
][
-
2
:]
==
'GB'
:
locale
=
'uk'
+
params
[
'language'
]
.
split
(
'-'
)[
0
]
locale
=
'uk
-
'
+
params
[
'language'
]
.
split
(
'-'
)[
0
]
else
:
locale
=
params
[
'language'
]
.
split
(
'-'
)
if
len
(
locale
)
==
2
:
...
...
searx/engines/subtitleseeker.py
View file @
e0c270bd
...
...
@@ -46,7 +46,7 @@ def response(resp):
# dirty fix for languages named differenly in their site
if
resp
.
search_params
[
'language'
][:
2
]
==
'fa'
:
search_lang
=
'Farsi'
elif
resp
.
search_params
[
'language'
]
==
'pt
_
BR'
:
elif
resp
.
search_params
[
'language'
]
==
'pt
-
BR'
:
search_lang
=
'Brazilian'
elif
resp
.
search_params
[
'language'
]
!=
'all'
:
search_lang
=
[
lc
[
3
]
...
...
searx/preferences.py
View file @
e0c270bd
...
...
@@ -110,7 +110,7 @@ class SearchLanguageSetting(EnumStringSetting):
elif
data
==
'ar-XA'
:
data
=
'ar-SA'
else
:
data
=
'all'
data
=
self
.
value
self
.
value
=
data
...
...
tests/unit/engines/test_duckduckgo.py
View file @
e0c270bd
...
...
@@ -19,6 +19,17 @@ class TestDuckduckgoEngine(SearxTestCase):
self
.
assertIn
(
'duckduckgo.com'
,
params
[
'url'
])
self
.
assertIn
(
'ch-de'
,
params
[
'url'
])
# when ddg uses non standard code
dicto
[
'language'
]
=
'en-GB'
params
=
duckduckgo
.
request
(
query
,
dicto
)
self
.
assertIn
(
'uk-en'
,
params
[
'url'
])
# no country given
duckduckgo
.
supported_languages
=
[
'de-CH'
,
'en-US'
]
dicto
[
'language'
]
=
'de'
params
=
duckduckgo
.
request
(
query
,
dicto
)
self
.
assertIn
(
'ch-de'
,
params
[
'url'
])
def
test_no_url_in_request_year_time_range
(
self
):
dicto
=
defaultdict
(
dict
)
query
=
'test_query'
...
...
tests/unit/engines/test_gigablast.py
View file @
e0c270bd
...
...
@@ -15,6 +15,12 @@ class TestGigablastEngine(SearxTestCase):
self
.
assertTrue
(
'url'
in
params
)
self
.
assertTrue
(
query
in
params
[
'url'
])
self
.
assertTrue
(
'gigablast.com'
in
params
[
'url'
])
self
.
assertTrue
(
'xx'
in
params
[
'url'
])
dicto
[
'language'
]
=
'en-US'
params
=
gigablast
.
request
(
query
,
dicto
)
self
.
assertTrue
(
'en'
in
params
[
'url'
])
self
.
assertFalse
(
'en-US'
in
params
[
'url'
])
def
test_response
(
self
):
self
.
assertRaises
(
AttributeError
,
gigablast
.
response
,
None
)
...
...
tests/unit/engines/test_subtitleseeker.py
View file @
e0c270bd
...
...
@@ -10,6 +10,7 @@ class TestSubtitleseekerEngine(SearxTestCase):
query
=
'test_query'
dicto
=
defaultdict
(
dict
)
dicto
[
'pageno'
]
=
1
dicto
[
'language'
]
=
'fr-FR'
params
=
subtitleseeker
.
request
(
query
,
dicto
)
self
.
assertTrue
(
'url'
in
params
)
self
.
assertTrue
(
query
in
params
[
'url'
])
...
...
@@ -68,6 +69,10 @@ class TestSubtitleseekerEngine(SearxTestCase):
self
.
assertIn
(
'1039 Subs'
,
results
[
0
][
'content'
])
self
.
assertIn
(
'Alternative Title'
,
results
[
0
][
'content'
])
dicto
[
'language'
]
=
'pt-BR'
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;">
...
...
tests/unit/engines/test_wikipedia.py
View file @
e0c270bd
...
...
@@ -29,6 +29,10 @@ class TestWikipediaEngine(SearxTestCase):
params
=
wikipedia
.
request
(
query
,
dicto
)
self
.
assertIn
(
'en'
,
params
[
'url'
])
dicto
[
'language'
]
=
'xx'
params
=
wikipedia
.
request
(
query
,
dicto
)
self
.
assertIn
(
'en'
,
params
[
'url'
])
def
test_response
(
self
):
dicto
=
defaultdict
(
dict
)
dicto
[
'language'
]
=
'fr'
...
...
tests/unit/test_preferences.py
View file @
e0c270bd
from
searx.preferences
import
(
EnumStringSetting
,
MapSetting
,
MissingArgumentException
,
from
searx.preferences
import
(
EnumStringSetting
,
MapSetting
,
MissingArgumentException
,
SearchLanguageSetting
,
MultipleChoiceSetting
,
PluginsSetting
,
ValidationException
)
from
searx.testing
import
SearxTestCase
...
...
@@ -88,6 +88,27 @@ class TestSettings(SearxTestCase):
setting
.
parse
(
'2'
)
self
.
assertEquals
(
setting
.
get_value
(),
[
'2'
])
# search language settings
def
test_lang_setting_valid_choice
(
self
):
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
(
'all'
,
choices
=
[
'all'
,
'de'
,
'en'
])
setting
.
parse
(
'xx'
)
self
.
assertEquals
(
setting
.
get_value
(),
'all'
)
def
test_lang_setting_old_cookie_choice
(
self
):
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
(
'all'
,
choices
=
[
'all'
,
'es'
,
'es-ES'
])
setting
.
parse
(
'es_ES'
)
self
.
assertEquals
(
setting
.
get_value
(),
'es-ES'
)
# plugins settings
def
test_plugins_setting_all_default_enabled
(
self
):
plugin1
=
PluginStub
(
'plugin1'
,
True
)
...
...
Write
Preview
Markdown
is supported
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