From ecbb46be2dbf141ddf48533f65793d02e375166b Mon Sep 17 00:00:00 2001 From: Zoheb Shaikh <26975142+ZohebShaikh@users.noreply.github.com> Date: Mon, 17 Aug 2026 09:02:10 +0100 Subject: [PATCH 1/2] feat: add logout --- src/blueapi/client/client.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/blueapi/client/client.py b/src/blueapi/client/client.py index ce5ec30016..8f72e085f1 100644 --- a/src/blueapi/client/client.py +++ b/src/blueapi/client/client.py @@ -775,6 +775,11 @@ def login(self, token_path: Path | None = None): else: print("Server is not configured to use authentication!") + def logout(self): + if sm := self._rest.session_manager: + sm.logout() + self._rest.session_manager = None + class PlanFailedError(Exception): def __init__(self, typ: str, message: str): From d7b3315e2aabc3a37d8363ae557a2e4cee7d01ca Mon Sep 17 00:00:00 2001 From: Zoheb Shaikh <26975142+ZohebShaikh@users.noreply.github.com> Date: Mon, 17 Aug 2026 11:24:53 +0100 Subject: [PATCH 2/2] add test --- tests/unit_tests/client/test_client.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit_tests/client/test_client.py b/tests/unit_tests/client/test_client.py index eaf96a3b2d..2a768c56af 100644 --- a/tests/unit_tests/client/test_client.py +++ b/tests/unit_tests/client/test_client.py @@ -1000,3 +1000,13 @@ def test_client_login_no_oidc( client.login() mock_session_manager.assert_not_called() + + +def test_client_logout(mock_rest: Mock, client: BlueapiClient): + mock_session_manager = Mock() + mock_rest.session_manager = mock_session_manager + + client.logout() + + mock_session_manager.logout.assert_called_once() + assert mock_rest.session_manager is None