test_server: Set LOCAL_UPLOADS_DIR in set_up_django.

For the Casper and API tests, we need to allow setting
LOCAL_UPLOADS_DIR, which is normally managed within test_runner.py.
This commit is contained in:
Wyatt Hoodes 2019-07-15 20:10:29 -10:00 committed by Tim Abbott
parent ea2e7ccf27
commit 1418b8b05f
2 changed files with 9 additions and 1 deletions

View File

@ -20,11 +20,14 @@ if TOOLS_DIR not in sys.path:
sys.path.insert(0, os.path.dirname(TOOLS_DIR))
from zerver.lib.test_fixtures import update_test_databases_if_required
from scripts.lib.zulip_tools import get_or_create_dev_uuid_var_path
def set_up_django(external_host):
# type: (str) -> None
os.environ['EXTERNAL_HOST'] = external_host
os.environ["TORNADO_SERVER"] = "http://127.0.0.1:9983"
os.environ["LOCAL_UPLOADS_DIR"] = get_or_create_dev_uuid_var_path(
'test-backend/test_uploads')
os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.test_settings'
django.setup()
os.environ['PYTHONUNBUFFERED'] = 'y'

View File

@ -126,7 +126,12 @@ ENABLE_FILE_LINKS = True
# These settings are set dynamically in `zerver/lib/test_runner.py`:
TEST_WORKER_DIR = ''
LOCAL_UPLOADS_DIR = ''
# Allow setting LOCAL_UPLOADS_DIR in the environment so that the
# Casper/API tests in test_server.py can control this.
if "LOCAL_UPLOADS_DIR" in os.environ:
LOCAL_UPLOADS_DIR = os.getenv("LOCAL_UPLOADS_DIR")
else:
LOCAL_UPLOADS_DIR = ''
S3_KEY = 'test-key'
S3_SECRET_KEY = 'test-secret-key'