Fix mock==1.1.0 break unit tests
assert_called_once() is not a valid mock assertion. Replace with assert mock.call_count == 1. Change-Id: Idb21807ee647d79b1b9792ebd0c1909f09b71706
This commit is contained in:
parent
786f216d4f
commit
80fbea0ccb
@ -1542,7 +1542,7 @@ class RBDConnectorTestCase(ConnectorTestCase):
|
||||
conffile='/etc/ceph/ceph.conf')
|
||||
|
||||
# Ensure correct calls to connect to cluster
|
||||
mock_rados.Rados.return_value.connect.assert_called_once()
|
||||
self.assertEqual(1, mock_rados.Rados.return_value.connect.call_count)
|
||||
mock_rados.Rados.return_value.open_ioctx.assert_called_once_with(
|
||||
encodeutils.safe_encode(self.pool))
|
||||
|
||||
@ -1565,7 +1565,7 @@ class RBDConnectorTestCase(ConnectorTestCase):
|
||||
device_info = rbd.connect_volume(self.connection_properties)
|
||||
rbd.disconnect_volume(self.connection_properties, device_info)
|
||||
|
||||
volume_close.assert_called_once()
|
||||
self.assertEqual(1, volume_close.call_count)
|
||||
|
||||
|
||||
class ScaleIOConnectorTestCase(ConnectorTestCase):
|
||||
|
@ -104,13 +104,13 @@ class RBDVolumeIOWrapperTestCase(base.TestCase):
|
||||
with mock.patch.object(linuxrbd, 'LOG') as mock_logger:
|
||||
self.mock_volume.image.flush = mock.Mock()
|
||||
self.mock_volume_wrapper.flush()
|
||||
self.mock_volume.image.flush.assert_called_once()
|
||||
self.assertEqual(1, self.mock_volume.image.flush.call_count)
|
||||
self.mock_volume.image.flush.reset_mock()
|
||||
# this should be caught and logged silently.
|
||||
self.mock_volume.image.flush.side_effect = AttributeError
|
||||
self.mock_volume_wrapper.flush()
|
||||
self.mock_volume.image.flush.assert_called_once()
|
||||
mock_logger.warning.assert_called_once()
|
||||
self.assertEqual(1, self.mock_volume.image.flush.call_count)
|
||||
self.assertEqual(1, mock_logger.warning.call_count)
|
||||
|
||||
def test_fileno(self):
|
||||
self.assertRaises(IOError, self.mock_volume_wrapper.fileno)
|
||||
|
Loading…
Reference in New Issue
Block a user