From 1ee555e4687dcd94cc054738076b4cb78999e81c Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Fri, 16 Jun 2017 10:17:38 +0100 Subject: [PATCH] Ensure the feature tests use the correct test settings database. Fixes #2486 --- web/config.py | 2 -- web/pgadmin/__init__.py | 5 +++++ web/regression/runtests.py | 5 ++++- web/setup.py | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/web/config.py b/web/config.py index d45c43c1e..6a3128e0a 100644 --- a/web/config.py +++ b/web/config.py @@ -305,8 +305,6 @@ DEFAULT_BINARY_PATHS = { ########################################################################## # Test settings - used primarily by the regression suite, not for users ########################################################################## -# Set default testing mode -TESTING_MODE = False # The default path for SQLite database for testing TEST_SQLITE_PATH = os.path.join(DATA_DIR, 'test_pgadmin4.db') diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index 5a7492793..4389e96b2 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -170,6 +170,11 @@ def create_app(app_name=None): logger = logging.getLogger('werkzeug') logger.setLevel(logging.INFO) + # Set SQLITE_PATH to TEST_SQLITE_PATH while running test cases + if "PGADMIN_TESTING_MODE" in os. environ and \ + os.environ["PGADMIN_TESTING_MODE"] == "1": + config.SQLITE_PATH = config.TEST_SQLITE_PATH + # Ensure the various working directories exist from pgadmin.setup import create_app_data_directory, db_upgrade create_app_data_directory(config) diff --git a/web/regression/runtests.py b/web/regression/runtests.py index 3339cd619..2d4e2bc40 100644 --- a/web/regression/runtests.py +++ b/web/regression/runtests.py @@ -50,7 +50,7 @@ from regression.feature_utils.app_starter import AppStarter if os.path.isfile(config.TEST_SQLITE_PATH): os.remove(config.TEST_SQLITE_PATH) -config.TESTING_MODE = True +os.environ["PGADMIN_TESTING_MODE"] = "1" # Disable upgrade checks - no need during testing, and it'll cause an error # if there's no network connection when it runs. @@ -408,6 +408,9 @@ if __name__ == '__main__': print("Please check output in file: %s/regression.log\n" % CURRENT_PATH) + # Unset environment variable + del os.environ["PGADMIN_TESTING_MODE"] + if failure: sys.exit(1) else: diff --git a/web/setup.py b/web/setup.py index ab8dab69a..762fa9b16 100644 --- a/web/setup.py +++ b/web/setup.py @@ -33,7 +33,8 @@ if __name__ == '__main__': app.config.from_object(config) - if config.TESTING_MODE: + if "PGADMIN_TESTING_MODE" in os. environ and \ + os.environ["PGADMIN_TESTING_MODE"] == "1": config.SQLITE_PATH = config.TEST_SQLITE_PATH create_app_data_directory(config)