'Test we don\'t have race condition if worker changes after get.'

@mock.patch('cinder.db.worker_update', autospec=True)
@mock.patch('cinder.db.worker_get', autospec=True)
def test_set_worker_claim_fail_after_get(self, mock_get, mock_update):

    service.Service.service_id = mock.sentinel.service_id
    worker = mock.Mock(service_id=mock.sentinel.service_id2, status=mock.sentinel.status, deleted=False, cleaning=False)
    mock_get.return_value = worker
    mock_update.side_effect = exception.WorkerNotFound
    backup = Backup(_context=self.context, status=mock.sentinel.status, id=mock.sentinel.id)
    self.assertRaises(exception.CleanableInUse, backup.set_worker)
    self.assertTrue(mock_get.called)
    self.assertTrue(mock_update.called)
