Example #1
0
def describe_validation(ctx, validation_id, action):

    check_id(ctx, validation_id)
    check_id(ctx, action)

    click.echo(
        DescribeValidation(ctx, validation_id,
                           action).invoke_and_return_resp())
def test_describe_validation(*args):
    responses.add(responses.GET,
                  'http://shiptest/actions/01BTTMFVDKZFRJM80FGD7J1AKN/'
                  'validations/02AURNEWAAAESKN99EBF8J2BHD',
                  body=GET_VALIDATION_API_RESP,
                  status=200)

    response = DescribeValidation(
        stubs.StubCliContext(),
        action_id='01BTTMFVDKZFRJM80FGD7J1AKN',
        validation_id='02AURNEWAAAESKN99EBF8J2BHD').invoke_and_return_resp()

    v_str = "validation/01BTTMFVDKZFRJM80FGD7J1AKN/02AURNEWAAAESKN99EBF8J2BHD"
    assert v_str in response
    assert "Validations failed for field 'abc'" in response
def test_describe_validation_not_found(*args):
    api_resp = stubs.gen_err_resp(message='Not Found',
                                  sub_error_count=0,
                                  sub_info_count=0,
                                  reason='It does not exist',
                                  code=404)
    responses.add(responses.GET,
                  'http://shiptest/actions/01BTTMFVDKZFRJM80FGD7J1AKN/'
                  'validations/02AURNEWAAAESKN99EBF8J2BHD',
                  body=api_resp,
                  status=404)

    response = DescribeValidation(
        stubs.StubCliContext(),
        action_id='01BTTMFVDKZFRJM80FGD7J1AKN',
        validation_id='02AURNEWAAAESKN99EBF8J2BHD').invoke_and_return_resp()
    assert 'Error: Not Found' in response
    assert 'Reason: It does not exist' in response