Files
unshackle/tests/remote/unit/test_input_bridge.py
T

28 lines
964 B
Python

"""Unit tests for unshackle.core.api.input_bridge.InputBridge."""
from __future__ import annotations
import pytest
from unshackle.core.api.input_bridge import InputBridge
from unshackle.core.remote_protocol import AuthStatus
pytestmark = pytest.mark.unit
def test_cancel_before_request_raises_immediately() -> None:
bridge = InputBridge()
bridge.cancel()
with pytest.raises(RuntimeError, match="cancelled"):
bridge.request_input("hello", timeout=5)
assert bridge.login_status is AuthStatus.AUTHENTICATING
def test_request_input_after_authentication_fails_fast() -> None:
"""After the login, a prompt with no attached session channel must not wait for an answer."""
bridge = InputBridge()
bridge.login_status = AuthStatus.AUTHENTICATED
with pytest.raises(RuntimeError, match="after authentication"):
bridge.request_input("Pick a profile", timeout=5)
assert bridge.login_status is AuthStatus.AUTHENTICATED