Ejemplo n.º 1
0
async def test_user_connection_failed(flow, mrp_device, pairing_mock):
    """Test error message when connection to device fails."""
    pairing_mock.begin.side_effect = exceptions.ConnectionFailedError()

    (await flow().step_user(identifier="MRP Device")).gives_form_confirm(
        description_placeholders={"name": "MRP Device"})

    (await flow().step_confirm()).gives_form_service_problem(
        description_placeholders={"protocol": "MRP"})

    (await flow().step_service_problem()).gives_abort("invalid_config")
Ejemplo n.º 2
0
async def error_handler(func, fallback, *args, **kwargs):
    """Call a function and re-map exceptions to match pyatv interface."""
    try:
        return await func(*args, **kwargs)
    except (OSError, asyncio.TimeoutError) as ex:
        raise exceptions.ConnectionFailedError(str(ex)) from ex
    except exceptions.BackOffError:
        raise
    except exceptions.NoCredentialsError:
        raise
    except Exception as ex:
        raise fallback(str(ex)) from ex