def test_validate_auth_vars_valid(): action = stubs.StubAction(stubs.StubCliContext()) try: action.validate_auth_vars() except AuthValuesError: # Valid parameters should not raise an AuthValuesError assert False
def test_commit_configdocs(*args): responses.add(responses.POST, 'http://shiptest/commitconfigdocs?force=false', body=None, status=200) response = CommitConfigdocs(stubs.StubCliContext(), False, False).invoke_and_return_resp() assert response == 'Configuration documents committed.\n'
def test_commit_configdocs_dryrun(*args): responses.add(responses.POST, 'http://shiptest/commitconfigdocs?force=false', body=None, status=200) response = CommitConfigdocs(stubs.StubCliContext(), False, True).invoke_and_return_resp() assert response == ('Configuration documents were not committed. Currently' ' in dryrun mode.\n')
def test_describe_step(*args): responses.add( responses.GET, 'http://shiptest/actions/01BTTMFVDKZFRJM80FGD7J1AKN/steps/preflight', body=GET_STEP_API_RESP, status=200) response = DescribeStep(stubs.StubCliContext(), '01BTTMFVDKZFRJM80FGD7J1AKN', 'preflight').invoke_and_return_resp() assert 'step/01BTTMFVDKZFRJM80FGD7J1AKN/preflight' in response
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).invoke_and_return_resp() assert 'Error_409' in response assert 'bad validations' in response assert 'action/01BTTMFVDKZFRJM80FGD7J1AKN' not in response
def test_control_409(*args): responses.add( responses.POST, 'http://shiptest/actions/01BTG32JW87G0YKA1K29TKNAFX/control/pause', body=resp_body, status=409) control_verb = 'pause' id = '01BTG32JW87G0YKA1K29TKNAFX' response = Control(stubs.StubCliContext(), control_verb, id).invoke_and_return_resp() # test correct function was called assert 'Unable to pause action' in response
def test_create_action(*args): responses.add(responses.POST, 'http://shiptest/actions', body=resp_body, status=201) response = CreateAction(stubs.StubCliContext(), action_name='deploy_site', param=None).invoke_and_return_resp() assert 'Name' in response assert 'Action' in response assert 'Lifecycle' in response assert 'action/01BTTMFVDKZFRJM80FGD7J1AKN' in response assert 'Error:' not in response
def test_control_stop(*args): responses.add( responses.POST, 'http://shiptest/actions/01BTG32JW87G0YKA1K29TKNAFX/control/stop', body=None, status=202) control_verb = 'stop' id = '01BTG32JW87G0YKA1K29TKNAFX' response = Control(stubs.StubCliContext(), control_verb, id).invoke_and_return_resp() # test correct function was called assert response == ('stop successfully submitted for action' ' 01BTG32JW87G0YKA1K29TKNAFX')
def test_describe_action(*args): responses.add(responses.GET, 'http://shiptest/actions/01BTTMFVDKZFRJM80FGD7J1AKN', body=GET_ACTION_API_RESP, status=200) response = DescribeAction( stubs.StubCliContext(), '01BTTMFVDKZFRJM80FGD7J1AKN').invoke_and_return_resp() assert 'action/01BTTMFVDKZFRJM80FGD7J1AKN' in response assert 'step/01BTTMFVDKZFRJM80FGD7J1AKN/action_xcom' in response assert 'Steps' in response assert 'Commands' in response assert 'Validations:' in response
def test_describe_workflow(*args): responses.add( responses.GET, 'http://shiptest/workflows/deploy_site__2017-10-09T21:19:03.000000', body=WF_API_RESP, status=200) response = DescribeWorkflow( stubs.StubCliContext(), 'deploy_site__2017-10-09T21:19:03.000000').invoke_and_return_resp() assert 'deploy_site__2017-10-09T21:19:03.000000' in response assert 'deploy_site.preflight__2017-10-09T21:19:03.000000' in response assert 'deploy_site.postflight__2017-10-09T21:19:03.000000' in response assert 'dag_concurrency_check' in response assert 'Subworkflows:' in response
def test_describe_validation(*args): responses.add(responses.GET, 'http://shiptest/actions/01BTTMFVDKZFRJM80FGD7J1AKN/' 'validationdetails/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_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
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
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
def test_validate_auth_vars_missing_required_and_others(): auth_vars = { 'project_domain_name': 'default', 'user_domain_name': 'default', 'project_name': 'service', 'username': None, 'password': '******', 'auth_url': None } param = stubs.gen_api_param(auth_vars=auth_vars) action = stubs.StubAction(stubs.StubCliContext(api_parameters=param)) with pytest.raises(AuthValuesError): try: action.validate_auth_vars() except AuthValuesError as ex: assert 'os-auth-url' in ex.diagnostic assert 'os-username' in ex.diagnostic assert 'os-password' not in ex.diagnostic raise
def test_create_configdocs(*args): succ_resp = stubs.gen_err_resp(message='Validations succeeded', sub_error_count=0, sub_info_count=0, reason='Validation', code=200) responses.add(responses.POST, 'http://shiptest/configdocs/design', body=succ_resp, status=201) filename = 'shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml' document_data = yaml.dump_all(filename) file_list = (filename, ) response = CreateConfigdocs(stubs.StubCliContext(), 'design', 'append', document_data, file_list).invoke_and_return_resp() assert 'Configuration documents added.' assert 'Status: Validations succeeded' in response assert 'Reason: Validation' in response
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 = 'shipyard_client/tests/unit/cli/create/sample_yaml/sample.yaml' document_data = yaml.dump_all(filename) file_list = (filename, ) response = CreateConfigdocs(stubs.StubCliContext(), 'design', 'append', 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