コード例 #1
0
def test_create_configdocs_409(*args):
    err_resp = stubs.gen_err_resp(message='Invalid collection',
                                  sub_message='Buffer is either not...',
                                  sub_error_count=1,
                                  sub_info_count=0,
                                  reason='Buffermode : append',
                                  code=409)
    responses.add(responses.POST,
                  'http://shiptest/configdocs/design',
                  body=err_resp,
                  status=409)

    filename = 'tests/unit/cli/create/sample_yaml/sample.yaml'
    document_data = yaml.dump_all(filename)
    file_list = (filename,)

    response = CreateConfigdocs(stubs.StubCliContext(),
                                'design',
                                'append',
                                False,
                                document_data,
                                file_list).invoke_and_return_resp()
    assert 'Error: Invalid collection' in response
    assert 'Reason: Buffermode : append' in response
    assert 'Buffer is either not...' in response
コード例 #2
0
def test_create_configdocs_201_with_val_fails(*args):
    succ_resp = stubs.gen_err_resp(message='Validations failed',
                                   sub_message='Some reason',
                                   sub_error_count=2,
                                   sub_info_count=1,
                                   reason='Validation',
                                   code=400)
    responses.add(responses.POST,
                  'http://shiptest/configdocs/design',
                  body=succ_resp,
                  status=201)

    filename = 'tests/unit/cli/create/sample_yaml/sample.yaml'
    document_data = yaml.dump_all(filename)
    file_list = (filename,)

    response = CreateConfigdocs(stubs.StubCliContext(),
                                'design',
                                'append',
                                False,
                                document_data,
                                file_list).invoke_and_return_resp()
    assert 'Configuration documents added.' in response
    assert 'Status: Validations failed' in response
    assert 'Reason: Validation' in response
    assert 'Some reason-1' in response
コード例 #3
0
 def validating_callback(request):
     # a request that has empty_collection should have no body.
     assert request.body is None
     resp_body = stubs.gen_err_resp(
         message='Validations succeeded',
         sub_error_count=0,
         sub_info_count=0,
         reason='Validation',
         code=200)
     return (201, {}, resp_body)
コード例 #4
0
def test_create_action_409(*args):
    responses.add(responses.POST,
                  'http://shiptest/actions',
                  body=stubs.gen_err_resp(message='Error_409',
                                          reason='bad validations'),
                  status=409)
    response = CreateAction(
        stubs.StubCliContext(),
        action_name='deploy_site',
        param=None,
        allow_intermediate_commits=False).invoke_and_return_resp()
    assert 'Error_409' in response
    assert 'bad validations' in response
    assert 'action/01BTTMFVDKZFRJM80FGD7J1AKN' not in response
コード例 #5
0
def test_get_renderedconfigdocs_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/renderedconfigdocs?version=buffer',
                  body=api_resp,
                  status=404)
    response = GetRenderedConfigdocs(
        stubs.StubCliContext(), version='buffer').invoke_and_return_resp()
    assert 'Error: Not Found' in response
    assert 'Reason: It does not exist' in response
コード例 #6
0
def test_commit_configdocs_forced(*args):
    api_resp = stubs.gen_err_resp(message="Conflicts message forced",
                                  sub_message='Another bucket message',
                                  sub_error_count=1,
                                  sub_info_count=0,
                                  reason='Conflicts reason',
                                  code=200)
    responses.add(responses.POST,
                  'http://shiptest/commitconfigdocs?force=true',
                  body=api_resp,
                  status=200)
    response = CommitConfigdocs(stubs.StubCliContext(), True,
                                False).invoke_and_return_resp()
    assert 'Status: Conflicts message forced' in response
    assert 'Configuration documents committed' in response
    assert 'Reason: Conflicts reason' in response
コード例 #7
0
def test_describe_action_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',
                  body=api_resp,
                  status=404)

    response = DescribeAction(
        stubs.StubCliContext(),
        '01BTTMFVDKZFRJM80FGD7J1AKN').invoke_and_return_resp()
    assert 'Error: Not Found' in response
    assert 'Reason: It does not exist' in response
コード例 #8
0
def test_describe_workflow_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/workflows/deploy_site__2017-10-09T21:19:03.000000',
        body=api_resp,
        status=404)

    response = DescribeWorkflow(
        stubs.StubCliContext(),
        'deploy_site__2017-10-09T21:19:03.000000').invoke_and_return_resp()
    assert 'Error: Not Found' in response
    assert 'Reason: It does not exist' in response