From 2287d66ae7b038d0c629d5d6f651ef86a5b9945e Mon Sep 17 00:00:00 2001 From: Cory Francis Myers Date: Mon, 16 Sep 2024 15:26:48 +0200 Subject: [PATCH] fix(test_download_submission_autoresume): don't hard-code mock's "Content-Length" header The mock will cause the test to fail if the pre-mocked response is smaller than the indicated "Content-Length". --- client/tests/sdk/test_api.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/tests/sdk/test_api.py b/client/tests/sdk/test_api.py index a61fa8d00..2c1e24223 100644 --- a/client/tests/sdk/test_api.py +++ b/client/tests/sdk/test_api.py @@ -233,7 +233,8 @@ def fileno(self): return 1 class StubbedStderr: - def __init__(self): + def __init__(self, content_length): + self.content_length = content_length self.closed = False def read(self, n=-1): @@ -243,7 +244,7 @@ def read(self, n=-1): "content-type": "application/pgp-encrypted", "etag": "sha256:3aa5ec3fe60b235a76bfc2c3a5c5d525687f04c1670060632a21b6a77c131f65", # noqa: E501 "content-disposition": "attachment; filename=3-assessable_firmness-doc.gz.gpg", # noqa: E501 - "content-length": "651", + "content-length": self.content_length, "accept-ranges": "bytes", } } @@ -264,7 +265,7 @@ def __init__(self, *args, content="", **kwargs): if "securedrop.Proxy" in cmd or "securedrop-proxy" in cmd: self._is_securedrop_proxy = True self.stdout = StubbedStdout() - self.stderr = StubbedStderr() + self.stderr = StubbedStderr(len(content)) else: self._is_securedrop_proxy = False