Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tests: Fix RateLimitTestCase and HostRequestMock.
The Dancec93126172069
diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.pyindex 6bf3ada5dac..495698163d5 100644--- a/zerver/lib/test_helpers.py+++ b/zerver/lib/test_helpers.py@@ -400,10 +400,16 @@ class HostRequestMock(HttpRequest):self.content_type = ""self.session = SessionBase()+ # Mock parse_client() in middleware.py+ if meta_data and "HTTP_USER_AGENT" in meta_data:+ client = meta_data["HTTP_USER_AGENT"]+ else:+ client = ""+RequestNotes.set_notes(self,RequestNotes(- client_name="",+ client_name=client,log_data={},tornado_handler_id=None if tornado_handler is None else tornado_handler.handler_id,client=get_client(client_name) if client_name is not None else None,diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.pyindex d90a957b4f5..937ad455e0f 100644--- a/zerver/tests/test_decorators.py+++ b/zerver/tests/test_decorators.py@@ -499,7 +499,7 @@ class RateLimitTestCase(ZulipTestCase):expect_rate_limit: bool,check_web_view: bool = False,) -> None:- META = {"REMOTE_ADDR": remote_addr, "PATH_INFO": "test"}+ META = {"REMOTE_ADDR": remote_addr, "PATH_INFO": "test", "HTTP_USER_AGENT": client_name}request = HostRequestMock(host="zulip.testserver", client_name=client_name, meta_data=META)view_func = self.ratelimited_web_view if check_web_view else self.ratelimited_json_view