python: Make test_bridge check_open() more flexible for testing reply details

We want to assert the `message` field of the close message soon as well.
Add a `reply_keys` dictionary which when given asserts extra fields of a
`close` or `ready` message.
This commit is contained in:
Martin Pitt 2023-02-03 09:54:46 +01:00 committed by Allison Karlitskaya
parent a2d976da7a
commit 60291fd727
1 changed files with 3 additions and 3 deletions

View File

@ -47,13 +47,13 @@ class MockTransport(asyncio.Transport):
self.send_json('', command='open', channel=channel, payload=payload, **kwargs)
return channel
async def check_open(self, payload, channel=None, problem=None, **kwargs):
async def check_open(self, payload, channel=None, problem=None, reply_keys: Optional[Dict[str, object]] = None, **kwargs):
ch = self.send_open(payload, channel, **kwargs)
if problem is None:
await self.assert_msg('', command='ready', channel=ch)
await self.assert_msg('', command='ready', channel=ch, **(reply_keys or {}))
assert ch in self.protocol.open_channels
else:
await self.assert_msg('', command='close', channel=ch, problem=problem)
await self.assert_msg('', command='close', channel=ch, problem=problem, **(reply_keys or {}))
assert ch not in self.protocol.open_channels
return ch