def test_acquire_lock_no_pipeline(self): task_id = 1 user_id = 1 limit = 1 timeout = 100 acquire_lock(task_id, user_id, limit, timeout) assert has_lock(task_id, user_id, limit)
def test_get_task_id_and_duration_for_project_user_missing(self): user = UserFactory.create() project = ProjectFactory.create(owner=user, short_name='egil', name='egil', description='egil') task = TaskFactory.create_batch(1, project=project, n_answers=1)[0] limit = 1 timeout = 100 acquire_lock(task.id, user.id, limit, timeout) task_id, _ = get_task_id_and_duration_for_project_user(project.id, user.id) assert get_task_id_project_id_key(task.id) in sentinel.master.keys() assert task.id == task_id
def test_lock_expiration(self): owner = UserFactory.create(id=500) project = ProjectFactory.create(owner=owner) project.info['sched'] = 'locked' project_repo.save(project) task1 = TaskFactory.create(project=project, info='task 1', n_answers=2) task1 = TaskFactory.create(project=project, info='task 2', n_answers=2) res = self.app.get('api/project/{}/newtask?api_key={}'.format( project.id, owner.api_key)) # fake expired user lock acquire_lock(task1.id, 1000, 2, -10) res = self.app.get('api/project/{}/newtask'.format(project.id)) rec_task1 = json.loads(res.data) assert rec_task1['info'] == 'task 1'