Unit test case migration for Stack object
Migrates the Stack usage from db api into heat objects Closes-bug: #1434455 Change-Id: Id7af1f1d8790d43cadf1a26e09cc60103c75c5b8
This commit is contained in:
parent
9dc904fddc
commit
ca1254bc85
@ -596,7 +596,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
|
||||
template, input_params, None,
|
||||
{'adopt_stack_data': str(adopt_data)})
|
||||
|
||||
stack = db_api.stack_get(self.ctx, result['stack_id'])
|
||||
stack = stack_object.Stack.get_by_id(self.ctx, result['stack_id'])
|
||||
self.assertEqual(template, stack.raw_template.template)
|
||||
self.assertEqual(input_params['parameters'],
|
||||
stack.raw_template.environment['parameters'])
|
||||
@ -612,7 +612,7 @@ class StackServiceCreateUpdateDeleteTest(common.HeatTestCase):
|
||||
template, {}, None,
|
||||
{'adopt_stack_data': str(adopt_data)})
|
||||
|
||||
stack = db_api.stack_get(self.ctx, result['stack_id'])
|
||||
stack = stack_object.Stack.get_by_id(self.ctx, result['stack_id'])
|
||||
self.assertEqual((parser.Stack.ADOPT, parser.Stack.IN_PROGRESS),
|
||||
(stack.action, stack.status))
|
||||
|
||||
@ -1992,7 +1992,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@mock.patch.object(db_api, 'stack_get_all')
|
||||
@mock.patch.object(stack_object.Stack, 'get_all')
|
||||
def test_stack_list_passes_marker_info(self, mock_stack_get_all):
|
||||
limit = object()
|
||||
marker = object()
|
||||
@ -2011,7 +2011,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
mock.ANY,
|
||||
)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_get_all')
|
||||
@mock.patch.object(stack_object.Stack, 'get_all')
|
||||
def test_stack_list_passes_filtering_info(self, mock_stack_get_all):
|
||||
filters = {'foo': 'bar'}
|
||||
self.eng.list_stacks(self.ctx, filters=filters)
|
||||
@ -2026,7 +2026,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
mock.ANY,
|
||||
)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_get_all')
|
||||
@mock.patch.object(stack_object.Stack, 'get_all')
|
||||
def test_stack_list_tenant_safe_defaults_to_true(self, mock_stack_get_all):
|
||||
self.eng.list_stacks(self.ctx)
|
||||
mock_stack_get_all.assert_called_once_with(mock.ANY,
|
||||
@ -2040,7 +2040,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
mock.ANY,
|
||||
)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_get_all')
|
||||
@mock.patch.object(stack_object.Stack, 'get_all')
|
||||
def test_stack_list_passes_tenant_safe_info(self, mock_stack_get_all):
|
||||
self.eng.list_stacks(self.ctx, tenant_safe=False)
|
||||
mock_stack_get_all.assert_called_once_with(mock.ANY,
|
||||
@ -2054,7 +2054,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
mock.ANY,
|
||||
)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_get_all')
|
||||
@mock.patch.object(stack_object.Stack, 'get_all')
|
||||
def test_stack_list_show_nested(self, mock_stack_get_all):
|
||||
self.eng.list_stacks(self.ctx, show_nested=True)
|
||||
mock_stack_get_all.assert_called_once_with(mock.ANY,
|
||||
@ -2068,7 +2068,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
True,
|
||||
)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_get_all')
|
||||
@mock.patch.object(stack_object.Stack, 'get_all')
|
||||
def test_stack_list_show_deleted(self, mock_stack_get_all):
|
||||
self.eng.list_stacks(self.ctx, show_deleted=True)
|
||||
mock_stack_get_all.assert_called_once_with(mock.ANY,
|
||||
@ -2082,7 +2082,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
mock.ANY,
|
||||
)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_count_all')
|
||||
@mock.patch.object(stack_object.Stack, 'count_all')
|
||||
def test_count_stacks_passes_filter_info(self, mock_stack_count_all):
|
||||
self.eng.count_stacks(self.ctx, filters={'foo': 'bar'})
|
||||
mock_stack_count_all.assert_called_once_with(mock.ANY,
|
||||
@ -2091,7 +2091,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
show_deleted=False,
|
||||
show_nested=False)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_count_all')
|
||||
@mock.patch.object(stack_object.Stack, 'count_all')
|
||||
def test_count_stacks_tenant_safe_default_true(self, mock_stack_count_all):
|
||||
self.eng.count_stacks(self.ctx)
|
||||
mock_stack_count_all.assert_called_once_with(mock.ANY,
|
||||
@ -2100,7 +2100,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
show_deleted=False,
|
||||
show_nested=False)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_count_all')
|
||||
@mock.patch.object(stack_object.Stack, 'count_all')
|
||||
def test_count_stacks_passes_tenant_safe_info(self, mock_stack_count_all):
|
||||
self.eng.count_stacks(self.ctx, tenant_safe=False)
|
||||
mock_stack_count_all.assert_called_once_with(mock.ANY,
|
||||
@ -2109,7 +2109,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
show_deleted=False,
|
||||
show_nested=False)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_count_all')
|
||||
@mock.patch.object(stack_object.Stack, 'count_all')
|
||||
def test_count_stacks_show_nested(self, mock_stack_count_all):
|
||||
self.eng.count_stacks(self.ctx, show_nested=True)
|
||||
mock_stack_count_all.assert_called_once_with(mock.ANY,
|
||||
@ -2118,7 +2118,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
show_deleted=False,
|
||||
show_nested=True)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_count_all')
|
||||
@mock.patch.object(stack_object.Stack, 'count_all')
|
||||
def test_count_stack_show_deleted(self, mock_stack_count_all):
|
||||
self.eng.count_stacks(self.ctx, show_deleted=True)
|
||||
mock_stack_count_all.assert_called_once_with(mock.ANY,
|
||||
@ -2575,7 +2575,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
test_data = {'food': 'yum'}
|
||||
|
||||
self.m.StubOutWithMock(service.EngineService, '_get_stack')
|
||||
s = db_api.stack_get(self.ctx, self.stack.id)
|
||||
s = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
service.EngineService._get_stack(self.ctx,
|
||||
self.stack.identifier()).AndReturn(s)
|
||||
|
||||
@ -2668,7 +2668,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
|
||||
test_data = {'food': 'yum'}
|
||||
self.m.StubOutWithMock(service.EngineService, '_get_stack')
|
||||
s = db_api.stack_get(self.ctx, self.stack.id)
|
||||
s = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
service.EngineService._get_stack(self.ctx,
|
||||
self.stack.identifier()).AndReturn(s)
|
||||
self.m.ReplayAll()
|
||||
@ -3093,7 +3093,7 @@ class StackServiceTest(common.HeatTestCase):
|
||||
self.assertRaises(exception.StackExists, self.eng._validate_new_stack,
|
||||
self.ctx, 'test_existing_stack', tmpl)
|
||||
|
||||
@mock.patch.object(db_api, 'stack_count_all')
|
||||
@mock.patch.object(service.stack_object.Stack, 'count_all')
|
||||
def test_validate_new_stack_checks_stack_limit(self, mock_db_count):
|
||||
cfg.CONF.set_override('max_stacks_per_tenant', 99)
|
||||
mock_db_count.return_value = 99
|
||||
|
@ -13,13 +13,13 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from heat.db import api as db_api
|
||||
from heat.engine import event
|
||||
from heat.engine import parser
|
||||
from heat.engine import resource
|
||||
from heat.engine import rsrc_defn
|
||||
from heat.engine import template
|
||||
from heat.objects import event as event_object
|
||||
from heat.objects import stack as stack_object
|
||||
from heat.tests import common
|
||||
from heat.tests import generic_resource as generic_rsrc
|
||||
from heat.tests import utils
|
||||
@ -57,7 +57,7 @@ class EventTest(common.HeatTestCase):
|
||||
|
||||
self.resource = self.stack['EventTestResource']
|
||||
self.resource._store()
|
||||
self.addCleanup(db_api.stack_delete, self.ctx, self.stack.id)
|
||||
self.addCleanup(stack_object.Stack.delete, self.ctx, self.stack.id)
|
||||
|
||||
def test_load(self):
|
||||
self.resource.resource_id_set('resource_physical_id')
|
||||
|
@ -24,7 +24,6 @@ import six
|
||||
from heat.common import context
|
||||
from heat.common import exception
|
||||
from heat.common import template_format
|
||||
import heat.db.api as db_api
|
||||
from heat.engine.clients.os import keystone
|
||||
from heat.engine.clients.os import nova
|
||||
from heat.engine import environment
|
||||
@ -134,8 +133,9 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.id = '1234'
|
||||
|
||||
# Simulate a deleted stack
|
||||
self.m.StubOutWithMock(db_api, 'stack_get')
|
||||
db_api.stack_get(self.stack.context, self.stack.id).AndReturn(None)
|
||||
self.m.StubOutWithMock(stack_object.Stack, 'get_by_id')
|
||||
stack_object.Stack.get_by_id(self.stack.context,
|
||||
self.stack.id).AndReturn(None)
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
||||
@ -506,12 +506,12 @@ class StackTest(common.HeatTestCase):
|
||||
|
||||
self.stack.set_stack_user_project_id(project_id='aproject456')
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
self.stack.delete(abandon=True)
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -1079,7 +1079,7 @@ class StackTest(common.HeatTestCase):
|
||||
stack_ownee = stack.Stack(self.ctx, 'ownee_stack', self.tmpl,
|
||||
owner_id=self.stack.id)
|
||||
stack_ownee.store()
|
||||
db_stack = db_api.stack_get(self.ctx, stack_ownee.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, stack_ownee.id)
|
||||
self.assertEqual(self.stack.id, db_stack.owner_id)
|
||||
|
||||
def test_init_user_creds_id(self):
|
||||
@ -1104,7 +1104,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.store()
|
||||
|
||||
# The store should've created a user_creds row and set user_creds_id
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
user_creds_id = db_stack.user_creds_id
|
||||
self.assertIsNotNone(user_creds_id)
|
||||
|
||||
@ -1140,7 +1140,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.store()
|
||||
|
||||
# The store should've created a user_creds row and set user_creds_id
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
user_creds_id = db_stack.user_creds_id
|
||||
self.assertIsNotNone(user_creds_id)
|
||||
|
||||
@ -1190,7 +1190,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.tmpl, username='foobar')
|
||||
self.ctx.username = 'not foobar'
|
||||
self.stack.store()
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
self.assertEqual('foobar', db_stack.username)
|
||||
|
||||
def test_store_backup_true(self):
|
||||
@ -1198,7 +1198,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.tmpl, username='foobar')
|
||||
self.ctx.username = 'not foobar'
|
||||
self.stack.store(backup=True)
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
self.assertTrue(db_stack.backup)
|
||||
|
||||
def test_store_backup_false(self):
|
||||
@ -1206,7 +1206,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.tmpl, username='foobar')
|
||||
self.ctx.username = 'not foobar'
|
||||
self.stack.store(backup=False)
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
self.assertFalse(db_stack.backup)
|
||||
|
||||
def test_init_stored_context_false(self):
|
||||
@ -1296,7 +1296,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'user_project_none', self.tmpl)
|
||||
self.stack.store()
|
||||
self.assertIsNone(self.stack.stack_user_project_id)
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
self.assertIsNone(db_stack.stack_user_project_id)
|
||||
|
||||
def test_stack_user_project_id_constructor(self):
|
||||
@ -1308,7 +1308,7 @@ class StackTest(common.HeatTestCase):
|
||||
stack_user_project_id='aproject1234')
|
||||
self.stack.store()
|
||||
self.assertEqual('aproject1234', self.stack.stack_user_project_id)
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
self.assertEqual('aproject1234', db_stack.stack_user_project_id)
|
||||
|
||||
self.stack.delete()
|
||||
@ -1325,7 +1325,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.assertIsNone(self.stack.stack_user_project_id)
|
||||
self.stack.set_stack_user_project_id(project_id='aproject456')
|
||||
self.assertEqual('aproject456', self.stack.stack_user_project_id)
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
self.assertEqual('aproject456', db_stack.stack_user_project_id)
|
||||
|
||||
self.stack.delete()
|
||||
@ -1343,7 +1343,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack.create_stack_user_project_id()
|
||||
|
||||
self.assertEqual('aprojectid', self.stack.stack_user_project_id)
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
self.assertEqual('aprojectid', db_stack.stack_user_project_id)
|
||||
|
||||
self.stack.delete()
|
||||
|
@ -20,12 +20,12 @@ import mock
|
||||
from heat.common import exception
|
||||
from heat.common import heat_keystoneclient as hkc
|
||||
from heat.common import template_format
|
||||
import heat.db.api as db_api
|
||||
from heat.engine.clients.os import keystone
|
||||
from heat.engine import resource
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import stack
|
||||
from heat.engine import template
|
||||
from heat.objects import stack as stack_object
|
||||
from heat.objects import user_creds as ucreds_object
|
||||
from heat.tests import common
|
||||
from heat.tests import fakes
|
||||
@ -50,12 +50,12 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_test', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -64,7 +64,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_test', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
self.assertIsNotNone(db_s.user_creds_id)
|
||||
user_creds_id = db_s.user_creds_id
|
||||
@ -73,11 +73,13 @@ class StackTest(common.HeatTestCase):
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
db_creds = ucreds_object.UserCreds.get_by_id(user_creds_id)
|
||||
self.assertIsNone(db_creds)
|
||||
del_db_s = db_api.stack_get(self.ctx, stack_id, show_deleted=True)
|
||||
del_db_s = stack_object.Stack.get_by_id(self.ctx,
|
||||
stack_id,
|
||||
show_deleted=True)
|
||||
self.assertIsNone(del_db_s.user_creds_id)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -92,7 +94,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_test', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
self.assertIsNotNone(db_s.user_creds_id)
|
||||
user_creds_id = db_s.user_creds_id
|
||||
@ -103,11 +105,13 @@ class StackTest(common.HeatTestCase):
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
db_creds = ucreds_object.UserCreds.get_by_id(user_creds_id)
|
||||
self.assertIsNone(db_creds)
|
||||
del_db_s = db_api.stack_get(self.ctx, stack_id, show_deleted=True)
|
||||
del_db_s = stack_object.Stack.get_by_id(self.ctx,
|
||||
stack_id,
|
||||
show_deleted=True)
|
||||
self.assertIsNone(del_db_s.user_creds_id)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -122,15 +126,16 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_test', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
self.assertIsNotNone(db_s.user_creds_id)
|
||||
exc = exception.Error('Cannot get user credentials')
|
||||
self.patchobject(db_api, 'user_creds_get').side_effect = exc
|
||||
self.patchobject(ucreds_object.UserCreds,
|
||||
'get_by_id').side_effect = exc
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -141,12 +146,12 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_trust', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -158,7 +163,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(trustor_ctx, 'delete_trust_nt', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
user_creds_id = db_s.user_creds_id
|
||||
@ -168,7 +173,7 @@ class StackTest(common.HeatTestCase):
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
db_s = db_api.stack_get(trustor_ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(trustor_ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -189,7 +194,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(trustor_ctx, 'delete_trust_nt', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
user_creds_id = db_s.user_creds_id
|
||||
@ -203,7 +208,7 @@ class StackTest(common.HeatTestCase):
|
||||
loaded_stack.delete()
|
||||
mock_sc.assert_called_with()
|
||||
|
||||
db_s = db_api.stack_get(other_ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(other_ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
loaded_stack.state)
|
||||
@ -219,12 +224,12 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_trust', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
self.stack.delete(backup=True)
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual(self.stack.state,
|
||||
(stack.Stack.DELETE, stack.Stack.COMPLETE))
|
||||
@ -241,7 +246,7 @@ class StackTest(common.HeatTestCase):
|
||||
owner_id='owner123')
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
user_creds_id = db_s.user_creds_id
|
||||
self.assertIsNotNone(user_creds_id)
|
||||
@ -250,7 +255,7 @@ class StackTest(common.HeatTestCase):
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
user_creds = ucreds_object.UserCreds.get_by_id(user_creds_id)
|
||||
self.assertIsNotNone(user_creds)
|
||||
@ -268,7 +273,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_trust', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
self.stack.delete()
|
||||
@ -276,7 +281,7 @@ class StackTest(common.HeatTestCase):
|
||||
mock_kcp.assert_called_with()
|
||||
self.assertEqual(2, mock_kcp.call_count)
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.FAILED),
|
||||
self.stack.state)
|
||||
@ -294,14 +299,14 @@ class StackTest(common.HeatTestCase):
|
||||
|
||||
self.stack.set_stack_user_project_id(project_id='aproject456')
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
self.stack.delete()
|
||||
|
||||
mock_kcp.assert_called_with()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -313,12 +318,12 @@ class StackTest(common.HeatTestCase):
|
||||
self.tmpl, disable_rollback=False)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
self.stack.delete(action=self.stack.ROLLBACK)
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.ROLLBACK, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
@ -327,12 +332,12 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_badaction_test', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
self.stack.delete(action="wibble")
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.FAILED),
|
||||
self.stack.state)
|
||||
@ -341,7 +346,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.stack = stack.Stack(self.ctx, 'delete_test', self.tmpl)
|
||||
stack_id = self.stack.store()
|
||||
|
||||
db_s = db_api.stack_get(self.ctx, stack_id)
|
||||
db_s = stack_object.Stack.get_by_id(self.ctx, stack_id)
|
||||
self.assertIsNotNone(db_s)
|
||||
|
||||
def dummy_task():
|
||||
@ -406,7 +411,7 @@ class StackTest(common.HeatTestCase):
|
||||
stack_user_project_id='aproject1234')
|
||||
self.stack.store()
|
||||
self.assertEqual('aproject1234', self.stack.stack_user_project_id)
|
||||
db_stack = db_api.stack_get(self.ctx, self.stack.id)
|
||||
db_stack = stack_object.Stack.get_by_id(self.ctx, self.stack.id)
|
||||
self.assertEqual('aproject1234', db_stack.stack_user_project_id)
|
||||
|
||||
self.stack.delete()
|
||||
|
Loading…
Reference in New Issue
Block a user