Skip to content

Commit

Permalink
test: new test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharis278 committed Sep 30, 2024
1 parent 576f04c commit 81a41c3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions edx_name_affirmation/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def idv_update_verified_name_task(self, attempt_id, user_id, name_affirmation_st
)
else:
# otherwise if there are no entries, we want to create one.
# TODO: There is an existing bug here where if a user has an existing verified name
# from proctoring and goes through idv again a new verified name is not created.
user = User.objects.get(id=user_id)
verified_name = VerifiedName.objects.create(
user=user,
Expand Down
32 changes: 32 additions & 0 deletions edx_name_affirmation/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,38 @@ def test_idv_does_not_update_verified_name_by_proctoring(self):
self.assertEqual(len(VerifiedName.objects.filter(platform_verification_attempt_id=self.idv_attempt_id)), 1)
self.assertEqual(len(VerifiedName.objects.filter(status=VerifiedNameStatus.SUBMITTED)), 1)

def test_idv_does_not_update_old_verification_types(self):
"""
The verfication_attempt_id field is no longer supported by edx-platform. These records should no be
updated by idv events.
"""
VerifiedName.objects.create(
user=self.user,
verified_name=self.verified_name,
profile_name=self.profile_name,
verification_attempt_id=123,
status=VerifiedNameStatus.APPROVED,
)
VerifiedName.objects.create(
user=self.user,
verified_name=self.verified_name,
profile_name=self.profile_name,
verification_attempt_id=456,
status=VerifiedNameStatus.SUBMITTED,
)

VerifiedName.objects.create(user=self.user, verified_name=self.verified_name, profile_name=self.profile_name)
self._handle_idv_event(IDV_ATTEMPT_CREATED, self.idv_attempt_id)
# new name linked
self.assertEqual(len(VerifiedName.objects.filter(
status=VerifiedNameStatus.PENDING,
platform_verification_attempt_id=self.idv_attempt_id,
)), 1)

# old records remain untouched
self.assertEqual(len(VerifiedName.objects.filter(status=VerifiedNameStatus.SUBMITTED)), 1)
self.assertEqual(len(VerifiedName.objects.filter(status=VerifiedNameStatus.APPROVED)), 1)

@ddt.data(
(IDV_ATTEMPT_CREATED, VerifiedNameStatus.PENDING),
(IDV_ATTEMPT_PENDING, VerifiedNameStatus.SUBMITTED),
Expand Down

0 comments on commit 81a41c3

Please sign in to comment.