From 81a41c31815d31fa458ffdbef71245f906f4b493 Mon Sep 17 00:00:00 2001 From: Zacharis278 Date: Mon, 30 Sep 2024 10:11:24 -0400 Subject: [PATCH] test: new test case --- edx_name_affirmation/tasks.py | 2 ++ edx_name_affirmation/tests/test_handlers.py | 32 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/edx_name_affirmation/tasks.py b/edx_name_affirmation/tasks.py index f6b8b46..e91c2af 100644 --- a/edx_name_affirmation/tasks.py +++ b/edx_name_affirmation/tasks.py @@ -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, diff --git a/edx_name_affirmation/tests/test_handlers.py b/edx_name_affirmation/tests/test_handlers.py index 70bdb54..678d409 100644 --- a/edx_name_affirmation/tests/test_handlers.py +++ b/edx_name_affirmation/tests/test_handlers.py @@ -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),