Skip to content

Commit

Permalink
Bring test coverage up
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Oct 27, 2024
1 parent e27a8fd commit 57cda77
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,24 @@ async def test_connect(api, mock_command_rsp):
await api.connect()


async def test_connect_failure(api, mock_command_rsp):
transport = None

def mock_version(*args, **kwargs):
nonlocal transport
transport = api._uart._transport

raise asyncio.TimeoutError()

with patch.object(api, "version", side_effect=mock_version):
# We connect but fail to probe
with pytest.raises(asyncio.TimeoutError):
await api.connect()

assert api._uart is None
assert len(transport.close.mock_calls) == 1


async def test_close(api):
await api.connect()

Expand Down

0 comments on commit 57cda77

Please sign in to comment.