Rename all from searx to searxng

This commit is contained in:
HLFH 2021-09-29 11:26:25 +01:00
parent a582cf3d82
commit ac05f0943c
No known key found for this signature in database
GPG key ID: 200A60A75D394102
682 changed files with 58450 additions and 58450 deletions

View file

@ -2,5 +2,5 @@ import os
from os.path import dirname, sep, abspath
# In unit tests the user settings from unit/settings/test_settings.yml are used.
os.environ['SEARX_SETTINGS_PATH'] = abspath(
os.environ['SEARXNG_SETTINGS_PATH'] = abspath(
dirname(__file__) + sep + 'settings' + sep + 'test_settings.yml')

View file

@ -1,21 +1,21 @@
'''
searx is free software: you can redistribute it and/or modify
searxng is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
searx is distributed in the hope that it will be useful,
searxng is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with searx. If not, see < http://www.gnu.org/licenses/ >.
along with searxng. If not, see < http://www.gnu.org/licenses/ >.
'''
from searx.engines import command as command_engine
from searxng.engines import command as command_engine
from tests import SearxTestCase
@ -35,57 +35,57 @@ class TestCommandEngine(SearxTestCase):
self.assertEqual(results, expected_results)
def test_delimiter_parsing_command_engine(self):
searx_logs = '''DEBUG:searx.webapp:static directory is /home/n/p/searx/searx/static
DEBUG:searx.webapp:templates directory is /home/n/p/searx/searx/templates
DEBUG:searx.engines:soundcloud engine: Starting background initialization
DEBUG:searx.engines:wolframalpha engine: Starting background initialization
DEBUG:searx.engines:locate engine: Starting background initialization
DEBUG:searx.engines:regex search in files engine: Starting background initialization
searxng_logs = '''DEBUG:searxng.webapp:static directory is /home/n/p/searxng/searxng/static
DEBUG:searxng.webapp:templates directory is /home/n/p/searxng/searxng/templates
DEBUG:searxng.engines:soundcloud engine: Starting background initialization
DEBUG:searxng.engines:wolframalpha engine: Starting background initialization
DEBUG:searxng.engines:locate engine: Starting background initialization
DEBUG:searxng.engines:regex search in files engine: Starting background initialization
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): www.wolframalpha.com
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): soundcloud.com
DEBUG:searx.engines:find engine: Starting background initialization
DEBUG:searx.engines:pattern search in files engine: Starting background initialization
DEBUG:searx.webapp:starting webserver on 127.0.0.1:8888
DEBUG:searxng.engines:find engine: Starting background initialization
DEBUG:searxng.engines:pattern search in files engine: Starting background initialization
DEBUG:searxng.webapp:starting webserver on 127.0.0.1:8888
WARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: 299-578-362'''
echo_engine = command_engine
echo_engine.command = ['echo', searx_logs]
echo_engine.command = ['echo', searxng_logs]
echo_engine.delimiter = {'chars': ':', 'keys': ['level', 'component', 'message']}
expected_results_by_page = [
[
{
'component': 'searx.webapp',
'message': 'static directory is /home/n/p/searx/searx/static',
'component': 'searxng.webapp',
'message': 'static directory is /home/n/p/searxng/searxng/static',
'template': 'key-value.html',
'level': 'DEBUG',
},
{
'component': 'searx.webapp',
'message': 'templates directory is /home/n/p/searx/searx/templates',
'component': 'searxng.webapp',
'message': 'templates directory is /home/n/p/searxng/searxng/templates',
'template': 'key-value.html',
'level': 'DEBUG',
},
{
'component': 'searx.engines',
'component': 'searxng.engines',
'message': 'soundcloud engine: Starting background initialization',
'template': 'key-value.html',
'level': 'DEBUG',
},
{
'component': 'searx.engines',
'component': 'searxng.engines',
'message': 'wolframalpha engine: Starting background initialization',
'template': 'key-value.html',
'level': 'DEBUG',
},
{
'component': 'searx.engines',
'component': 'searxng.engines',
'message': 'locate engine: Starting background initialization',
'template': 'key-value.html',
'level': 'DEBUG',
},
{
'component': 'searx.engines',
'component': 'searxng.engines',
'message': 'regex search in files engine: Starting background initialization',
'template': 'key-value.html',
'level': 'DEBUG',
@ -103,13 +103,13 @@ INFO:werkzeug: * Debugger PIN: 299-578-362'''
'level': 'DEBUG',
},
{
'component': 'searx.engines',
'component': 'searxng.engines',
'message': 'find engine: Starting background initialization',
'template': 'key-value.html',
'level': 'DEBUG',
},
{
'component': 'searx.engines',
'component': 'searxng.engines',
'message': 'pattern search in files engine: Starting background initialization',
'template': 'key-value.html',
'level': 'DEBUG',
@ -118,7 +118,7 @@ INFO:werkzeug: * Debugger PIN: 299-578-362'''
],
[
{
'component': 'searx.webapp',
'component': 'searxng.webapp',
'message': 'starting webserver on 127.0.0.1:8888',
'template': 'key-value.html',
'level': 'DEBUG',

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from collections import defaultdict
import mock
from searx.engines import xpath
from searxng.engines import xpath
from tests import SearxTestCase

View file

@ -4,7 +4,7 @@ from mock import patch
import httpx
from searx.network.network import Network, NETWORKS, initialize
from searxng.network.network import Network, NETWORKS, initialize
from tests import SearxTestCase

View file

@ -1,6 +1,6 @@
general:
debug: false
instance_name: "searx"
instance_name: "searxng"
search:
safe_search: 0

View file

@ -2,7 +2,7 @@
from mock import Mock
from searx.answerers import answerers
from searxng.answerers import answerers
from tests import SearxTestCase

View file

@ -1,4 +1,4 @@
from searx import settings, engines
from searxng import settings, engines
from tests import SearxTestCase

View file

@ -1,5 +1,5 @@
from searx.external_bang import get_node, resolve_bang_definition, get_bang_url, get_bang_definition_and_autocomplete
from searx.search import SearchQuery, EngineRef
from searxng.external_bang import get_node, resolve_bang_definition, get_bang_url, get_bang_definition_and_autocomplete
from searxng.search import SearchQuery, EngineRef
from tests import SearxTestCase

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from searx import plugins
from searxng import plugins
from mock import Mock
from tests import SearxTestCase

View file

@ -1,4 +1,4 @@
from searx.preferences import (EnumStringSetting, MapSetting, MissingArgumentException, SearchLanguageSetting,
from searxng.preferences import (EnumStringSetting, MapSetting, MissingArgumentException, SearchLanguageSetting,
MultipleChoiceSetting, PluginsSetting, ValidationException)
from tests import SearxTestCase
@ -123,7 +123,7 @@ class TestSettings(SearxTestCase):
class TestPreferences(SearxTestCase):
def test_encode(self):
from searx.preferences import Preferences
from searxng.preferences import Preferences
pref = Preferences(['oscar'], ['general'], {}, [])
url_params = 'eJx1VMmO2zAM_Zr6YrTocujJh6JF0QEKzKAz7VVgJNohLIseUU7ivy-VcWy5yyGOTVGP73GLKJNPYjiYgGeT4NB8BS9YOSY' \
'TUdifMDYM-vmGY1d5CN0EHTYOK88W_PXNkcDBozOjnzoK0vyi4bWnHs2RU4-zvHr_-RF9a-5Cy3GARByy7X7EkKMoBeMp9CuPQ-SzYMx' \

View file

@ -1,6 +1,6 @@
from searx import settings
from searx.engines import load_engines
from searx.query import RawTextQuery
from searxng import settings
from searxng.engines import load_engines
from searxng.query import RawTextQuery
from tests import SearxTestCase

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from searx.results import ResultContainer
from searxng.results import ResultContainer
from tests import SearxTestCase

View file

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
import searx.search
from searx.search import SearchQuery, EngineRef
from searx import settings
import searxng.search
from searxng.search import SearchQuery, EngineRef
from searxng import settings
from tests import SearxTestCase
@ -39,13 +39,13 @@ class SearchTestCase(SearxTestCase):
@classmethod
def setUpClass(cls):
searx.search.initialize(TEST_ENGINES)
searxng.search.initialize(TEST_ENGINES)
def test_timeout_simple(self):
settings['outgoing']['max_request_timeout'] = None
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
'en-US', SAFESEARCH, PAGENO, None, None)
search = searx.search.Search(search_query)
search = searxng.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 3.0)
@ -53,7 +53,7 @@ class SearchTestCase(SearxTestCase):
settings['outgoing']['max_request_timeout'] = None
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
'en-US', SAFESEARCH, PAGENO, None, 5.0)
search = searx.search.Search(search_query)
search = searxng.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 3.0)
@ -61,7 +61,7 @@ class SearchTestCase(SearxTestCase):
settings['outgoing']['max_request_timeout'] = None
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
'en-US', SAFESEARCH, PAGENO, None, 1.0)
search = searx.search.Search(search_query)
search = searxng.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 1.0)
@ -69,7 +69,7 @@ class SearchTestCase(SearxTestCase):
settings['outgoing']['max_request_timeout'] = 10.0
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
'en-US', SAFESEARCH, PAGENO, None, 5.0)
search = searx.search.Search(search_query)
search = searxng.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 5.0)
@ -77,7 +77,7 @@ class SearchTestCase(SearxTestCase):
settings['outgoing']['max_request_timeout'] = 10.0
search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
'en-US', SAFESEARCH, PAGENO, None, 15.0)
search = searx.search.Search(search_query)
search = searxng.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 10.0)
@ -86,7 +86,7 @@ class SearchTestCase(SearxTestCase):
[EngineRef(PUBLIC_ENGINE_NAME, 'general')],
'en-US', SAFESEARCH, PAGENO, None, None,
external_bang="yt")
search = searx.search.Search(search_query)
search = searxng.search.Search(search_query)
results = search.search()
# For checking if the user redirected with the youtube external bang
self.assertTrue(results.redirect_url is not None)
@ -95,7 +95,7 @@ class SearchTestCase(SearxTestCase):
[EngineRef(PUBLIC_ENGINE_NAME, 'general')],
'en-US', SAFESEARCH, PAGENO, None, None)
search = searx.search.Search(search_query)
search = searxng.search.Search(search_query)
results = search.search()
# This should not redirect
self.assertTrue(results.redirect_url is None)

View file

@ -3,8 +3,8 @@
from os.path import dirname, join, abspath
from unittest.mock import patch
from searx.exceptions import SearxSettingsException
from searx import settings_loader
from searxng.exceptions import SearxSettingsException
from searxng import settings_loader
from tests import SearxTestCase
@ -58,14 +58,14 @@ class TestUserSettings(SearxTestCase):
def test_user_settings_not_found(self):
with patch.dict(settings_loader.environ,
{'SEARX_SETTINGS_PATH': '/dev/null'}):
{'SEARXNG_SETTINGS_PATH': '/dev/null'}):
settings, msg = settings_loader.load_settings()
self.assertTrue(msg.startswith('load the default settings from'))
self.assertEqual(settings['server']['secret_key'], "ultrasecretkey")
def test_user_settings(self):
with patch.dict(settings_loader.environ,
{'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings_simple.yml')}):
{'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings_simple.yml')}):
settings, msg = settings_loader.load_settings()
self.assertTrue(msg.startswith('merge the default settings'))
self.assertEqual(settings['server']['secret_key'], "user_secret_key")
@ -73,7 +73,7 @@ class TestUserSettings(SearxTestCase):
def test_user_settings_remove(self):
with patch.dict(settings_loader.environ,
{'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings_remove.yml')}):
{'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings_remove.yml')}):
settings, msg = settings_loader.load_settings()
self.assertTrue(msg.startswith('merge the default settings'))
self.assertEqual(settings['server']['secret_key'], "user_secret_key")
@ -85,7 +85,7 @@ class TestUserSettings(SearxTestCase):
def test_user_settings_remove2(self):
with patch.dict(settings_loader.environ,
{'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings_remove2.yml')}):
{'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings_remove2.yml')}):
settings, msg = settings_loader.load_settings()
self.assertTrue(msg.startswith('merge the default settings'))
self.assertEqual(settings['server']['secret_key'], "user_secret_key")
@ -102,7 +102,7 @@ class TestUserSettings(SearxTestCase):
def test_user_settings_keep_only(self):
with patch.dict(settings_loader.environ,
{'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings_keep_only.yml')}):
{'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings_keep_only.yml')}):
settings, msg = settings_loader.load_settings()
self.assertTrue(msg.startswith('merge the default settings'))
engine_names = [engine['name'] for engine in settings['engines']]
@ -112,7 +112,7 @@ class TestUserSettings(SearxTestCase):
def test_custom_settings(self):
with patch.dict(settings_loader.environ,
{'SEARX_SETTINGS_PATH': join(test_dir, 'settings/user_settings.yml')}):
{'SEARXNG_SETTINGS_PATH': join(test_dir, 'settings/user_settings.yml')}):
settings, msg = settings_loader.load_settings()
self.assertTrue(msg.startswith('load the user settings from'))
self.assertEqual(settings['server']['port'], 9000)

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""Test utils/standalone_searx.py"""
"""Test utils/standalone_searxng.py"""
import datetime
import io
import sys
@ -7,13 +7,13 @@ import sys
from mock import Mock, patch
from nose2.tools import params
from searx.search import SearchQuery, EngineRef, initialize
from searx_extra import standalone_searx as sas
from searxng.search import SearchQuery, EngineRef, initialize
from searxng_extra import standalone_searxng as sas
from tests import SearxTestCase
class StandaloneSearx(SearxTestCase):
"""Unit test for standalone_searx."""
"""Unit test for standalone_searxng."""
@classmethod
def setUpClass(cls):
@ -59,7 +59,7 @@ class StandaloneSearx(SearxTestCase):
def test_to_dict_with_mock(self):
"""test to dict."""
with patch.object(sas.searx.search, 'Search') as mock_s:
with patch.object(sas.searxng.search, 'Search') as mock_s:
m_search = mock_s().search()
m_sq = Mock()
self.assertEqual(

View file

@ -2,8 +2,8 @@
import lxml.etree
from lxml import html
from searx.exceptions import SearxXPathSyntaxException, SearxEngineXPathException
from searx import utils
from searxng.exceptions import SearxXPathSyntaxException, SearxEngineXPathException
from searxng import utils
from tests import SearxTestCase
@ -15,10 +15,10 @@ class TestUtils(SearxTestCase):
self.assertIsNotNone(utils.gen_useragent())
self.assertTrue(utils.gen_useragent().startswith('Mozilla'))
def test_searx_useragent(self):
self.assertIsInstance(utils.searx_useragent(), str)
self.assertIsNotNone(utils.searx_useragent())
self.assertTrue(utils.searx_useragent().startswith('searx'))
def test_searxng_useragent(self):
self.assertIsInstance(utils.searxng_useragent(), str)
self.assertIsNotNone(utils.searxng_useragent())
self.assertTrue(utils.searxng_useragent().startswith('searxng'))
def test_html_to_text(self):
html_str = """

View file

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from searx.preferences import Preferences
from searx.engines import engines
from searxng.preferences import Preferences
from searxng.engines import engines
import searx.search
from searx.search import EngineRef
from searx.webadapter import validate_engineref_list
import searxng.search
from searxng.search import EngineRef
from searxng.webadapter import validate_engineref_list
from tests import SearxTestCase
@ -28,7 +28,7 @@ class ValidateQueryCase(SearxTestCase):
@classmethod
def setUpClass(cls):
searx.search.initialize(TEST_ENGINES)
searxng.search.initialize(TEST_ENGINES)
def test_query_private_engine_without_token(self):
preferences = Preferences(['oscar'], ['general'], engines, [])

View file

@ -4,8 +4,8 @@ import json
from urllib.parse import ParseResult
from mock import Mock
import searx.search.processors
from searx.search import Search
import searxng.search.processors
from searxng.search import Search
from tests import SearxTestCase
@ -15,9 +15,9 @@ class ViewsTestCase(SearxTestCase):
# skip init function (no external HTTP request)
def dummy(*args, **kwargs):
pass
self.setattr4test(searx.search.processors, 'initialize_processor', dummy)
self.setattr4test(searxng.search.processors, 'initialize_processor', dummy)
from searx import webapp # pylint disable=import-outside-toplevel
from searxng import webapp # pylint disable=import-outside-toplevel
webapp.app.config['TESTING'] = True # to get better error messages
self.app = webapp.app.test_client()
@ -84,7 +84,7 @@ class ViewsTestCase(SearxTestCase):
self.assertEqual(result.status_code, 200)
self.assertIn(b'<div class="text-hide center-block" id="main-logo">'
+ b'<img class="center-block img-responsive" src="/static/themes/oscar/img/logo_searx_a.png"'
+ b' alt="searx logo" />searx</div>', result.data)
+ b' alt="searxng logo" />searxng</div>', result.data)
def test_index_html_post(self):
result = self.app.post('/', data={'q': 'test'})
@ -162,7 +162,7 @@ class ViewsTestCase(SearxTestCase):
result = self.app.post('/search', data={'q': 'test', 'format': 'rss'})
self.assertIn(
b'<description>Search results for "test" - searx</description>',
b'<description>Search results for "test" - searxng</description>',
result.data
)

View file

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import mock
from searx import webutils
from searxng import webutils
from tests import SearxTestCase