Merge "Test: use assert_has_calls() instead"

This commit is contained in:
Jenkins 2016-04-17 14:38:00 +00:00 committed by Gerrit Code Review
commit 78ad6fbde1

View File

@ -1543,12 +1543,13 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
rpc_init.assert_called_once_with(CONF) rpc_init.assert_called_once_with(CONF)
last_completed_audit_period.assert_called_once_with() last_completed_audit_period.assert_called_once_with()
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end) volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
notify_about_volume_usage.assert_any_call(ctxt, volume1, 'exists', notify_about_volume_usage.assert_has_calls([
extra_usage_info=extra_info) mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
notify_about_volume_usage.assert_any_call( mock.call(ctxt, volume1, 'create.start',
ctxt, volume1, 'create.start', extra_usage_info=local_extra_info) extra_usage_info=local_extra_info),
notify_about_volume_usage.assert_any_call( mock.call(ctxt, volume1, 'create.end',
ctxt, volume1, 'create.end', extra_usage_info=local_extra_info) extra_usage_info=local_extra_info)
])
@mock.patch('cinder.volume.utils.notify_about_volume_usage') @mock.patch('cinder.volume.utils.notify_about_volume_usage')
@mock.patch('cinder.db.volume_get_active_by_window') @mock.patch('cinder.db.volume_get_active_by_window')
@ -1609,20 +1610,17 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
rpc_init.assert_called_once_with(CONF) rpc_init.assert_called_once_with(CONF)
last_completed_audit_period.assert_called_once_with() last_completed_audit_period.assert_called_once_with()
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end) volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
notify_about_volume_usage.assert_any_call( notify_about_volume_usage.assert_has_calls([
ctxt, volume1, 'exists', extra_usage_info=extra_info) mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
notify_about_volume_usage.assert_any_call( mock.call(ctxt, volume1, 'create.start',
ctxt, volume1, 'create.start', extra_usage_info=local_extra_info_create),
extra_usage_info=local_extra_info_create) mock.call(ctxt, volume1, 'create.end',
notify_about_volume_usage.assert_any_call( extra_usage_info=local_extra_info_create),
ctxt, volume1, 'create.end', mock.call(ctxt, volume1, 'delete.start',
extra_usage_info=local_extra_info_create) extra_usage_info=local_extra_info_delete),
notify_about_volume_usage.assert_any_call( mock.call(ctxt, volume1, 'delete.end',
ctxt, volume1, 'delete.start', extra_usage_info=local_extra_info_delete)
extra_usage_info=local_extra_info_delete) ])
notify_about_volume_usage.assert_any_call(
ctxt, volume1, 'delete.end',
extra_usage_info=local_extra_info_delete)
@mock.patch('cinder.volume.utils.notify_about_snapshot_usage') @mock.patch('cinder.volume.utils.notify_about_snapshot_usage')
@mock.patch('cinder.objects.snapshot.SnapshotList.get_active_by_window') @mock.patch('cinder.objects.snapshot.SnapshotList.get_active_by_window')
@ -1688,14 +1686,13 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
last_completed_audit_period.assert_called_once_with() last_completed_audit_period.assert_called_once_with()
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end) volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
self.assertFalse(notify_about_volume_usage.called) self.assertFalse(notify_about_volume_usage.called)
notify_about_snapshot_usage.assert_any_call(ctxt, snapshot1, 'exists', notify_about_snapshot_usage.assert_has_calls([
extra_info) mock.call(ctxt, snapshot1, 'exists', extra_info),
notify_about_snapshot_usage.assert_any_call( mock.call(ctxt, snapshot1, 'create.start',
ctxt, snapshot1, 'create.start', extra_usage_info=local_extra_info_create),
extra_usage_info=local_extra_info_create) mock.call(ctxt, snapshot1, 'delete.start',
notify_about_snapshot_usage.assert_any_call( extra_usage_info=local_extra_info_delete)
ctxt, snapshot1, 'delete.start', ])
extra_usage_info=local_extra_info_delete)
@mock.patch('cinder.volume.utils.notify_about_snapshot_usage') @mock.patch('cinder.volume.utils.notify_about_snapshot_usage')
@mock.patch('cinder.objects.snapshot.SnapshotList.get_active_by_window') @mock.patch('cinder.objects.snapshot.SnapshotList.get_active_by_window')
@ -1764,32 +1761,26 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
rpc_init.assert_called_once_with(CONF) rpc_init.assert_called_once_with(CONF)
last_completed_audit_period.assert_called_once_with() last_completed_audit_period.assert_called_once_with()
volume_get_active_by_window.assert_called_once_with(ctxt, begin, end) volume_get_active_by_window.assert_called_once_with(ctxt, begin, end)
notify_about_volume_usage.assert_any_call( notify_about_volume_usage.assert_has_calls([
ctxt, volume1, 'exists', extra_usage_info=extra_info) mock.call(ctxt, volume1, 'exists', extra_usage_info=extra_info),
notify_about_volume_usage.assert_any_call( mock.call(ctxt, volume1, 'create.start',
ctxt, volume1, 'create.start', extra_usage_info=extra_info_volume_create),
extra_usage_info=extra_info_volume_create) mock.call(ctxt, volume1, 'create.end',
notify_about_volume_usage.assert_any_call( extra_usage_info=extra_info_volume_create),
ctxt, volume1, 'create.end', mock.call(ctxt, volume1, 'delete.start',
extra_usage_info=extra_info_volume_create) extra_usage_info=extra_info_volume_delete),
notify_about_volume_usage.assert_any_call( mock.call(ctxt, volume1, 'delete.end',
ctxt, volume1, 'delete.start', extra_usage_info=extra_info_volume_delete)
extra_usage_info=extra_info_volume_delete) ])
notify_about_volume_usage.assert_any_call(
ctxt, volume1, 'delete.end',
extra_usage_info=extra_info_volume_delete)
notify_about_snapshot_usage.assert_any_call(ctxt, snapshot1, notify_about_snapshot_usage.assert_has_calls([
'exists', extra_info) mock.call(ctxt, snapshot1, 'exists', extra_info),
notify_about_snapshot_usage.assert_any_call( mock.call(ctxt, snapshot1, 'create.start',
ctxt, snapshot1, 'create.start', extra_usage_info=extra_info_snapshot_create),
extra_usage_info=extra_info_snapshot_create) mock.call(ctxt, snapshot1, 'create.end',
notify_about_snapshot_usage.assert_any_call( extra_usage_info=extra_info_snapshot_create),
ctxt, snapshot1, 'create.end', mock.call(ctxt, snapshot1, 'delete.start',
extra_usage_info=extra_info_snapshot_create) extra_usage_info=extra_info_snapshot_delete),
notify_about_snapshot_usage.assert_any_call( mock.call(ctxt, snapshot1, 'delete.end',
ctxt, snapshot1, 'delete.start', extra_usage_info=extra_info_snapshot_delete)
extra_usage_info=extra_info_snapshot_delete) ])
notify_about_snapshot_usage.assert_any_call(
ctxt, snapshot1, 'delete.end',
extra_usage_info=extra_info_snapshot_delete)