コード例 #1
0
ファイル: commands.py プロジェクト: airshipit/shipyard
def describe_workflow(ctx, workflow_id):

    if not workflow_id:
        ctx.fail("An action id argument must be passed.")

    check_workflow_id(ctx, workflow_id)

    click.echo(DescribeWorkflow(ctx, workflow_id).invoke_and_return_resp())
コード例 #2
0
def test_check_workflow_id_invalid_date_format():
    """Check that the date format check invokes the context.fail"""
    ctx = Mock(side_effect=Exception("failed"))
    try:
        input_checks.check_workflow_id(ctx, 'something__2017-01-01T12:34:56')
    except Exception:
        pass
    # py 3.6: ctx.fail.assert_called()
    assert 'call.fail(' in str(ctx.mock_calls[0])
コード例 #3
0
def test_check_workflow_id_none():
    """Check that the workflow id check invokes the context.fail on None"""
    ctx = Mock(side_effect=Exception("failed"))
    try:
        input_checks.check_workflow_id(ctx, None)
    except Exception:
        pass
    # py 3.6: ctx.fail.assert_called()
    assert 'call.fail(' in str(ctx.mock_calls[0])
コード例 #4
0
def test_check_workflow_id_invalid_separator():
    """Check that the separator check invokes the context.fail"""
    ctx = Mock(side_effect=Exception("failed"))
    try:
        input_checks.check_workflow_id(ctx,
                                       'something20170101T12:34:56.000000')
    except Exception:
        pass
    # py 3.6: ctx.fail.assert_called()
    assert 'call.fail(' in str(ctx.mock_calls[0])
コード例 #5
0
def test_check_workflow_id_no_date():
    """Check tha a missing date portion of the string is rejected."""
    ctx = Mock(side_effect=Exception("failed"))
    try:
        input_checks.check_workflow_id(ctx, 'something__')
    except Exception:
        pass
    # py 3.6: ctx.fail.assert_called()
    assert 'date portion' in str(ctx.mock_calls[0])
    assert 'call.fail(' in str(ctx.mock_calls[0])
コード例 #6
0
def test_check_workflow_id_valid_tricky():
    """Check that a valid formatted id passes.

    This test provides something that arrow will parse as an invalid
    date if the code is not properly set up to separate the date
    first.
    """
    ctx = Mock(side_effect=Exception("failed"))
    input_checks.check_workflow_id(
        ctx, '2017-01-01T12:34:99.000__2017-01-01T12:34:56.000000')
    ctx.fail.assert_not_called()
コード例 #7
0
def test_check_workflow_id_valid():
    """Check that a valid formatted id passes"""
    ctx = Mock(side_effect=Exception("failed"))
    input_checks.check_workflow_id(ctx,
                                   'something__2017-01-01T12:34:56.000000')
    ctx.fail.assert_not_called()