This commit is contained in:
zixuanzh 2018-11-20 23:49:37 -05:00
parent daf9f69b62
commit 2569eac3a0
2 changed files with 6 additions and 9 deletions

View File

@ -9,6 +9,5 @@ class RawConnection(IRawConnection):
self.reader = reader
self.writer = writer
def close(self):
self.writer.close()

View File

@ -1,26 +1,24 @@
import pytest
import asyncio
import pytest
from network.connection.raw_connection import RawConnection
# from network.connection.raw_connection import RawConnection
async def handle_echo(reader, writer):
data = await reader.read(100)
message = data.decode()
writer.write(data)
await writer.drain()
writer.close()
@pytest.mark.asyncio
async def test_echo():
async def test_simple_echo():
server_ip = '127.0.0.1'
server_port = 8888
await asyncio.start_server(handle_echo, server_ip, server_port)
reader, writer = await asyncio.open_connection(server_ip, server_port)
raw_connection = RawConnection(server_ip, server_port, reader, writer)
# raw_connection = RawConnection(server_ip, server_port, reader, writer)
test_message = "hello world"
writer.write(test_message.encode())