diff --git a/src/binarylane/console/runners/command.py b/src/binarylane/console/runners/command.py index c03dad6..78c3b8b 100644 --- a/src/binarylane/console/runners/command.py +++ b/src/binarylane/console/runners/command.py @@ -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 diff --git a/tests/runners/test_command_runner.py b/tests/runners/test_command_runner.py index 85bd26e..e6027d0 100644 --- a/tests/runners/test_command_runner.py +++ b/tests/runners/test_command_runner.py @@ -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)