def test_get_security_group_from_id(self): ctx = self.mock_cloudify_context('test_get_security_group_from_id') current_ctx.set(ctx=ctx) client = self._get_ec2_client() group = client.create_security_group('test_get_security_group_from_id', 'some description') self.addCleanup(group.delete) group_from_plugin = securitygroup._get_security_group_from_name( group_name=group.name) self.assertEqual(group.id, group_from_plugin.id)
def test_get_security_group_from_name_but_really_id(self): ctx = self.mock_cloudify_context( 'test_get_security_group_from_name_but_really_id') current_ctx.set(ctx=ctx) client = self._get_ec2_client() group = client.create_security_group( 'test_get_security_group_from_name_but_really_id', 'some description') self.addCleanup(group.delete) group_from_plugin = securitygroup._get_security_group_from_name( group_name=group.id) self.assertEqual(group.name, group_from_plugin.name)
def test_get_security_group_from_name(self): """This tests that _get_security_group_from_name returns a securoty group from an ID as expected. """ test_properties = self.get_mock_properties() ctx = self.security_group_mock('test_get_security_group_from_name', test_properties) current_ctx.set(ctx=ctx) with mock_ec2(): ec2_client = connection.EC2ConnectionClient().client() group = \ ec2_client.create_security_group('test_get_' 'security_group_from_name', 'this is test') ctx.instance.runtime_properties['aws_resource_id'] = group.id output = securitygroup._get_security_group_from_name(group.id) self.assertEqual(group.id, output.id)
def test_get_security_group_from_name(self): """This tests that _get_security_group_from_name returns a securoty group from an ID as expected. """ test_properties = self.get_mock_properties() ctx = self.security_group_mock( 'test_get_security_group_from_name', test_properties) current_ctx.set(ctx=ctx) with mock_ec2(): ec2_client = connection.EC2ConnectionClient().client() group = \ ec2_client.create_security_group('test_get_' 'security_group_from_name', 'this is test') ctx.instance.runtime_properties['aws_resource_id'] = group.id output = securitygroup._get_security_group_from_name( group.id) self.assertEqual(group.id, output.id)