Fix calls to mock.assert_not_called()

There is no assert_not_called() method in mock, as described here:

https://code.google.com/p/mock/issues/detail?id=159

Fix these calls to use the mock.called attribute instead.

Closes-Bug: #1316167

Change-Id: I865463244ebfc45e1f940c74e1afbb9084930bb3
This commit is contained in:
Matt Riedemann 2014-05-04 19:05:44 -07:00
parent 89fd077042
commit 92d92c7fe1
4 changed files with 16 additions and 14 deletions

View File

@ -392,7 +392,7 @@ class TestCollectionLinks(test.NoDBTestCase):
builder = common.ViewBuilder()
results = builder._get_collection_links(req, items, "ignored", "uuid")
href_link_mock.assert_not_called()
self.assertFalse(href_link_mock.called)
self.assertThat(results, matchers.HasLength(0))
@mock.patch('nova.api.openstack.common.ViewBuilder._get_next_link')

View File

@ -761,7 +761,8 @@ class ComputeUtilsPeriodicTaskSpacingWarning(test.NoDBTestCase):
return "something"
self.assertEqual("something", not_a_periodic_task())
mock_log.warning.assert_not_called()
self.assertFalse(mock_log.warning.called)
self.assertFalse(mock_log.warn.called)
@mock.patch.object(compute_utils, 'LOG')
def test_periodic_task_spacing_warning_nonzero_spacing(self, mock_log):
@ -772,7 +773,8 @@ class ComputeUtilsPeriodicTaskSpacingWarning(test.NoDBTestCase):
return "something"
self.assertEqual("something", a_periodic_task())
mock_log.warning.assert_not_called()
self.assertFalse(mock_log.warning.called)
self.assertFalse(mock_log.warn.called)
@mock.patch.object(compute_utils, 'LOG')
def test_periodic_task_spacing_warning_zero_spacing(self, mock_log):

View File

@ -545,7 +545,7 @@ class TestIsImageAvailable(test.NoDBTestCase):
res = glance._is_image_available(ctx, img)
self.assertTrue(res)
img.assert_not_called()
self.assertFalse(img.called)
def test_admin_override(self):
ctx = mock.MagicMock(auth_token=False, is_admin=True)
@ -553,7 +553,7 @@ class TestIsImageAvailable(test.NoDBTestCase):
res = glance._is_image_available(ctx, img)
self.assertTrue(res)
img.assert_not_called()
self.assertFalse(img.called)
def test_v2_visibility(self):
ctx = mock.MagicMock(auth_token=False, is_admin=False)
@ -687,7 +687,7 @@ class TestShow(test.NoDBTestCase):
client.call.assert_called_once_with(ctx, 1, 'get',
mock.sentinel.image_id)
is_avail_mock.assert_called_once_with(ctx, mock.sentinel.images_0)
trans_from_mock.assert_not_called()
self.assertFalse(trans_from_mock.called)
@mock.patch('nova.image.glance._reraise_translated_image_exception')
@mock.patch('nova.image.glance._translate_from_glance')
@ -705,8 +705,8 @@ class TestShow(test.NoDBTestCase):
service.show(ctx, mock.sentinel.image_id)
client.call.assert_called_once_with(ctx, 1, 'get',
mock.sentinel.image_id)
is_avail_mock.assert_not_called()
trans_from_mock.assert_not_called()
self.assertFalse(is_avail_mock.called)
self.assertFalse(trans_from_mock.called)
reraise_mock.assert_called_once_with(mock.sentinel.image_id)
@ -751,7 +751,7 @@ class TestDetail(test.NoDBTestCase):
client.call.assert_called_once_with(ctx, 1, 'list')
is_avail_mock.assert_called_once_with(ctx, mock.sentinel.images_0)
trans_from_mock.assert_not_called()
self.assertFalse(trans_from_mock.called)
self.assertEqual([], images)
@mock.patch('nova.image.glance._extract_query_params')
@ -788,8 +788,8 @@ class TestDetail(test.NoDBTestCase):
service.detail(ctx, **params)
client.call.assert_called_once_with(ctx, 1, 'list')
is_avail_mock.assert_not_called()
trans_from_mock.assert_not_called()
self.assertFalse(is_avail_mock.called)
self.assertFalse(trans_from_mock.called)
reraise_mock.assert_called_once_with()
@ -845,7 +845,7 @@ class TestCreate(test.NoDBTestCase):
self.assertRaises(exception.Invalid, service.create, ctx, image_mock)
trans_to_mock.assert_called_once_with(image_mock)
trans_from_mock.assert_not_called()
self.assertFalse(trans_from_mock.called)
class TestUpdate(test.NoDBTestCase):
@ -917,7 +917,7 @@ class TestUpdate(test.NoDBTestCase):
mock.sentinel.image_id,
purge_props=True,
name=mock.sentinel.name)
trans_from_mock.assert_not_called()
self.assertFalse(trans_from_mock.called)
reraise_mock.assert_called_once_with(mock.sentinel.image_id)

View File

@ -336,7 +336,7 @@ class WorkOnDiskTestCase(test.NoDBTestCase):
self.dev, self.root_mb, self.swap_mb,
self.ephemeral_mb, self.image_path, False)
self.m_ibd.assert_called_once_with(self.dev)
self.m_mp.assert_not_called()
self.assertFalse(self.m_mp.called)
def test_no_root_partition(self):
self.m_ibd.side_effect = [True, False]