Merge "UnitTests: fix mock assertions usage"
This commit is contained in:
commit
2209dbbba7
@ -2987,12 +2987,10 @@ class ThreadGroupManagerTest(HeatTestCase):
|
|||||||
self.stlock_mock.StackLock.assert_called_with(self.cnxt,
|
self.stlock_mock.StackLock.assert_called_with(self.cnxt,
|
||||||
self.stack,
|
self.stack,
|
||||||
self.engine_id)
|
self.engine_id)
|
||||||
self.lock_mock.acquire.assert_called_once()
|
|
||||||
thm.start_with_acquired_lock.assert_called_once()
|
thm.start_with_acquired_lock.assert_called_once_with(
|
||||||
calls = thm.start_with_acquired_lock.call_args
|
self.stack, self.lock_mock,
|
||||||
self.assertEqual((self.stack, self.lock_mock, self.f) + self.fargs,
|
self.f, *self.fargs, **self.fkwargs)
|
||||||
calls[0])
|
|
||||||
self.assertEqual(self.fkwargs, calls[1])
|
|
||||||
|
|
||||||
def test_tgm_start(self):
|
def test_tgm_start(self):
|
||||||
stack_id = 'test'
|
stack_id = 'test'
|
||||||
|
@ -170,17 +170,17 @@ class StackLockTest(HeatTestCase):
|
|||||||
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
||||||
try:
|
try:
|
||||||
with slock.thread_lock(self.stack.id):
|
with slock.thread_lock(self.stack.id):
|
||||||
db_api.stack_lock_create.assert_called_once()
|
self.assertEqual(1, db_api.stack_lock_create.call_count)
|
||||||
raise Exception
|
raise Exception
|
||||||
except:
|
except:
|
||||||
db_api.stack_lock_release.assert_called_once()
|
self.assertEqual(1, db_api.stack_lock_release.call_count)
|
||||||
|
|
||||||
def test_thread_lock_context_mgr_no_exception(self):
|
def test_thread_lock_context_mgr_no_exception(self):
|
||||||
db_api.stack_lock_create = mock.Mock(return_value=None)
|
db_api.stack_lock_create = mock.Mock(return_value=None)
|
||||||
db_api.stack_lock_release = mock.Mock(return_value=None)
|
db_api.stack_lock_release = mock.Mock(return_value=None)
|
||||||
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
||||||
with slock.thread_lock(self.stack.id):
|
with slock.thread_lock(self.stack.id):
|
||||||
db_api.stack_lock_create.assert_called_once()
|
self.assertEqual(1, db_api.stack_lock_create.call_count)
|
||||||
assert not db_api.stack_lock_release.called
|
assert not db_api.stack_lock_release.called
|
||||||
|
|
||||||
def test_try_thread_lock_context_mgr_exception(self):
|
def test_try_thread_lock_context_mgr_exception(self):
|
||||||
@ -189,17 +189,17 @@ class StackLockTest(HeatTestCase):
|
|||||||
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
||||||
try:
|
try:
|
||||||
with slock.try_thread_lock(self.stack.id):
|
with slock.try_thread_lock(self.stack.id):
|
||||||
db_api.stack_lock_create.assert_called_once()
|
self.assertEqual(1, db_api.stack_lock_create.call_count)
|
||||||
raise Exception
|
raise Exception
|
||||||
except:
|
except:
|
||||||
db_api.stack_lock_release.assert_called_once()
|
self.assertEqual(1, db_api.stack_lock_release.call_count)
|
||||||
|
|
||||||
def test_try_thread_lock_context_mgr_no_exception(self):
|
def test_try_thread_lock_context_mgr_no_exception(self):
|
||||||
db_api.stack_lock_create = mock.Mock(return_value=None)
|
db_api.stack_lock_create = mock.Mock(return_value=None)
|
||||||
db_api.stack_lock_release = mock.Mock(return_value=None)
|
db_api.stack_lock_release = mock.Mock(return_value=None)
|
||||||
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
||||||
with slock.try_thread_lock(self.stack.id):
|
with slock.try_thread_lock(self.stack.id):
|
||||||
db_api.stack_lock_create.assert_called_once()
|
self.assertEqual(1, db_api.stack_lock_create.call_count)
|
||||||
assert not db_api.stack_lock_release.called
|
assert not db_api.stack_lock_release.called
|
||||||
|
|
||||||
def test_try_thread_lock_context_mgr_existing_lock(self):
|
def test_try_thread_lock_context_mgr_existing_lock(self):
|
||||||
@ -208,7 +208,7 @@ class StackLockTest(HeatTestCase):
|
|||||||
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
slock = stack_lock.StackLock(self.context, self.stack, self.engine_id)
|
||||||
try:
|
try:
|
||||||
with slock.try_thread_lock(self.stack.id):
|
with slock.try_thread_lock(self.stack.id):
|
||||||
db_api.stack_lock_create.assert_called_once()
|
self.assertEqual(1, db_api.stack_lock_create.call_count)
|
||||||
raise Exception
|
raise Exception
|
||||||
except:
|
except:
|
||||||
assert not db_api.stack_lock_release.called
|
assert not db_api.stack_lock_release.called
|
||||||
|
Loading…
Reference in New Issue
Block a user