mirror of https://github.com/searxng/searxng.git
Compare commits
7 Commits
aef22de3c0
...
ae2659d8f0
Author | SHA1 | Date |
---|---|---|
Grant Lanham Jr | ae2659d8f0 | |
Leo Liu | dfaf5868e2 | |
Leo Liu | b173f3a8b9 | |
dependabot[bot] | 2fbf15eccb | |
searxng-bot | 08c5f258d8 | |
Grant Lanham | 6ed37fc9eb | |
Grant Lanham | 6ee5d46c6c |
|
@ -18,4 +18,4 @@ fasttext-predict==0.9.2.2
|
||||||
tomli==2.0.2; python_version < '3.11'
|
tomli==2.0.2; python_version < '3.11'
|
||||||
msgspec==0.18.6
|
msgspec==0.18.6
|
||||||
eval_type_backport; python_version < '3.9'
|
eval_type_backport; python_version < '3.9'
|
||||||
typer-slim==0.12.5
|
typer-slim==0.13.0
|
||||||
|
|
|
@ -479,7 +479,6 @@ class Preferences:
|
||||||
self.plugins = PluginsSetting('plugins', plugins=plugins)
|
self.plugins = PluginsSetting('plugins', plugins=plugins)
|
||||||
self.tokens = SetSetting('tokens')
|
self.tokens = SetSetting('tokens')
|
||||||
self.client = client or ClientPref()
|
self.client = client or ClientPref()
|
||||||
self.unknown_params: Dict[str, str] = {}
|
|
||||||
|
|
||||||
def get_as_url_params(self):
|
def get_as_url_params(self):
|
||||||
"""Return preferences as URL parameters"""
|
"""Return preferences as URL parameters"""
|
||||||
|
@ -523,10 +522,6 @@ class Preferences:
|
||||||
self.plugins.parse_cookie(input_data.get('disabled_plugins', ''), input_data.get('enabled_plugins', ''))
|
self.plugins.parse_cookie(input_data.get('disabled_plugins', ''), input_data.get('enabled_plugins', ''))
|
||||||
elif user_setting_name == 'tokens':
|
elif user_setting_name == 'tokens':
|
||||||
self.tokens.parse(user_setting)
|
self.tokens.parse(user_setting)
|
||||||
elif not any(
|
|
||||||
user_setting_name.startswith(x) for x in ['enabled_', 'disabled_', 'engine_', 'category_', 'plugin_']
|
|
||||||
):
|
|
||||||
self.unknown_params[user_setting_name] = user_setting
|
|
||||||
|
|
||||||
def parse_form(self, input_data: Dict[str, str]):
|
def parse_form(self, input_data: Dict[str, str]):
|
||||||
"""Parse formular (``<input>``) data from a ``flask.request.form``"""
|
"""Parse formular (``<input>``) data from a ``flask.request.form``"""
|
||||||
|
@ -551,8 +546,7 @@ class Preferences:
|
||||||
disabled_plugins.append(user_setting_name)
|
disabled_plugins.append(user_setting_name)
|
||||||
elif user_setting_name == 'tokens':
|
elif user_setting_name == 'tokens':
|
||||||
self.tokens.parse_form(user_setting)
|
self.tokens.parse_form(user_setting)
|
||||||
else:
|
|
||||||
self.unknown_params[user_setting_name] = user_setting
|
|
||||||
self.key_value_settings['categories'].parse_form(enabled_categories)
|
self.key_value_settings['categories'].parse_form(enabled_categories)
|
||||||
self.engines.parse_form(disabled_engines)
|
self.engines.parse_form(disabled_engines)
|
||||||
self.plugins.parse_form(disabled_plugins)
|
self.plugins.parse_form(disabled_plugins)
|
||||||
|
@ -563,8 +557,6 @@ class Preferences:
|
||||||
ret_val = None
|
ret_val = None
|
||||||
if user_setting_name in self.key_value_settings:
|
if user_setting_name in self.key_value_settings:
|
||||||
ret_val = self.key_value_settings[user_setting_name].get_value()
|
ret_val = self.key_value_settings[user_setting_name].get_value()
|
||||||
if user_setting_name in self.unknown_params:
|
|
||||||
ret_val = self.unknown_params[user_setting_name]
|
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|
||||||
def save(self, resp: flask.Response):
|
def save(self, resp: flask.Response):
|
||||||
|
@ -577,8 +569,6 @@ class Preferences:
|
||||||
self.engines.save(resp)
|
self.engines.save(resp)
|
||||||
self.plugins.save(resp)
|
self.plugins.save(resp)
|
||||||
self.tokens.save('tokens', resp)
|
self.tokens.save('tokens', resp)
|
||||||
for k, v in self.unknown_params.items():
|
|
||||||
resp.set_cookie(k, v, max_age=COOKIE_MAX_AGE)
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
def validate_token(self, engine):
|
def validate_token(self, engine):
|
||||||
|
|
|
@ -20,7 +20,7 @@ if (next_call_ts == false or next_call_ts == nil) then
|
||||||
-- 2/ the next call is a random time between start_after_from and start_after_to
|
-- 2/ the next call is a random time between start_after_from and start_after_to
|
||||||
local initial_delay = math.random(start_after_from, start_after_to)
|
local initial_delay = math.random(start_after_from, start_after_to)
|
||||||
redis.call('SET', redis_key, now + initial_delay)
|
redis.call('SET', redis_key, now + initial_delay)
|
||||||
return { false, delay }
|
return { false, initial_delay }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- next_call_ts is defined
|
-- next_call_ts is defined
|
||||||
|
|
|
@ -226,15 +226,12 @@ outgoing:
|
||||||
# - 'Hash plugin'
|
# - 'Hash plugin'
|
||||||
# - 'Self Information'
|
# - 'Self Information'
|
||||||
# - 'Tracker URL remover'
|
# - 'Tracker URL remover'
|
||||||
|
# - 'Unit converter plugin'
|
||||||
# - 'Ahmia blacklist' # activation depends on outgoing.using_tor_proxy
|
# - 'Ahmia blacklist' # activation depends on outgoing.using_tor_proxy
|
||||||
# # these plugins are disabled if nothing is configured ..
|
# # these plugins are disabled if nothing is configured ..
|
||||||
# - 'Hostnames plugin' # see 'hostnames' configuration below
|
# - 'Hostnames plugin' # see 'hostnames' configuration below
|
||||||
# - 'Open Access DOI rewrite'
|
# - 'Open Access DOI rewrite'
|
||||||
# - 'Tor check plugin'
|
# - 'Tor check plugin'
|
||||||
# # Read the docs before activate: auto-detection of the language could be
|
|
||||||
# # detrimental to users expectations / users can activate the plugin in the
|
|
||||||
# # preferences if they want.
|
|
||||||
# - 'Autodetect search language'
|
|
||||||
|
|
||||||
# Configuration of the "Hostnames plugin":
|
# Configuration of the "Hostnames plugin":
|
||||||
#
|
#
|
||||||
|
|
Binary file not shown.
|
@ -39,9 +39,8 @@ msgstr ""
|
||||||
"Project-Id-Version: searx\n"
|
"Project-Id-Version: searx\n"
|
||||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||||
"PO-Revision-Date: 2024-10-26 21:13+0000\n"
|
"PO-Revision-Date: 2024-11-03 09:08+0000\n"
|
||||||
"Last-Translator: Atul_Eterno <Atul_Eterno@users.noreply.translate.codeberg."
|
"Last-Translator: return42 <return42@users.noreply.translate.codeberg.org>\n"
|
||||||
"org>\n"
|
|
||||||
"Language-Team: Spanish <https://translate.codeberg.org/projects/searxng/"
|
"Language-Team: Spanish <https://translate.codeberg.org/projects/searxng/"
|
||||||
"searxng/es/>\n"
|
"searxng/es/>\n"
|
||||||
"Language: es\n"
|
"Language: es\n"
|
||||||
|
@ -1246,7 +1245,7 @@ msgstr "Tiempo máximo"
|
||||||
|
|
||||||
#: searx/templates/simple/preferences/favicon.html:2
|
#: searx/templates/simple/preferences/favicon.html:2
|
||||||
msgid "Favicon Resolver"
|
msgid "Favicon Resolver"
|
||||||
msgstr ""
|
msgstr "Buscador de favicon"
|
||||||
|
|
||||||
#: searx/templates/simple/preferences/favicon.html:15
|
#: searx/templates/simple/preferences/favicon.html:15
|
||||||
msgid "Display favicons near search results"
|
msgid "Display favicons near search results"
|
||||||
|
|
Binary file not shown.
|
@ -10,21 +10,22 @@
|
||||||
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
|
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
|
||||||
# omfj <omfj@users.noreply.translate.codeberg.org>, 2024.
|
# omfj <omfj@users.noreply.translate.codeberg.org>, 2024.
|
||||||
# combwizard <combwizard@users.noreply.translate.codeberg.org>, 2024.
|
# combwizard <combwizard@users.noreply.translate.codeberg.org>, 2024.
|
||||||
|
# laaknor <laaknor@users.noreply.translate.codeberg.org>, 2024.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PROJECT VERSION\n"
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||||
"PO-Revision-Date: 2024-10-04 21:35+0000\n"
|
"PO-Revision-Date: 2024-11-03 09:08+0000\n"
|
||||||
"Last-Translator: combwizard "
|
"Last-Translator: laaknor <laaknor@users.noreply.translate.codeberg.org>\n"
|
||||||
"<combwizard@users.noreply.translate.codeberg.org>\n"
|
"Language-Team: Norwegian Bokmål <https://translate.codeberg.org/projects/"
|
||||||
|
"searxng/searxng/nb_NO/>\n"
|
||||||
"Language: nb_NO\n"
|
"Language: nb_NO\n"
|
||||||
"Language-Team: Norwegian Bokmål "
|
|
||||||
"<https://translate.codeberg.org/projects/searxng/searxng/nb_NO/>\n"
|
|
||||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||||
|
"X-Generator: Weblate 5.8.1\n"
|
||||||
"Generated-By: Babel 2.16.0\n"
|
"Generated-By: Babel 2.16.0\n"
|
||||||
|
|
||||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||||
|
@ -1051,7 +1052,7 @@ msgstr "Det er ingen flere resultater. Du kan prøve å:"
|
||||||
|
|
||||||
#: searx/templates/simple/messages/no_results.html:19
|
#: searx/templates/simple/messages/no_results.html:19
|
||||||
msgid "Refresh the page."
|
msgid "Refresh the page."
|
||||||
msgstr "oppfrisk siden"
|
msgstr "oppfrisk siden."
|
||||||
|
|
||||||
#: searx/templates/simple/messages/no_results.html:20
|
#: searx/templates/simple/messages/no_results.html:20
|
||||||
msgid "Search for another query or select another category (above)."
|
msgid "Search for another query or select another category (above)."
|
||||||
|
@ -1882,4 +1883,3 @@ msgstr "skjul video"
|
||||||
|
|
||||||
#~ msgid "Engines cannot retrieve results"
|
#~ msgid "Engines cannot retrieve results"
|
||||||
#~ msgstr "Søkemotorer kan ikke motta resultater"
|
#~ msgstr "Søkemotorer kan ikke motta resultater"
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -23,13 +23,14 @@
|
||||||
# notlmutsaers <notlmutsaers@users.noreply.translate.codeberg.org>, 2024.
|
# notlmutsaers <notlmutsaers@users.noreply.translate.codeberg.org>, 2024.
|
||||||
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
|
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
|
||||||
# ljansen <ljansen@users.noreply.translate.codeberg.org>, 2024.
|
# ljansen <ljansen@users.noreply.translate.codeberg.org>, 2024.
|
||||||
|
# zarlin <zarlin@users.noreply.translate.codeberg.org>, 2024.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: searx\n"
|
"Project-Id-Version: searx\n"
|
||||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||||
"PO-Revision-Date: 2024-10-28 21:07+0000\n"
|
"PO-Revision-Date: 2024-11-02 04:00+0000\n"
|
||||||
"Last-Translator: ljansen <ljansen@users.noreply.translate.codeberg.org>\n"
|
"Last-Translator: zarlin <zarlin@users.noreply.translate.codeberg.org>\n"
|
||||||
"Language-Team: Dutch <https://translate.codeberg.org/projects/searxng/"
|
"Language-Team: Dutch <https://translate.codeberg.org/projects/searxng/"
|
||||||
"searxng/nl/>\n"
|
"searxng/nl/>\n"
|
||||||
"Language: nl\n"
|
"Language: nl\n"
|
||||||
|
@ -493,7 +494,7 @@ msgstr "stemmen"
|
||||||
|
|
||||||
#: searx/engines/radio_browser.py:107
|
#: searx/engines/radio_browser.py:107
|
||||||
msgid "clicks"
|
msgid "clicks"
|
||||||
msgstr "clicks"
|
msgstr "klikken"
|
||||||
|
|
||||||
#: searx/engines/seekr.py:193 searx/engines/yummly.py:71
|
#: searx/engines/seekr.py:193 searx/engines/yummly.py:71
|
||||||
#: searx/engines/zlibrary.py:137
|
#: searx/engines/zlibrary.py:137
|
||||||
|
@ -662,7 +663,7 @@ msgstr "Voorkeuren"
|
||||||
|
|
||||||
#: searx/templates/simple/base.html:68
|
#: searx/templates/simple/base.html:68
|
||||||
msgid "Powered by"
|
msgid "Powered by"
|
||||||
msgstr "Zoekmachine"
|
msgstr "Verzorgd door"
|
||||||
|
|
||||||
#: searx/templates/simple/base.html:68
|
#: searx/templates/simple/base.html:68
|
||||||
msgid "a privacy-respecting, open metasearch engine"
|
msgid "a privacy-respecting, open metasearch engine"
|
||||||
|
@ -1069,7 +1070,7 @@ msgstr "Er zijn geen resultaten meer. U kunt proberen om:"
|
||||||
|
|
||||||
#: searx/templates/simple/messages/no_results.html:19
|
#: searx/templates/simple/messages/no_results.html:19
|
||||||
msgid "Refresh the page."
|
msgid "Refresh the page."
|
||||||
msgstr "Ververs de pagina"
|
msgstr "Ververs de pagina."
|
||||||
|
|
||||||
#: searx/templates/simple/messages/no_results.html:20
|
#: searx/templates/simple/messages/no_results.html:20
|
||||||
msgid "Search for another query or select another category (above)."
|
msgid "Search for another query or select another category (above)."
|
||||||
|
@ -1235,9 +1236,8 @@ msgid "Max time"
|
||||||
msgstr "Max. duur"
|
msgstr "Max. duur"
|
||||||
|
|
||||||
#: searx/templates/simple/preferences/favicon.html:2
|
#: searx/templates/simple/preferences/favicon.html:2
|
||||||
#, fuzzy
|
|
||||||
msgid "Favicon Resolver"
|
msgid "Favicon Resolver"
|
||||||
msgstr "favicon-resolver"
|
msgstr "Favicon Oplosser"
|
||||||
|
|
||||||
#: searx/templates/simple/preferences/favicon.html:15
|
#: searx/templates/simple/preferences/favicon.html:15
|
||||||
msgid "Display favicons near search results"
|
msgid "Display favicons near search results"
|
||||||
|
|
Binary file not shown.
|
@ -8,21 +8,23 @@
|
||||||
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
|
# return42 <return42@users.noreply.translate.codeberg.org>, 2024.
|
||||||
# abhabongse <abhabongse@users.noreply.translate.codeberg.org>, 2024.
|
# abhabongse <abhabongse@users.noreply.translate.codeberg.org>, 2024.
|
||||||
# tutakrab <tutakrab@users.noreply.translate.codeberg.org>, 2024.
|
# tutakrab <tutakrab@users.noreply.translate.codeberg.org>, 2024.
|
||||||
|
# sahussawud <sahussawud@users.noreply.translate.codeberg.org>, 2024.
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PROJECT VERSION\n"
|
"Project-Id-Version: PROJECT VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||||
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
"POT-Creation-Date: 2024-10-05 06:24+0000\n"
|
||||||
"PO-Revision-Date: 2024-10-02 16:10+0000\n"
|
"PO-Revision-Date: 2024-11-06 07:26+0000\n"
|
||||||
"Last-Translator: tutakrab <tutakrab@users.noreply.translate.codeberg.org>"
|
"Last-Translator: sahussawud <sahussawud@users.noreply.translate.codeberg.org>"
|
||||||
"\n"
|
"\n"
|
||||||
|
"Language-Team: Thai <https://translate.codeberg.org/projects/searxng/searxng/"
|
||||||
|
"th/>\n"
|
||||||
"Language: th\n"
|
"Language: th\n"
|
||||||
"Language-Team: Thai "
|
|
||||||
"<https://translate.codeberg.org/projects/searxng/searxng/th/>\n"
|
|
||||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||||
|
"X-Generator: Weblate 5.8.1\n"
|
||||||
"Generated-By: Babel 2.16.0\n"
|
"Generated-By: Babel 2.16.0\n"
|
||||||
|
|
||||||
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
#. CONSTANT_NAMES['NO_SUBGROUPING']
|
||||||
|
@ -163,7 +165,7 @@ msgstr "มืด"
|
||||||
#. STYLE_NAMES['BLACK']
|
#. STYLE_NAMES['BLACK']
|
||||||
#: searx/searxng.msg
|
#: searx/searxng.msg
|
||||||
msgid "black"
|
msgid "black"
|
||||||
msgstr ""
|
msgstr "สีดำ"
|
||||||
|
|
||||||
#. BRAND_CUSTOM_LINKS['UPTIME']
|
#. BRAND_CUSTOM_LINKS['UPTIME']
|
||||||
#: searx/searxng.msg
|
#: searx/searxng.msg
|
||||||
|
@ -331,12 +333,12 @@ msgstr "ผู้เขียน"
|
||||||
#. SOCIAL_MEDIA_TERMS['THREAD OPEN']
|
#. SOCIAL_MEDIA_TERMS['THREAD OPEN']
|
||||||
#: searx/engines/discourse.py:149 searx/searxng.msg
|
#: searx/engines/discourse.py:149 searx/searxng.msg
|
||||||
msgid "open"
|
msgid "open"
|
||||||
msgstr ""
|
msgstr "สร้าง"
|
||||||
|
|
||||||
#. SOCIAL_MEDIA_TERMS['THREAD CLOSED']
|
#. SOCIAL_MEDIA_TERMS['THREAD CLOSED']
|
||||||
#: searx/engines/discourse.py:149 searx/searxng.msg
|
#: searx/engines/discourse.py:149 searx/searxng.msg
|
||||||
msgid "closed"
|
msgid "closed"
|
||||||
msgstr ""
|
msgstr "ลบ"
|
||||||
|
|
||||||
#. SOCIAL_MEDIA_TERMS['THREAD ANSWERED']
|
#. SOCIAL_MEDIA_TERMS['THREAD ANSWERED']
|
||||||
#: searx/engines/discourse.py:160 searx/searxng.msg
|
#: searx/engines/discourse.py:160 searx/searxng.msg
|
||||||
|
@ -450,7 +452,7 @@ msgstr "คำนวณ {functions} จากอาร์กิวเมนต
|
||||||
|
|
||||||
#: searx/engines/mozhi.py:57
|
#: searx/engines/mozhi.py:57
|
||||||
msgid "Synonyms"
|
msgid "Synonyms"
|
||||||
msgstr ""
|
msgstr "คำเหมือน"
|
||||||
|
|
||||||
#: searx/engines/openstreetmap.py:159
|
#: searx/engines/openstreetmap.py:159
|
||||||
msgid "Get directions"
|
msgid "Get directions"
|
||||||
|
@ -538,8 +540,9 @@ msgid "hash digest"
|
||||||
msgstr "แฮชย่อย"
|
msgstr "แฮชย่อย"
|
||||||
|
|
||||||
#: searx/plugins/hostnames.py:103
|
#: searx/plugins/hostnames.py:103
|
||||||
|
#, fuzzy
|
||||||
msgid "Hostnames plugin"
|
msgid "Hostnames plugin"
|
||||||
msgstr ""
|
msgstr "ชื่อโฮส ปลั๊กอิน"
|
||||||
|
|
||||||
#: searx/plugins/hostnames.py:104
|
#: searx/plugins/hostnames.py:104
|
||||||
msgid "Rewrite hostnames, remove results or prioritize them based on the hostname"
|
msgid "Rewrite hostnames, remove results or prioritize them based on the hostname"
|
||||||
|
@ -1698,4 +1701,3 @@ msgstr "ซ่อนวิดีโอ"
|
||||||
|
|
||||||
#~ msgid "Engines cannot retrieve results"
|
#~ msgid "Engines cannot retrieve results"
|
||||||
#~ msgstr "เครื่องมือไม่สามารถดึงผลลัพธ์ได้"
|
#~ msgstr "เครื่องมือไม่สามารถดึงผลลัพธ์ได้"
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
# pylint: disable=missing-module-docstring, invalid-name
|
# pylint: disable=missing-module-docstring, invalid-name
|
||||||
|
|
||||||
|
import flask
|
||||||
|
from mock import Mock
|
||||||
from tests import SearxTestCase
|
from tests import SearxTestCase
|
||||||
from searx import favicons
|
from searx import favicons
|
||||||
from searx.locales import locales_initialize
|
from searx.locales import locales_initialize
|
||||||
from searx.preferences import (
|
from searx.preferences import (
|
||||||
|
Setting,
|
||||||
EnumStringSetting,
|
EnumStringSetting,
|
||||||
MapSetting,
|
MapSetting,
|
||||||
SearchLanguageSetting,
|
SearchLanguageSetting,
|
||||||
|
@ -13,6 +16,7 @@ from searx.preferences import (
|
||||||
ValidationException,
|
ValidationException,
|
||||||
)
|
)
|
||||||
from searx.plugins import Plugin
|
from searx.plugins import Plugin
|
||||||
|
from searx.preferences import Preferences
|
||||||
|
|
||||||
locales_initialize()
|
locales_initialize()
|
||||||
favicons.init()
|
favicons.init()
|
||||||
|
@ -125,10 +129,10 @@ class TestSettings(SearxTestCase): # pylint: disable=missing-class-docstring
|
||||||
|
|
||||||
|
|
||||||
class TestPreferences(SearxTestCase): # pylint: disable=missing-class-docstring
|
class TestPreferences(SearxTestCase): # pylint: disable=missing-class-docstring
|
||||||
def test_encode(self):
|
def setUp(self):
|
||||||
from searx.preferences import Preferences # pylint: disable=import-outside-toplevel
|
self.preferences = Preferences(['simple'], ['general'], {}, [])
|
||||||
|
|
||||||
pref = Preferences(['simple'], ['general'], {}, [])
|
def test_encode(self):
|
||||||
url_params = (
|
url_params = (
|
||||||
'eJx1Vk1z4zYM_TXxRZNMd7eddg8-pe21nWnvGoiEJEQkofDDtvzrC1qSRdnbQxQTBA'
|
'eJx1Vk1z4zYM_TXxRZNMd7eddg8-pe21nWnvGoiEJEQkofDDtvzrC1qSRdnbQxQTBA'
|
||||||
'Hw8eGRCiJ27AnDsUOHHszBgOsSdHjU-Pr7HwfDCkweHCBFVmxHgxGPB7LiU4-eL9Px'
|
'Hw8eGRCiJ27AnDsUOHHszBgOsSdHjU-Pr7HwfDCkweHCBFVmxHgxGPB7LiU4-eL9Px'
|
||||||
|
@ -155,8 +159,48 @@ class TestPreferences(SearxTestCase): # pylint: disable=missing-class-docstring
|
||||||
'd-DZy7PtaVp2WgvPBpzCXUL_J1OGex48RVmOXzBU8_N3kqekkefRDzxNK2_Klp9mBJ'
|
'd-DZy7PtaVp2WgvPBpzCXUL_J1OGex48RVmOXzBU8_N3kqekkefRDzxNK2_Klp9mBJ'
|
||||||
'wsUnXyRqq1mScHuYalUY7_AZTCR4s=&q='
|
'wsUnXyRqq1mScHuYalUY7_AZTCR4s=&q='
|
||||||
)
|
)
|
||||||
pref.parse_encoded_data(url_params)
|
self.preferences.parse_encoded_data(url_params)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
vars(pref.key_value_settings['categories']),
|
vars(self.preferences.key_value_settings['categories']),
|
||||||
{'value': ['general'], 'locked': False, 'choices': ['general', 'none']},
|
{'value': ['general'], 'locked': False, 'choices': ['general', 'none']},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_save_key_value_setting(self):
|
||||||
|
setting_key = 'foo'
|
||||||
|
setting_value = 'bar'
|
||||||
|
|
||||||
|
cookie_callback = {}
|
||||||
|
|
||||||
|
def set_cookie_callback(name, value, max_age): # pylint: disable=unused-argument
|
||||||
|
cookie_callback[name] = value
|
||||||
|
|
||||||
|
response_mock = Mock(flask.Response)
|
||||||
|
response_mock.set_cookie = set_cookie_callback
|
||||||
|
self.preferences.key_value_settings = {
|
||||||
|
setting_key: Setting(
|
||||||
|
setting_value,
|
||||||
|
locked=False,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
self.preferences.save(response_mock)
|
||||||
|
self.assertIn(setting_key, cookie_callback)
|
||||||
|
self.assertEqual(cookie_callback[setting_key], setting_value)
|
||||||
|
|
||||||
|
def test_false_key_value_setting(self):
|
||||||
|
setting_key = 'foo'
|
||||||
|
|
||||||
|
cookie_callback = {}
|
||||||
|
|
||||||
|
def set_cookie_callback(name, value, max_age): # pylint: disable=unused-argument
|
||||||
|
cookie_callback[name] = value
|
||||||
|
|
||||||
|
response_mock = Mock(flask.Response)
|
||||||
|
response_mock.set_cookie = set_cookie_callback
|
||||||
|
self.preferences.key_value_settings = {
|
||||||
|
setting_key: Setting(
|
||||||
|
'',
|
||||||
|
locked=True,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
self.preferences.save(response_mock)
|
||||||
|
self.assertNotIn(setting_key, cookie_callback)
|
||||||
|
|
Loading…
Reference in New Issue