Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dchhabda committed Feb 23, 2023
1 parent b302f84 commit fa73eab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pybossa/view/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def handle_valid_form(form):
project.kpi = project.info.get('kpi')
project.input_data_class = project.info.get('data_classification', {}).get('input_data')
project.output_data_class = project.info.get('data_classification', {}).get('output_data')
project.allow_taskrun_edit = project.info.get("allow_taskrun_edit") or False
project.allow_taskrun_edit = project.info.get("allow_taskrun_edit", False)
ensure_amp_config_applied_to_project(project, project.info.get('annotation_config', {}))
form = dynamic_project_form(ProjectUpdateForm, None, data_access_levels, obj=project,
products=prodsubprods, data_classes=data_classes)
Expand Down
30 changes: 30 additions & 0 deletions test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -3461,6 +3461,36 @@ def test_task_presenter_with_allow_taskrun_edit_raises_forbidden(self):
res = self.app.get('/project/%s/task/%s' % (project_short_name, task.id))
assert res.status_code == 403, res.status_code

@with_context
def test_task_presenter_with_allow_taskrun_edit_allows_submission(self):
"""Test WEB with taskrun edit is permitted with task_submitter_id passed"""
self.register()
self.signin()
self.create()
project = db.session.query(Project).get(1)
project.info = dict(allow_taskrun_edit=True)
db.session.commit()
self.new_task(project.id)
project_short_name = project.short_name

task = db.session.query(Task).filter(Task.project_id == 1).first()
# user = db.session.query(User).first()
regular_user = UserFactory.create(id=999, subadmin=False, admin=False)
regular_user.set_password('1234')
user_repo.save(regular_user)
self.signin(email=regular_user.email_addr, password='1234')
task_run = TaskRun(project_id=project.id, task_id=task.id,
info={'answer': 1,
'odfoa': {'version': 1, 'source-uri': 'http://fake.com', 'odf': {}, 'oa': {}},
'fake': {'b': 27}},
user_id=regular_user.id)
db.session.add(task_run)
db.session.commit()

# task_submitter_id is passed to fetch task response recorded by the user
res = self.app.get('/project/%s/task/%s/%s?mode=edit_submission' % (project_short_name, task.id, regular_user.id))
assert res.status_code == 200, res.status_code

@with_context
@patch('pybossa.view.projects.uploader.upload_file', return_value=True)
def test_25_get_wrong_task_app(self, mock):
Expand Down

0 comments on commit fa73eab

Please sign in to comment.