

def setUp(self):
    fake_ec2 = flexmock(name='fake_ec2')
    fake_ec2.should_receive('get_key_pair')
    fake_ec2.should_receive('create_key_pair').with_args('bookeyname').and_return(KeyPair())
    fake_ec2.should_receive('get_all_security_groups').and_return([])
    fake_ec2.should_receive('create_security_group').with_args('boogroup', 'AppScale security group').and_return(SecurityGroup())
    fake_ec2.should_receive('authorize_security_group')
    reservation = Reservation()
    instance = flexmock(name='instance', private_dns_name='private-ip', public_dns_name='public-ip', id='i-id', state='running', key_name='bookeyname')
    reservation.instances = [instance]
    fake_ec2.should_receive('get_all_instances').and_return([]).and_return([reservation])
    fake_ec2.should_receive('terminate_instances').and_return([instance])
    fake_ec2.should_receive('request_spot_instances')
    flexmock(boto.ec2)
    boto.ec2.should_receive('connect_to_region').and_return(fake_ec2)
    flexmock(utils).should_receive('get_secret').and_return('secret')
    flexmock(utils).should_receive('sleep').and_return()
    flexmock(utils).should_receive('get_random_alphanumeric').and_return('0000000000')
    flexmock(utils).should_receive('write_key_file').and_return()

dataset/ETHPy150Open AppScale/appscale/InfrastructureManager/tests/test_ec2_agent_w_spot.py TestEC2Agent.setUp/original