Skip to content

Commit

Permalink
Merge pull request #79 from edx/alangsto/account_for_error_status
Browse files Browse the repository at this point in the history
fix: allow error status updates to trigger verified name updates
  • Loading branch information
alangsto authored Feb 23, 2022
2 parents 2af8239 + 7791ad6 commit 6e416cb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Change Log
Unreleased
~~~~~~~~~~

[2.2.1] - 2022-02-23
~~~~~~~~~~~~~~~~~~~~
* Update verified name status to `denied` if proctoring `error` status is received

[2.2.0] - 2022-02-14
~~~~~~~~~~~~~~~~~~~~
* Added Django40 testing and dropped Django22, 30 and 31 support
Expand Down
2 changes: 1 addition & 1 deletion edx_name_affirmation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Django app housing name affirmation logic.
"""

__version__ = '2.2.0'
__version__ = '2.2.1'

default_app_config = 'edx_name_affirmation.apps.EdxNameAffirmationConfig' # pylint: disable=invalid-name
3 changes: 2 additions & 1 deletion edx_name_affirmation/statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def trigger_state_change_from_proctoring(cls, proctoring_status):
'created': cls.PENDING,
'submitted': cls.SUBMITTED,
'verified': cls.APPROVED,
'rejected': cls.DENIED
'rejected': cls.DENIED,
'error': cls.DENIED,
}

return proctoring_state_transition_mapping.get(proctoring_status, None)
47 changes: 45 additions & 2 deletions edx_name_affirmation/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ class ProctoringSignalTests(SignalTestCase):
('created', VerifiedNameStatus.PENDING),
('submitted', VerifiedNameStatus.SUBMITTED),
('verified', VerifiedNameStatus.APPROVED),
('rejected', VerifiedNameStatus.DENIED)
('rejected', VerifiedNameStatus.DENIED),
('error', VerifiedNameStatus.DENIED),
)
@ddt.unpack
def test_proctoring_update_status_for_attempt_id(self, proctoring_status, expected_status):
Expand Down Expand Up @@ -259,6 +260,49 @@ def test_proctoring_update_status_for_attempt_id(self, proctoring_status, expect
verified_name = verified_name_query.first()
self.assertEqual(verified_name.status, expected_status)

@ddt.data(
('verified', VerifiedNameStatus.APPROVED),
('rejected', VerifiedNameStatus.DENIED),
)
@ddt.unpack
def test_proctoring_error_update_status(self, proctoring_status, expected_status):
"""
If we receive a proctoring update with an error status, ensure that later status updates are handled as expected
"""

proctoring_attempt_handler(
self.proctoring_attempt_id,
self.user.id,
'error',
self.verified_name,
self.profile_name,
True,
True,
True
)

verified_name = VerifiedName.objects.get(proctored_exam_attempt_id=self.proctoring_attempt_id)
object_id = verified_name.id
self.assertEqual(verified_name.status, VerifiedNameStatus.DENIED)

# update status
proctoring_attempt_handler(
self.proctoring_attempt_id,
self.user.id,
proctoring_status,
self.verified_name,
self.profile_name,
True,
True,
True
)

# ensure that status is updated for subsequent updates
verified_name_query = VerifiedName.objects.filter(id=object_id)
self.assertEqual(len(verified_name_query), 1)
verified_name = verified_name_query.first()
self.assertEqual(verified_name.status, expected_status)

def test_proctoring_create_verified_name(self):
"""
Test that if no verified name exists for the name or attempt id, create one
Expand Down Expand Up @@ -373,7 +417,6 @@ def test_proctoring_log_with_existing_approved_verified_name(self, should_names_
'ready_to_start',
'started',
'ready_to_submit',
'error',
)
@patch('edx_name_affirmation.tasks.proctoring_update_verified_name_task.delay')
def test_proctoring_non_trigger_status(self, status, mock_task):
Expand Down

0 comments on commit 6e416cb

Please sign in to comment.