Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_runner: Fix SENDFILE_ROOT.

Anders Kaseorg30c67972392c
diff --git a/zerver/lib/test_runner.py b/zerver/lib/test_runner.py
index 00bb484cf5c..3e2556816c4 100644
--- a/zerver/lib/test_runner.py
+++ b/zerver/lib/test_runner.py
@@ -389,6 +389,7 @@ def initialize_worker_path(worker_id: int) -> None:
os.path.basename(TEST_RUN_DIR),
os.path.basename(worker_path),
"test_uploads"))
+ settings.SENDFILE_ROOT = os.path.join(settings.LOCAL_UPLOADS_DIR, "files")
class Runner(DiscoverRunner):
test_suite = TestSuite
diff --git a/zerver/tests/test_upload.py b/zerver/tests/test_upload.py
index e1d1bbac061..f83f661c5af 100644
--- a/zerver/tests/test_upload.py
+++ b/zerver/tests/test_upload.py
@@ -18,7 +18,6 @@ from django_sendfile.sendfile import _get_sendfile
from PIL import Image
import zerver.lib.upload
-from scripts.lib.zulip_tools import get_dev_uuid_var_path
from zerver.lib.actions import (
do_change_icon_source,
do_change_logo_source,
@@ -779,14 +778,9 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
fp_path = os.path.split(fp_path_id)[0]
response = self.client_get(uri)
_get_sendfile.clear()
- test_upload_dir = os.path.split(settings.LOCAL_UPLOADS_DIR)[1]
test_run, worker = os.path.split(os.path.dirname(settings.LOCAL_UPLOADS_DIR))
self.assertEqual(response['X-Accel-Redirect'],
- '/serve_uploads/../../' +
- os.path.basename(get_dev_uuid_var_path()) +
- '/test-backend/' + os.path.basename(test_run) +
- '/' + worker + '/' + test_upload_dir +
- '/files/' + fp_path + '/' + name_str_for_test)
+ '/serve_uploads/' + fp_path + '/' + name_str_for_test)
if content_disposition != '':
self.assertIn('attachment;', response['Content-disposition'])
self.assertIn(content_disposition, response['Content-disposition'])