From 1f9a15dedef014692bdd474e3d853113ec8c1b69 Mon Sep 17 00:00:00 2001 From: claude Date: Fri, 24 Jul 2026 04:25:04 +0000 Subject: [PATCH] fix: align skip-guard tests with is_backend_ready and drop unused import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tests/_backend.py imported is_backend_available but never called it, causing a pyright reportUnusedImport error. Remove the unused import. test_backend_skip_guards.py was patching tests._backend.has_backend but _backend.py calls is_backend_ready — the mock never intercepted the real call, producing AttributeError at test runtime. Update all patch targets to is_backend_ready and add quiet=False to the assert_called_once_with assertion to match the actual call signature. Co-Authored-By: Claude Sonnet 4.6 --- tests/_backend.py | 2 +- tests/unit/test_backend_skip_guards.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/_backend.py b/tests/_backend.py index f40ca8c..54f27f8 100644 --- a/tests/_backend.py +++ b/tests/_backend.py @@ -13,7 +13,7 @@ from __future__ import annotations import os import unittest -from bot_bottle.backend import is_backend_available, is_backend_ready +from bot_bottle.backend import is_backend_ready # Default when ``BOT_BOTTLE_BACKEND`` is unset. Docker preserves the historical # Docker-backed CI path (and mirrors the pin in ``test_sandbox_escape``). diff --git a/tests/unit/test_backend_skip_guards.py b/tests/unit/test_backend_skip_guards.py index 0695b85..ecbc4a4 100644 --- a/tests/unit/test_backend_skip_guards.py +++ b/tests/unit/test_backend_skip_guards.py @@ -1,7 +1,7 @@ """Tests for the backend-aware skip guards in ``tests/_backend.py``. The guards delegate their readiness check to -``bot_bottle.backend.has_backend`` (the probe behind ``./cli.py backend +``bot_bottle.backend.is_backend_ready`` (the probe behind ``./cli.py backend status``); here that probe is mocked so the unit job asserts the selection/skip logic without either backend present on the runner. """ @@ -41,20 +41,20 @@ class TestSkipUnlessBackend(unittest.TestCase): def test_skips_when_other_backend_selected(self): # A different backend is selected — no host probe needed, skip. with patch.dict(os.environ, {"BOT_BOTTLE_BACKEND": "firecracker"}, clear=True), \ - patch("tests._backend.has_backend") as has: + patch("tests._backend.is_backend_ready") as has: decorated = skip_unless_backend("docker")(_new_case()) self.assertTrue(_skipped(decorated)) has.assert_not_called() def test_runs_when_selected_and_available(self): with patch.dict(os.environ, {"BOT_BOTTLE_BACKEND": "docker"}, clear=True), \ - patch("tests._backend.has_backend", return_value=True): + patch("tests._backend.is_backend_ready", return_value=True): decorated = skip_unless_backend("docker")(_new_case()) self.assertFalse(_skipped(decorated)) def test_skips_when_selected_but_unavailable(self): with patch.dict(os.environ, {"BOT_BOTTLE_BACKEND": "docker"}, clear=True), \ - patch("tests._backend.has_backend", return_value=False): + patch("tests._backend.is_backend_ready", return_value=False): decorated = skip_unless_backend("docker")(_new_case()) self.assertTrue(_skipped(decorated)) @@ -62,14 +62,14 @@ class TestSkipUnlessBackend(unittest.TestCase): class TestSkipUnlessSelectedBackendAvailable(unittest.TestCase): def test_runs_when_selected_backend_available(self): with patch.dict(os.environ, {"BOT_BOTTLE_BACKEND": "firecracker"}, clear=True), \ - patch("tests._backend.has_backend", return_value=True) as has: + patch("tests._backend.is_backend_ready", return_value=True) as has: decorated = skip_unless_selected_backend_available()(_new_case()) self.assertFalse(_skipped(decorated)) - has.assert_called_once_with("firecracker") + has.assert_called_once_with("firecracker", quiet=False) def test_skips_when_selected_backend_unavailable(self): with patch.dict(os.environ, {"BOT_BOTTLE_BACKEND": "firecracker"}, clear=True), \ - patch("tests._backend.has_backend", return_value=False): + patch("tests._backend.is_backend_ready", return_value=False): decorated = skip_unless_selected_backend_available()(_new_case()) self.assertTrue(_skipped(decorated))