Skip to content

Commit

Permalink
Merge pull request #3190 from david-caro/dont_autoreject_autoapproved…
Browse files Browse the repository at this point in the history
…_workflows
  • Loading branch information
david-caro committed Feb 15, 2018
2 parents 806e6a7 + 09f03ee commit 9ccc342
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
7 changes: 7 additions & 0 deletions inspirehep/modules/workflows/tasks/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ def _is_auto_rejected(workflow_obj):
return decision.lower() == 'rejected' and len(core_keywords) == 0


def _is_auto_approved(workflow_obj):
return workflow_obj.extra_data.get('auto-approved', False)


@with_debug_logging
def is_record_relevant(obj, eng):
"""Shall we halt this workflow for potential acceptance or just reject?"""
Expand All @@ -186,6 +190,9 @@ def is_record_relevant(obj, eng):
if is_submission(obj, eng):
return True

if _is_auto_approved(workflow_obj=obj):
return True

if _is_auto_rejected(workflow_obj=obj):
return False

Expand Down
30 changes: 21 additions & 9 deletions tests/unit/workflows/test_workflows_tasks_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,29 +390,41 @@ def test__is_auto_rejected(expected, obj):


@pytest.mark.parametrize(
'expected,should_submission,should_auto_reject',
'expected, should_submission, should_auto_reject, should_auto_approve',
[
(True, True, True),
(True, True, False),
(False, False, True),
(True, False, False),
(True, True, True, False),
(True, True, False, False),
(False, False, True, False),
(True, False, False, False),
(True, True, True, True),
(True, True, False, True),
(True, False, True, True),
(True, False, False, True),
],
ids=[
'Relevant: is submission and autorejected',
'Relevant: is submission and not autorejected',
'Not relevant: is not submission and autorejected',
'Relevant: is not submission and not autorejected',
'Relevant: non auto-approved is submission and autorejected',
'Relevant: non auto-approved is submission and not autorejected',
'Not relevant: non auto-approved is not submission and autorejected',
'Relevant: non auto-approved is not submission and not autorejected',
'Relevant: auto-approved is submission and autorejected',
'Relevant: auto-approved is submission and not autorejected',
'Relevant: auto-approved is not submission and autorejected',
'Relevant: auto-approved is not submission and not autorejected',
]
)
@patch('inspirehep.modules.workflows.tasks.actions.is_submission')
@patch('inspirehep.modules.workflows.tasks.actions._is_auto_rejected')
@patch('inspirehep.modules.workflows.tasks.actions._is_auto_approved')
def test_is_record_relevant(
_is_auto_approved_mock,
_is_auto_rejected_mock,
is_submission_mock,
expected,
should_submission,
should_auto_reject,
should_auto_approve,
):
_is_auto_approved_mock.return_value = should_auto_approve
_is_auto_rejected_mock.return_value = should_auto_reject
is_submission_mock.return_value = should_submission
obj = object()
Expand Down

0 comments on commit 9ccc342

Please sign in to comment.