def test__stack_updatable_limit_exceeded_does_not_exist(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) assert_equals(False, cfno._stack_updatable(cfn, 'test'))
def test__get_difference_no_difference(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) assert_equals([], cfno._get_difference(cfn, 'test', '{"a": "b"}'))
def test__stack_exists_nonexistant(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) assert_equals(False, cfno._stack_exists(cfn, 'test'))
def test_do_poll_true_delete_catches_rate_limit(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) assert_equals(True, cfno.do_poll(cfn, 'test', True, 'delete'))
def test_do_poll_true_create_returns_false_on_non_existing_stack(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) assert_equals(False, cfno.do_poll(cfn, 'test', True, 'create'))
def test__upload_stack_succeeds_iam_profile(self): cfno = AWSCFNOutput() creds = { 'audit_output': 'test', 'use_iam_profile': True, } assert_equals(None, cfno._upload_stack('{}', 'test', creds))
def test_do_poll_true_returns_true_multiple_loops(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) assert_equals(True, cfno.do_poll(cfn, 'test', True, 'create'))
def test__stack_updatable_exists(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) assert_equals(True, cfno._stack_updatable(cfn, 'test'))
def test__show_prompt_no_difference(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) assert_equals(False, cfno._show_prompt(cfn, 'test', '{"a": "b"}', _mock_allowed_update(self)))
def test__upload_stack_succeeds(self): cfno = AWSCFNOutput() creds = { 'access': '1234', 'secret': '1234', 'audit_output': 'test', } assert_equals(None, cfno._upload_stack('{}', 'test', creds))
def test__show_prompt_difference_yes(self): cfno = AWSCFNOutput() cfn = boto.connect_cloudformation( aws_access_key_id='access', aws_secret_access_key='secret' ) sys.stdout = open('/dev/null', 'w') assert_equals(True, cfno._show_prompt(cfn, 'test', '{"a": "c"}', _mock_allowed_update(self)))
def test_run_create_instance_profile_returns_true(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'use_iam_profile': True, 'name': 'test', 'environment': 'test', 'audit': 'NoopAudit', } assert_equals(cfno.run('{"a": "b"}', metadata), True)
def test_run_create_returns_true(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'audit': 'NoopAudit', } assert_equals(cfno.run('{"a": "b"}', metadata), True)
def test_run_audit_failure_connects(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'audit': 'S3Audit', } assert_equals(cfno.run('{"a": "b"}', metadata), True)
def test_run_trigger_stack_exists_no_update_returns_true(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'audit': 'NoopAudit', 'audit_output': 'thingy', 'strategy': 'InPlace', } assert_equals(True, cfno.run('{"a": "b"}', metadata, action='trigger'))
def test_run_with_tags_connects(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'audit': 'NoopAudit', 'tags': { 'Name': 'test' } } assert_equals(cfno.run('{"a": "b"}', metadata), True)
def test_run_connects_upload_succeeds(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'audit': 'NoopAudit', 'audit_output': 'thingy', 'strategy': 'InPlace', } assert_equals(cfno.run('{"a": "b"}', metadata, poll=False, action='create', upload=True), True)
def test_run_update_stack_nonexisting_stack_returns_true(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'audit': 'NoopAudit', 'audit_output': 'thingy', 'strategy': 'InPlace', } assert_equals(cfno.run('{"a": "b"}', metadata, poll=False, action='update', upload=True), True)
def test_run_delete_existing_stack_prompt_no_returns_false(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'audit': 'NoopAudit', 'audit_output': 'thingy', 'strategy': 'PromptInPlace', } assert_equals(cfno.run('{"a": "b"}', metadata, action='delete', upload=True), False)
def test_run_delete_nonexistant_stack_succeeds(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'audit': 'NoopAudit', 'audit_output': 'thingy', 'strategy': 'InPlace', } assert_equals(cfno.run('{"a": "b"}', metadata, action='delete', upload=True), True)
def test_run_with_prompt_false_succeeds(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'strategy': 'PromptInPlace', 'audit': 'NoopAudit', 'tags': { 'Name': 'test' } } assert_equals(cfno.run('{"a": "b"}', metadata, action='update'), True)
def test_run_with_no_iam_caps_succeeds(self): cfno = AWSCFNOutput() metadata = { 'region': 'eu-west-1', 'access': '1234', 'secret': '2345', 'name': 'test', 'environment': 'test', 'strategy': 'InPlace', 'audit': 'NoopAudit', 'tags': { 'Name': 'test' } } data = '{"Resources": {"foo": {"Type": "AWS::AMI::Thing"}}}' assert_equals(cfno.run(data, metadata), True)
def test__get_input_not_term(self): cfno = AWSCFNOutput() assert_equals(cfno._get_input('test'), 'y')
def test_do_poll_false_returns_true(self): cfno = AWSCFNOutput() assert_equals(True, cfno.do_poll(None, 'test', False, 'create'))