'Test detach_all_attachments with exceptions.'

def test_detach_all_attachments_handles_exceptions(self):

    mock_log = self.mock_object(manager, 'LOG')
    self.volume_mocks['detach_volume'].side_effect = [Exception]
    fake_attachments = [{'id': str(uuid.uuid4()), 'attached_host': 'testhost', 'instance_uuid': None}, {'id': str(uuid.uuid4()), 'attached_host': 'testhost', 'instance_uuid': None}]
    fake_volume = {'id': str(uuid.uuid4()), 'volume_attachment': fake_attachments}
    self.backup_mgr._detach_all_attachments(self.ctxt, fake_volume)
    self.assertEqual(len(fake_attachments), mock_log.exception.call_count)
