Compare commits
1 Commits
main
...
network-te
Author | SHA1 | Date | |
---|---|---|---|
56ca50a0df |
@ -32,6 +32,7 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from secret_handshake import SHSClient, SHSServer
|
||||
from secret_handshake.boxstream import BoxStreamKeys
|
||||
from secret_handshake.network import SHSDuplexStream
|
||||
|
||||
from .helpers import AsyncBuffer
|
||||
|
||||
@ -169,3 +170,30 @@ async def test_server(mocker: MockerFixture) -> None:
|
||||
|
||||
await server.listen()
|
||||
await wait_for(resolve.wait(), 5)
|
||||
|
||||
|
||||
def test_duplex_write(mocker: MockerFixture) -> None:
|
||||
"""Test the writing capabilities of the duplex stream"""
|
||||
|
||||
d_stream = SHSDuplexStream()
|
||||
d_stream.write_stream = mocker.AsyncMock()
|
||||
d_stream.write(b"thing")
|
||||
|
||||
d_stream.write_stream.write.assert_called_once_with(b"thing")
|
||||
|
||||
|
||||
def test_duplex_close_no_write_stream() -> None:
|
||||
"""Test if SHSDuplexStream’s close method doesn’t fail if there is no write stream"""
|
||||
|
||||
d_stream = SHSDuplexStream()
|
||||
assert d_stream.write_stream is None
|
||||
d_stream.close()
|
||||
|
||||
# We cannot really do assertions here. If there is not set (it is None), the above call would fail
|
||||
|
||||
|
||||
def test_duplex_stream_aiter() -> None:
|
||||
"""Test if the __aiter__ method of SHSDuplexStream returns the stream itself"""
|
||||
|
||||
d_stream = SHSDuplexStream()
|
||||
assert d_stream.__aiter__() is d_stream # pylint: disable=unnecessary-dunder-call
|
||||
|
Loading…
Reference in New Issue
Block a user