Skip to content

Commit

Permalink
Clean up client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SaladDais committed Dec 13, 2023
1 parent 5517d60 commit 1ded118
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/client/test_hippo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def send_packet(self, packet: UDPPacket) -> None:
packet = copy.copy(packet)
packet.direction = Direction.IN
# Delay calling so the client can do its ACK bookkeeping first
asyncio.get_event_loop_policy().get_event_loop().call_soon(lambda: self._server.process_inbound(packet))
asyncio.get_event_loop().call_soon(lambda: self._server.process_inbound(packet))


class MockHippoClient(HippoClient):
Expand Down Expand Up @@ -112,14 +112,13 @@ async def asyncSetUp(self):
self.client = MockHippoClient(self.server)

async def asyncTearDown(self):
await self.client.aclose()
self.aio_mock.stop()
try:
await self.client.aclose()
finally:
self.aio_mock.stop()

async def _log_client_in(self, client: MockHippoClient):
async def _do_login():
await client.login("foo", "bar", login_uri=self.FAKE_LOGIN_URI)

login_task = asyncio.create_task(_do_login())
login_task = asyncio.create_task(client.login("foo", "bar", login_uri=self.FAKE_LOGIN_URI))
with self.server_handler.subscribe_async(
("*",),
) as get_msg:
Expand All @@ -141,9 +140,8 @@ async def test_login(self):
with self.server_handler.subscribe_async(
("*",),
) as get_msg:
logout_task = asyncio.create_task(self.client.logout())
await self.client.logout()
assert (await _soon(get_msg)).name == "LogoutRequest"
await logout_task

async def test_eq(self):
await self._log_client_in(self.client)
Expand Down

0 comments on commit 1ded118

Please sign in to comment.