Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Sep 10, 2024
1 parent 4dbe60a commit ffd813e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_ash.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,21 @@ def send_reset(self) -> None:


class FakeTransport:
def __init__(self, receiver):
def __init__(self, receiver) -> None:
self.receiver = receiver
self.paused = False
self.paused: bool = False
self.closing: bool = False

def write(self, data: bytes) -> None:
if not self.paused:
self.receiver.data_received(data)

def close(self) -> None:
self.closing = True

def is_closing(self) -> bool:
return self.closing


class FakeTransportOneByteAtATime(FakeTransport):
def write(self, data: bytes) -> None:
Expand Down Expand Up @@ -317,6 +324,7 @@ async def test_sequence():
loop = asyncio.get_running_loop()
ezsp = MagicMock()
transport = MagicMock()
transport.is_closing.return_value = False

protocol = ash.AshProtocol(ezsp)
protocol._write_frame = MagicMock(wraps=protocol._write_frame)
Expand Down Expand Up @@ -408,6 +416,7 @@ async def test_ash_protocol_startup(caplog):

ezsp = MagicMock()
transport = MagicMock()
transport.is_closing.return_value = False

protocol = ash.AshProtocol(ezsp)
protocol._write_frame = MagicMock(wraps=protocol._write_frame)
Expand Down
1 change: 1 addition & 0 deletions tests/test_uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def test_eof_received(gw):
async def test_connection_lost_reset_error_propagation(monkeypatch):
app = MagicMock()
transport = MagicMock()
transport.is_closing.return_value = False

async def mockconnect(loop, protocol_factory, **kwargs):
protocol = protocol_factory()
Expand Down

0 comments on commit ffd813e

Please sign in to comment.