def test_associate_external_elasticip_or_instance_external(self): ctx = self.mock_relationship_context( 'test_associate_external_elasticip_or_instance_external') current_ctx.set(ctx=ctx) client = self._get_ec2_client() address_object = client.allocate_address() self.addCleanup(address_object.delete) ctx.source.node.properties['use_external_resource'] = True ctx.target.node.properties['use_external_resource'] = True ctx.source.instance.runtime_properties['public_ip_address'] = \ '127.0.0.1' output = \ elasticip._associate_external_elasticip_or_instance( address_object.public_ip) self.assertEqual(True, output) self.assertIn( 'public_ip_address', ctx.source.instance.runtime_properties) self.assertEqual( address_object.public_ip, ctx.source.instance.runtime_properties['public_ip_address'])
def test_associate_external_elasticip_or_instance_external(self): ctx = self.mock_relationship_context( 'test_associate_external_elasticip_or_instance_external') current_ctx.set(ctx=ctx) client = self._get_ec2_client() address_object = client.allocate_address() self.addCleanup(address_object.delete) ctx.source.node.properties['use_external_resource'] = True ctx.target.node.properties['use_external_resource'] = True ctx.source.instance.runtime_properties['public_ip_address'] = \ '127.0.0.1' output = \ elasticip._associate_external_elasticip_or_instance( address_object.public_ip) self.assertEqual(True, output) self.assertIn('public_ip_address', ctx.source.instance.runtime_properties) self.assertEqual( address_object.public_ip, ctx.source.instance.runtime_properties['public_ip_address'])
def test_associate_external_elasticip_or_instance(self): """ This tests that this function returns False if use_external_resource is false. """ ctx = self.mock_relationship_context( 'test_associate_external_elasticip_or_instance') current_ctx.set(ctx=ctx) ctx.source.node.properties['use_external_resource'] = False output = \ elasticip._associate_external_elasticip_or_instance( '127.0.0.1') self.assertEqual(False, output)