def test_waits_until_timeout(client, time, datetime_mock): first_timestamp = datetime.now() second_timestamp = datetime.now() + timedelta(0, 50, 0) last_timestamp = datetime.now() + timedelta(0, 61, 0) datetime_mock.now.side_effect = [first_timestamp, second_timestamp, last_timestamp] set_stack_status_returns(client, ['UPDATE_IN_PROGRESS', 'UPDATE_IN_PROGRESS', 'UPDATE_IN_PROGRESS', 'CREATE_FAILED']) set_stack_events(client) stack_waiter = StackWaiter(STACK, timeout=1) with pytest.raises(SystemExit, match='1'): stack_waiter.wait('0') assert time.sleep.call_count == 2 client.cancel_update_stack.assert_called_with(StackName=STACK)
def deploy(args): client = AWS.current_session().client('cloudformation') last_event = client.describe_stack_events( StackName=args.stack)['StackEvents'][0]['EventId'] client.execute_change_set( ChangeSetName=(CHANGE_SET_FORMAT.format(stack=args.stack)), StackName=args.stack) StackWaiter(args.stack, client).wait(last_event)
def remove(args): client = AWS.current_session().client('cloudformation') stack_id = client.describe_stacks( StackName=args.stack)['Stacks'][0]['StackId'] logger.info('Removing Stack and waiting for it to be removed, ...') last_event = client.describe_stack_events( StackName=args.stack)['StackEvents'][0]['EventId'] client.delete_stack(StackName=args.stack) StackWaiter(stack_id, client).wait(last_event)
def stack_waiter(cf_client_mock): return StackWaiter(STACK, cf_client_mock)
def stack_waiter(): return StackWaiter(STACK)