Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/binarylane/console/runners/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def response(self, status_code: int, received: Any) -> None:
if status_code == 401:
self.error(ExitCode.TOKEN, 'Unable to authenticate with API - please run "bl configure" to get started.')

# If no response is available, report an API error (unless it is `204 No Content`)
# If no response is available, report an API error (unless it is `202 Accepted` or `204 No Content`)
if received is None:
if status_code != 204:
if status_code not in (202, 204):
self.error(ExitCode.API, f"HTTP {status_code}")
return

Expand Down
10 changes: 10 additions & 0 deletions tests/runners/test_command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ def test_response_handles_nocontent(capsys: CaptureFixture[str]) -> None:
assert captured.err == "" and captured.out == ""


def test_response_handles_accepted(capsys: CaptureFixture[str]) -> None:
"""HTTP 202 Accepted with no body should not be treated as an error."""
runner = TypeRunner(CommandRunner)

runner.test.response(202, None)

captured = capsys.readouterr()
assert captured.err == "" and captured.out == ""


def test_response_handles_ok(capsys: CaptureFixture[str]) -> None:
runner = TypeRunner(CommandRunner)

Expand Down
Loading