-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tempest crash fetching task with error handling and retries
- Loading branch information
1 parent
391f870
commit 2223305
Showing
3 changed files
with
203 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import json | ||
from requests import Response | ||
|
||
def create_mock_response(status_code: int, body: dict = None, is_json: bool = True) -> Response: | ||
""" | ||
Creates a mock Response object for testing. | ||
Args: | ||
status_code: HTTP status code to return | ||
body: Response body (dict for JSON responses) | ||
is_json: Whether the response should be treated as JSON | ||
""" | ||
response = Response() | ||
response.status_code = status_code | ||
|
||
if body is None: | ||
body = {} | ||
|
||
if is_json: | ||
response._content = json.dumps(body).encode() | ||
else: | ||
response._content = str(body).encode() | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters