def test_add(self): act = elb_actor.RegisterInstance('UTA', { 'elb': 'test', 'region': 'us-east-1', 'instances': 'test' }) elb = mock.Mock() instance = 'i-un173s7' yield act._add(elb, [instance]) elb.register_instances.assert_called_with([instance])
def test_add_zones_noop(self): act = elb_actor.RegisterInstance('UTA', { 'elb': 'test', 'region': 'us-east-1', 'instances': 'test' }) act.ec2_conn = mock.Mock() zone = mock.Mock() zone.name = 'unit-test-zone' act.ec2_conn.get_all_zones.return_value = [zone] elb = mock.Mock() elb.availability_zones = ['unit-test-zone'] yield act._check_elb_zones(elb) self.assertEquals(elb.enable_zones.call_count, 0)
def test_execute(self): act = elb_actor.RegisterInstance('UTA', { 'elb': 'elb-test', 'region': 'us-east-1', 'instances': 'i-test' }) act._find_elb = mock.Mock() act._find_elb.return_value = helper.tornado_value(mock.Mock()) act._check_elb_zones = mock.Mock() act._check_elb_zones.return_value = helper.tornado_value(mock.Mock()) act._add = mock.Mock() act._add.return_value = helper.tornado_value(mock.Mock()) yield act._execute() act._find_elb.assert_called_with('elb-test') lb = yield act._find_elb() act._add.assert_called_with(lb, ['i-test'])
def test_execute_self(self): # No instance id specified act = elb_actor.RegisterInstance('UTA', { 'elb': 'elb-test', 'region': 'us-east-1' }) act._find_elb = mock.Mock() act._find_elb.return_value = helper.tornado_value(mock.Mock()) act._check_elb_zones = mock.Mock() act._check_elb_zones.return_value = helper.tornado_value(mock.Mock()) act._add = mock.Mock() act._add.return_value = helper.tornado_value(mock.Mock()) act._get_meta_data = helper.mock_tornado('i-test') yield act._execute() act._find_elb.assert_called_with('elb-test') lb = yield act._find_elb() act._add.assert_called_with(lb, ['i-test'])
def test_execute_dry(self): act = elb_actor.RegisterInstance('UTA', { 'elb': 'elb-test', 'region': 'us-east-1', 'instances': 'i-test' }, dry=True) act._find_elb = mock.Mock() act._find_elb.return_value = helper.tornado_value(mock.Mock()) act._check_elb_zones = mock.Mock() act._check_elb_zones.return_value = helper.tornado_value(mock.Mock()) act._add = mock.Mock() act._add.return_value = helper.tornado_value(mock.Mock()) yield act._execute() act._find_elb.assert_called_with('elb-test') yield act._find_elb() self.assertEquals(0, act._add.call_count)