Skip to content

Commit

Permalink
chore: Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rijuma committed Sep 4, 2024
1 parent 5d3ff14 commit 84c4d10
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions edx_name_affirmation/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,16 @@ def setUp(self):
)
return super().setUp()

@patch('edx_name_affirmation.models.SoftwareSecurePhotoVerification')
def test_histories(self, sspv_mock):
def test_histories(self):
"""
Test the model history is recording records as expected
"""
idv_attempt_id = 34455
idv_attempt_status = 'submitted'

sspv_mock.objects.get = lambda id: \
_obj({'status': idv_attempt_status}) if id == idv_attempt_id \
else _obj({'status': None})

verified_name_history = self.verified_name.history.all().order_by('history_date')
assert len(verified_name_history) == 1
self.verified_name.status = VerifiedNameStatus.APPROVED
self.verified_name.verification_attempt_id = idv_attempt_id

assert self.verified_name.verification_attempt_status is idv_attempt_status
self.verified_name.save()
verified_name_history = self.verified_name.history.all().order_by('history_date')
assert len(verified_name_history) == 2
Expand All @@ -61,3 +53,21 @@ def test_histories(self, sspv_mock):
second_history_record = verified_name_history[1]
assert second_history_record.status == VerifiedNameStatus.APPROVED
assert second_history_record.verification_attempt_id == idv_attempt_id

@patch('edx_name_affirmation.models.SoftwareSecurePhotoVerification')
def test_verification_status(self, sspv_mock):
"""
Test the model history is recording records as expected
"""
idv_attempt_id = 34455
idv_attempt_status = 'submitted'

sspv_mock.objects.get = lambda id: \
_obj({'status': idv_attempt_status}) if id == idv_attempt_id \
else _obj({'status': None})

self.verified_name.verification_attempt_id = 12345
assert self.verified_name.verification_attempt_status is None

self.verified_name.verification_attempt_id = idv_attempt_id
assert self.verified_name.verification_attempt_status is idv_attempt_status

0 comments on commit 84c4d10

Please sign in to comment.