Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_join_otaa_timeout(runner, mock_rak811):
mock_rak811.return_value.join_otaa.side_effect = Rak811TimeoutError(
'Timeout while waiting for event'
)
result = runner.invoke(cli, ['-v', 'join-otaa'])
mock_rak811.return_value.join_otaa.assert_called_once()
assert result.output == 'RAK811 timeout: Timeout while waiting for event\n'
def print_exception(e):
"""Print exception raised by the Rak811 library."""
if isinstance(e, Rak811ResponseError):
click.echo('RAK811 response error {}: {}'.format(e.errno, e.strerror))
elif isinstance(e, Rak811EventError):
click.echo('RAK811 event error {}: {}'.format(e.errno, e.strerror))
elif isinstance(e, Rak811TimeoutError):
click.echo('RAK811 timeout: {}'.format(e))
else:
click.echo('RAK811 unexpected exception {}'.format(e))