Fix use of invalid assert calls

assert_called_once and assert_called are not part of the mock
API; rework assertions to perform the same validation using
appropriate methods.

Change-Id: I8212a8d6aea4d4db1d0441088828a6602e6c0957
This commit is contained in:
James Page 2016-05-19 12:05:33 +01:00
parent fe8a119e8d
commit 942eca9362
2 changed files with 4 additions and 4 deletions

View File

@ -171,7 +171,7 @@ class ServiceTestCase(test.NoDBTestCase):
serv.start()
# test service version got updated and saved:
service_obj.save.assert_called_once()
self.assertEqual(1, service_obj.save.call_count)
self.assertEqual(objects.service.SERVICE_VERSION, service_obj.version)
def _test_service_check_create_race(self, ex):

View File

@ -15240,7 +15240,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
# cache() should have been called on the 3 disk backends
for backend in (mock_backend.kernel, mock_backend.ramdisk,
mock_backend.root):
backend.cache.assert_called()
self.assertTrue(backend.cache.called)
@mock.patch.object(libvirt_utils, 'get_instance_path')
@mock.patch.object(libvirt_utils, 'load_file')
@ -15362,10 +15362,10 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
# cache() should habe been called on the 3 non-config disk backends
for backend in (mock_backend.kernel, mock_backend.ramdisk,
mock_backend.root):
backend.cache.assert_called()
self.assertTrue(backend.cache.called)
# import_file() should have been called for the config disk
mock_backend.config.import_file.assert_called()
self.assertTrue(mock_backend.config.import_file.called)
@mock.patch('shutil.rmtree')
@mock.patch('nova.utils.execute')