Merge "replace assert statement with unittest.assertXXX"
This commit is contained in:
commit
1dd2b1f235
@ -391,7 +391,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||||||
|
|
||||||
result = self.controller.index(req, tenant_id=self.tenant)
|
result = self.controller.index(req, tenant_id=self.tenant)
|
||||||
self.assertNotIn('count', result)
|
self.assertNotIn('count', result)
|
||||||
assert not engine.count_stacks.called
|
self.assertFalse(engine.count_stacks.called)
|
||||||
|
|
||||||
def test_index_with_count_is_invalid(self, mock_enforce):
|
def test_index_with_count_is_invalid(self, mock_enforce):
|
||||||
self._mock_enforce_setup(mock_enforce, 'index', True)
|
self._mock_enforce_setup(mock_enforce, 'index', True)
|
||||||
|
@ -144,14 +144,14 @@ class SqlAlchemyTest(common.HeatTestCase):
|
|||||||
query = mock.Mock()
|
query = mock.Mock()
|
||||||
db_api._filter_and_page_query(self.ctx, query)
|
db_api._filter_and_page_query(self.ctx, query)
|
||||||
|
|
||||||
assert mock_paginate_query.called
|
self.assertTrue(mock_paginate_query.called)
|
||||||
|
|
||||||
@mock.patch.object(db_api, '_events_paginate_query')
|
@mock.patch.object(db_api, '_events_paginate_query')
|
||||||
def test_events_filter_and_page_query(self, mock_events_paginate_query):
|
def test_events_filter_and_page_query(self, mock_events_paginate_query):
|
||||||
query = mock.Mock()
|
query = mock.Mock()
|
||||||
db_api._events_filter_and_page_query(self.ctx, query)
|
db_api._events_filter_and_page_query(self.ctx, query)
|
||||||
|
|
||||||
assert mock_events_paginate_query.called
|
self.assertTrue(mock_events_paginate_query.called)
|
||||||
|
|
||||||
@mock.patch.object(db_api.db_filters, 'exact_filter')
|
@mock.patch.object(db_api.db_filters, 'exact_filter')
|
||||||
def test_filter_and_page_query_handles_no_filters(self, mock_db_filter):
|
def test_filter_and_page_query_handles_no_filters(self, mock_db_filter):
|
||||||
@ -174,7 +174,7 @@ class SqlAlchemyTest(common.HeatTestCase):
|
|||||||
filters = {'foo': 'bar'}
|
filters = {'foo': 'bar'}
|
||||||
db_api._filter_and_page_query(self.ctx, query, filters=filters)
|
db_api._filter_and_page_query(self.ctx, query, filters=filters)
|
||||||
|
|
||||||
assert mock_db_filter.called
|
self.assertTrue(mock_db_filter.called)
|
||||||
|
|
||||||
@mock.patch.object(db_api.db_filters, 'exact_filter')
|
@mock.patch.object(db_api.db_filters, 'exact_filter')
|
||||||
def test_events_filter_and_page_query_applies_filters(self,
|
def test_events_filter_and_page_query_applies_filters(self,
|
||||||
@ -183,7 +183,7 @@ class SqlAlchemyTest(common.HeatTestCase):
|
|||||||
filters = {'foo': 'bar'}
|
filters = {'foo': 'bar'}
|
||||||
db_api._events_filter_and_page_query(self.ctx, query, filters=filters)
|
db_api._events_filter_and_page_query(self.ctx, query, filters=filters)
|
||||||
|
|
||||||
assert mock_db_filter.called
|
self.assertTrue(mock_db_filter.called)
|
||||||
|
|
||||||
@mock.patch.object(db_api, '_paginate_query')
|
@mock.patch.object(db_api, '_paginate_query')
|
||||||
def test_filter_and_page_query_whitelists_sort_keys(self,
|
def test_filter_and_page_query_whitelists_sort_keys(self,
|
||||||
|
@ -168,7 +168,7 @@ class StackLockTest(common.HeatTestCase):
|
|||||||
stack_lock_object.StackLock.create.call_count)
|
stack_lock_object.StackLock.create.call_count)
|
||||||
raise exception.ActionInProgress
|
raise exception.ActionInProgress
|
||||||
self.assertRaises(exception.ActionInProgress, check_thread_lock)
|
self.assertRaises(exception.ActionInProgress, check_thread_lock)
|
||||||
assert not stack_lock_object.StackLock.release.called
|
self.assertFalse(stack_lock_object.StackLock.release.called)
|
||||||
|
|
||||||
def test_thread_lock_context_mgr_no_exception(self):
|
def test_thread_lock_context_mgr_no_exception(self):
|
||||||
stack_lock_object.StackLock.create = mock.Mock(return_value=None)
|
stack_lock_object.StackLock.create = mock.Mock(return_value=None)
|
||||||
@ -177,7 +177,7 @@ class StackLockTest(common.HeatTestCase):
|
|||||||
self.engine_id)
|
self.engine_id)
|
||||||
with slock.thread_lock():
|
with slock.thread_lock():
|
||||||
self.assertEqual(1, stack_lock_object.StackLock.create.call_count)
|
self.assertEqual(1, stack_lock_object.StackLock.create.call_count)
|
||||||
assert not stack_lock_object.StackLock.release.called
|
self.assertFalse(stack_lock_object.StackLock.release.called)
|
||||||
|
|
||||||
def test_try_thread_lock_context_mgr_exception(self):
|
def test_try_thread_lock_context_mgr_exception(self):
|
||||||
stack_lock_object.StackLock.create = mock.Mock(return_value=None)
|
stack_lock_object.StackLock.create = mock.Mock(return_value=None)
|
||||||
@ -200,7 +200,7 @@ class StackLockTest(common.HeatTestCase):
|
|||||||
self.engine_id)
|
self.engine_id)
|
||||||
with slock.try_thread_lock():
|
with slock.try_thread_lock():
|
||||||
self.assertEqual(1, stack_lock_object.StackLock.create.call_count)
|
self.assertEqual(1, stack_lock_object.StackLock.create.call_count)
|
||||||
assert not stack_lock_object.StackLock.release.called
|
self.assertFalse(stack_lock_object.StackLock.release.called)
|
||||||
|
|
||||||
def test_try_thread_lock_context_mgr_existing_lock(self):
|
def test_try_thread_lock_context_mgr_existing_lock(self):
|
||||||
stack_lock_object.StackLock.create = mock.Mock(return_value=1234)
|
stack_lock_object.StackLock.create = mock.Mock(return_value=1234)
|
||||||
@ -214,4 +214,4 @@ class StackLockTest(common.HeatTestCase):
|
|||||||
stack_lock_object.StackLock.create.call_count)
|
stack_lock_object.StackLock.create.call_count)
|
||||||
raise self.TestThreadLockException
|
raise self.TestThreadLockException
|
||||||
self.assertRaises(self.TestThreadLockException, check_thread_lock)
|
self.assertRaises(self.TestThreadLockException, check_thread_lock)
|
||||||
assert not stack_lock_object.StackLock.release.called
|
self.assertFalse(stack_lock_object.StackLock.release.called)
|
||||||
|
Loading…
Reference in New Issue
Block a user