Skip to content

Commit

Permalink
test: add pytest for fsread1 max_read_size validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jelly committed Aug 11, 2023
1 parent e7b5545 commit 5581861
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/pytest/mocktransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class MockTransport(asyncio.Transport):
close_future: Optional[asyncio.Future] = None

def send_json(self, _channel: str, **kwargs) -> None:
msg = {k.replace('_', '-'): v for k, v in kwargs.items()}
# max_read_size is one of our special keys which uses underscores
msg = {k.replace('_', '-') if k != "max_read_size" else k: v for k, v in kwargs.items()}
self.send_data(_channel, json.dumps(msg).encode('ascii'))

def send_data(self, channel: str, data: bytes) -> None:
Expand Down
3 changes: 3 additions & 0 deletions test/pytest/test_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ async def test_fsread1_errors(transport):
await transport.check_open('fsread1', path='/etc/shadow', problem='access-denied')
await transport.check_open('fsread1', path='/', problem='internal-error',
reply_keys={'message': "[Errno 21] Is a directory: '/'"})
await transport.check_open('fsread1', path='/etc/passwd', max_read_size="lol",
problem='protocol-error',
reply_keys={'message': "max_read_size must be an integer"})


@pytest.mark.asyncio
Expand Down

0 comments on commit 5581861

Please sign in to comment.