summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/__init__.py12
-rw-r--r--tests/robot/__main__.py6
-rw-r--r--tests/unit/__init__.py2
-rw-r--r--tests/unit/test_settings_loader.py12
4 files changed, 19 insertions, 13 deletions
diff --git a/tests/__init__.py b/tests/__init__.py
index 23e62f040..c823cec87 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -2,11 +2,17 @@ import os
import aiounittest
-os.environ['SEARX_DEBUG'] = '1'
-os.environ['SEARX_DEBUG_LOG_LEVEL'] = 'WARNING'
-os.environ['SEARX_DISABLE_ETC_SETTINGS'] = '1'
+os.environ.pop('SEARX_DEBUG', None)
+os.environ.pop('SEARX_DEBUG_LOG_LEVEL', None)
+os.environ.pop('SEARX_DISABLE_ETC_SETTINGS', None)
os.environ.pop('SEARX_SETTINGS_PATH', None)
+os.environ.pop('SEARXNG_SETTINGS_PATH', None)
+
+os.environ['SEARXNG_DEBUG'] = '1'
+os.environ['SEARXNG_DEBUG_LOG_LEVEL'] = 'WARNING'
+os.environ['SEARXNG_DISABLE_ETC_SETTINGS'] = '1'
+
class SearxTestLayer:
"""Base layer for non-robot tests."""
diff --git a/tests/robot/__main__.py b/tests/robot/__main__.py
index e435f512a..d4d6642a9 100644
--- a/tests/robot/__main__.py
+++ b/tests/robot/__main__.py
@@ -35,10 +35,10 @@ class SearxRobotLayer():
# - debug mode: https://flask.palletsprojects.com/quickstart/#debug-mode
# - Flask.run(..): https://flask.palletsprojects.com/api/#flask.Flask.run
- os.environ['SEARX_DEBUG'] = '0'
+ os.environ['SEARXNG_DEBUG'] = '0'
# set robot settings path
- os.environ['SEARX_SETTINGS_PATH'] = str(tests_path / 'robot' / 'settings_robot.yml')
+ os.environ['SEARXNG_SETTINGS_PATH'] = str(tests_path / 'robot' / 'settings_robot.yml')
# run the server
self.server = subprocess.Popen( # pylint: disable=consider-using-with
@@ -52,7 +52,7 @@ class SearxRobotLayer():
def tearDown(self):
os.kill(self.server.pid, 9)
# remove previously set environment variable
- del os.environ['SEARX_SETTINGS_PATH']
+ del os.environ['SEARXNG_SETTINGS_PATH']
def run_robot_tests(tests):
diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py
index 8266c675a..d1c97ec81 100644
--- a/tests/unit/__init__.py
+++ b/tests/unit/__init__.py
@@ -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')
diff --git a/tests/unit/test_settings_loader.py b/tests/unit/test_settings_loader.py
index ad9fc6e95..9e04df653 100644
--- a/tests/unit/test_settings_loader.py
+++ b/tests/unit/test_settings_loader.py
@@ -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)