Exemplo n.º 1
0
def test_check_control_action_invalid():
    ctx = Mock(side_effect=Exception("failed"))
    try:
        input_checks.check_control_action(ctx, 'completely_bogus')
    except Exception:
        pass
    # py 3.6: ctx.fail.assert_called()
    assert 'call.fail(' in str(ctx.mock_calls[0])
Exemplo n.º 2
0
def test_check_control_action_none():
    ctx = Mock(side_effect=Exception("failed"))
    try:
        input_checks.check_control_action(ctx, None)
    except Exception:
        pass
    # py 3.6: ctx.fail.assert_called()
    assert 'call.fail(' in str(ctx.mock_calls[0])
Exemplo n.º 3
0
def control_command(ctx, action, target_type, id):
    """
    For more information on the control commands (pause, unpause, stop), please
    enter 'shipyard control <control command> --help.'
    """

    check_control_action(ctx, action)

    if id:
        check_id(ctx, id)
        ctx.invoke(getattr(control, 'control_' + action),
                   target_type=target_type,
                   id=id)

    else:
        ctx.invoke(getattr(control, 'control_' + action),
                   target_type=target_type)
Exemplo n.º 4
0
def test_check_control_action_valid():
    ctx = Mock(side_effect=Exception("failed"))
    input_checks.check_control_action(ctx, 'pause')
    input_checks.check_control_action(ctx, 'unpause')
    input_checks.check_control_action(ctx, 'stop')
    ctx.fail.assert_not_called()