diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.py index a056bc1dce..fa85c051f1 100644 --- a/zerver/tests/test_slack_importer.py +++ b/zerver/tests/test_slack_importer.py @@ -63,16 +63,16 @@ def remove_folder(path: str) -> None: if os.path.exists(path): shutil.rmtree(path) +class MockResponse: + def __init__(self, json_data: Dict[str, Any], status_code: int) -> None: + self.json_data = json_data + self.status_code = status_code + + def json(self) -> Dict[str, Any]: + return self.json_data + # This method will be used by the mock to replace requests.get -def mocked_requests_get(*args: List[str], **kwargs: List[str]) -> mock.Mock: - class MockResponse: - def __init__(self, json_data: Dict[str, Any], status_code: int) -> None: - self.json_data = json_data - self.status_code = status_code - - def json(self) -> Dict[str, Any]: - return self.json_data - +def mocked_requests_get(*args: List[str], **kwargs: List[str]) -> MockResponse: if args[0] == 'https://slack.com/api/users.list?token=xoxp-valid-token': return MockResponse({"ok": True, "members": "user_data"}, 200) elif args[0] == 'https://slack.com/api/users.list?token=xoxp-invalid-token':