settings: Refactor how TEST_SUITE is configured.

This is designed to allow us to access the value inside
configured_settings.py
This commit is contained in:
Tim Abbott 2023-12-03 20:53:00 -08:00
parent 45df5750ae
commit 2d1b217441
5 changed files with 8 additions and 3 deletions

View File

@ -100,8 +100,6 @@ else:
IS_WORKER = False IS_WORKER = False
# This is overridden in test_settings.py for the test suites
TEST_SUITE = False
# This is overridden in test_settings.py for the test suites # This is overridden in test_settings.py for the test suites
PUPPETEER_TESTS = False PUPPETEER_TESTS = False
# This is overridden in test_settings.py for the test suites # This is overridden in test_settings.py for the test suites

View File

@ -2,6 +2,8 @@
# DEFAULT VALUES FOR SETTINGS # DEFAULT VALUES FOR SETTINGS
######################################################################## ########################################################################
import os
# For any settings that are not set in the site-specific configuration file # For any settings that are not set in the site-specific configuration file
# (/etc/zulip/settings.py in production, or dev_settings.py or test_settings.py # (/etc/zulip/settings.py in production, or dev_settings.py or test_settings.py
# in dev and test), we want to initialize them to sane defaults. # in dev and test), we want to initialize them to sane defaults.
@ -11,6 +13,8 @@ from .default_settings import * # noqa: F403 isort: skip
# Import prod_settings after determining the deployment/machine type # Import prod_settings after determining the deployment/machine type
from .config import PRODUCTION from .config import PRODUCTION
TEST_SUITE = os.getenv("ZULIP_TEST_SUITE") == "true"
if PRODUCTION: # nocoverage if PRODUCTION: # nocoverage
from .prod_settings import * # noqa: F403 isort: skip from .prod_settings import * # noqa: F403 isort: skip
else: else:

View File

@ -7,6 +7,9 @@ from zproject.settings_types import SCIMConfigDict
ZULIP_ADMINISTRATOR = "desdemona+admin@zulip.com" ZULIP_ADMINISTRATOR = "desdemona+admin@zulip.com"
# Initiatize TEST_SUITE early, so other code can rely on the setting.
TEST_SUITE = os.getenv("ZULIP_TEST_SUITE") == "true"
# We want LOCAL_UPLOADS_DIR to be an absolute path so that code can # We want LOCAL_UPLOADS_DIR to be an absolute path so that code can
# chdir without having problems accessing it. Unfortunately, this # chdir without having problems accessing it. Unfortunately, this
# means we need a duplicate definition of DEPLOY_ROOT with the one in # means we need a duplicate definition of DEPLOY_ROOT with the one in

View File

@ -82,7 +82,6 @@ AUTH_LDAP_REVERSE_EMAIL_SEARCH = LDAPSearch(
"ou=users,dc=zulip,dc=com", ldap.SCOPE_ONELEVEL, "(mail=%(email)s)" "ou=users,dc=zulip,dc=com", ldap.SCOPE_ONELEVEL, "(mail=%(email)s)"
) )
TEST_SUITE = True
RATE_LIMITING = False RATE_LIMITING = False
RATE_LIMITING_AUTHENTICATE = False RATE_LIMITING_AUTHENTICATE = False
# Don't use RabbitMQ from the test suite -- the user_profile_ids for # Don't use RabbitMQ from the test suite -- the user_profile_ids for

View File

@ -16,6 +16,7 @@ import os
# it can be set there, at the right place in the settings.py flow. # it can be set there, at the right place in the settings.py flow.
# Ick. # Ick.
os.environ["EXTERNAL_HOST"] = os.getenv("TEST_EXTERNAL_HOST", "testserver") os.environ["EXTERNAL_HOST"] = os.getenv("TEST_EXTERNAL_HOST", "testserver")
os.environ["ZULIP_TEST_SUITE"] = "true"
from .settings import * # noqa: F403 isort: skip from .settings import * # noqa: F403 isort: skip
from .test_extra_settings import * # noqa: F403 isort: skip from .test_extra_settings import * # noqa: F403 isort: skip