def test_good_address_associate(self): """ Tests that associate runs when clean. """ ctx = self.mock_relationship_context('test_good_address_associate') current_ctx.set(ctx=ctx) address = self.get_address() instance_id = self.get_instance_id() ctx.target.instance.runtime_properties['aws_resource_id'] = \ address.public_ip ctx.source.instance.runtime_properties['aws_resource_id'] = \ instance_id elasticip.associate(ctx=ctx) self.assertIn('instance_id', ctx.target.instance.runtime_properties) self.assertEquals( instance_id, ctx.target.instance.runtime_properties.get('instance_id'))
def test_good_address_associate(self): """ Tests that associate runs when clean. """ ctx = self.mock_relationship_context('test_good_address_associate') current_ctx.set(ctx=ctx) address = self.get_address() instance_id = self.get_instance_id() ctx.target.instance.runtime_properties['aws_resource_id'] = \ address.public_ip ctx.source.instance.runtime_properties['aws_resource_id'] = \ instance_id elasticip.associate(ctx=ctx) self.assertIn('instance_id', ctx.target.instance.runtime_properties) self.assertEquals(instance_id, ctx.target.instance.runtime_properties.get( 'instance_id'))
def test_good_address_associate_with_new_domain_property(self): """ Tests that associate runs when clean. """ ctx = self.mock_relationship_context('test_good_address_associate') ctx.source.node.properties['domain'] = '' current_ctx.set(ctx=ctx) address = self.get_address() instance_id = self.get_instance_id() ctx.target.instance.runtime_properties['aws_resource_id'] = \ address.public_ip ctx.source.instance.runtime_properties['aws_resource_id'] = \ instance_id ctx.source.instance.runtime_properties['vpc_id'] = \ self.create_vpc_client().create_vpc('10.10.10.0/16').id elasticip.associate(ctx=ctx) self.assertIn('instance_id', ctx.target.instance.runtime_properties) self.assertEquals( instance_id, ctx.target.instance.runtime_properties.get('instance_id')) self.assertIn('vpc_id', ctx.target.instance.runtime_properties)
def test_good_address_associate_with_new_domain_property(self): """ Tests that associate runs when clean. """ ctx = self.mock_relationship_context('test_good_address_associate') ctx.source.node.properties['domain'] = '' current_ctx.set(ctx=ctx) address = self.get_address() instance_id = self.get_instance_id() ctx.target.instance.runtime_properties['aws_resource_id'] = \ address.public_ip ctx.source.instance.runtime_properties['aws_resource_id'] = \ instance_id ctx.source.instance.runtime_properties['vpc_id'] = \ self.create_vpc_client().create_vpc('10.10.10.0/16').id elasticip.associate(ctx=ctx) self.assertIn('instance_id', ctx.target.instance.runtime_properties) self.assertEquals(instance_id, ctx.target.instance.runtime_properties.get( 'instance_id')) self.assertIn('vpc_id', ctx.target.instance.runtime_properties)
def test_existing_address_associate(self): """ Tests that when an address that is in the user's EC2 account is provided to the associate function no errors are raised """ ctx = self.mock_relationship_context('test_existing_address_associate') current_ctx.set(ctx=ctx) address = self.get_address() instance_id = self.get_instance_id() ctx.target.node.properties['use_external_resource'] = True ctx.target.node.properties['resource_id'] = address.public_ip ctx.target.instance.runtime_properties['aws_resource_id'] = \ address.public_ip ctx.source.node.properties['use_external_resource'] = True ctx.source.node.properties['resource_id'] = instance_id ctx.source.instance.runtime_properties['aws_resource_id'] = \ instance_id elasticip.associate(ctx=ctx) self.assertEqual( address.public_ip, ctx.source.instance.runtime_properties['public_ip_address'])
def test_associate_with_allocate_id(self, *_): """ This tests that this function returns True when associating with allocation_id. """ ctx = self.mock_relationship_context( 'test_associate_with_allocate_id') current_ctx.set(ctx=ctx) address = self.get_address() instance_id = self.get_instance_id() ctx.target.instance.runtime_properties['aws_resource_id'] = \ address.public_ip ctx.source.instance.runtime_properties['aws_resource_id'] = \ instance_id ctx.target.instance.runtime_properties['allocation_id'] = 'random' output = \ elasticip.associate() self.assertEqual(True, output)