Exemplo n.º 1
0
async def reset(request: web.Request) -> web.Response:
    """ Execute a reset of the requested parts of the user configuration.

    POST /settings/reset {resetOption: Any}

    -> 200 OK, {"links": {"restart": uri}}
    -> 400 Bad Request, {"error": error-shortmessage, "message": str}
    """
    data = await request.json()

    try:
        # Convert to dict of ResetOptionId to value
        data = {reset_util.ResetOptionId(k): v for k, v in data.items()}

        # We provide the parts that should be reset. Any with a
        # non-falsey value.
        reset_util.reset(set(k for k, v in data.items() if v))
    except ValueError as e:
        return web.json_response(
            {
                'error': 'bad-reset-option',
                'message': str(e)
            }, status=400)

    return web.json_response({}, status=200)
Exemplo n.º 2
0
def test_reset_all_set(mock_reset_boot_scripts, mock_reset_labware_calibration,
                       mock_reset_tip_probe):
    reset.reset({
        reset.ResetOptionId.boot_scripts, reset.ResetOptionId.tip_probe,
        reset.ResetOptionId.labware_calibration
    })
    mock_reset_labware_calibration.assert_called_once()
    mock_reset_boot_scripts.assert_called_once()
    mock_reset_tip_probe.assert_called_once()
Exemplo n.º 3
0
async def post_settings_reset_options(
        factory_reset_commands: Dict[reset_util.ResetOptionId, bool]) \
        -> V1BasicResponse:
    options = set(k for k, v in factory_reset_commands.items() if v)
    reset_util.reset(options)

    message = "Options '{}' were reset".format(
        ", ".join(o.name for o in options)) \
        if options else "Nothing to do"
    return V1BasicResponse(message=message)
Exemplo n.º 4
0
def test_reset_empty_set(mock_reset_boot_scripts,
                         mock_reset_labware_calibration, mock_reset_tip_probe):
    reset.reset(set())
    mock_reset_labware_calibration.assert_not_called()
    mock_reset_boot_scripts.assert_not_called()
    mock_reset_tip_probe.assert_not_called()