'Test set worker for direct call (non rpc call).'

@mock.patch('cinder.db.worker_create', autospec=True)
@mock.patch('cinder.db.worker_get', autospec=True)
def test_set_worker_direct(self, mock_get, mock_create):

    mock_get.side_effect = exception.WorkerNotFound
    service_id = mock.sentinel.service_id
    service.Service.service_id = service_id
    mock_create.return_value = mock.Mock(service_id=service_id, status=mock.sentinel.status, deleted=False, cleaning=False)
    backup = Backup(_context=self.context, status=mock.sentinel.status, id=mock.sentinel.id)
    backup.set_worker()
    mock_get.assert_called_once_with(self.context, resource_type='Backup', resource_id=mock.sentinel.id)
    mock_create.assert_called_once_with(self.context, status=mock.sentinel.status, resource_type='Backup', resource_id=mock.sentinel.id, service_id=service_id)
    self.assertEqual(mock_create.return_value, backup.worker)
