Ensure the feature tests use the correct test settings database. Fixes #2486

This commit is contained in:
Khushboo Vashi 2017-06-16 10:17:38 +01:00 committed by Dave Page
parent 0056a94115
commit 1ee555e468
4 changed files with 11 additions and 4 deletions

View File

@ -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')

View File

@ -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)

View File

@ -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:

View File

@ -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)