-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IDV Status to VerifiedName #215
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
15ff78c
feat: Adding IDV Status to VerifiedName
rijuma 86d6ddf
fix: Moved attempt status getter from Serialized to Model
rijuma 839fcc0
fix: Reverted Views unit tests
rijuma 734a867
fix: Updated tests
rijuma 1067184
chore: Added proper tests to model
rijuma 8bcfee5
fix: Added catch to not found exception
rijuma 8d568b2
chore: Updated tests
rijuma d54fa93
fix: Updated tests
rijuma b8069b7
chore: Moved test variables to be more localized
rijuma cc9d116
chore: Moved test variables to be more localized
rijuma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
""" | ||
Tests for Name Affirmation models | ||
""" | ||
from unittest.mock import patch | ||
|
||
from django.contrib.auth import get_user_model | ||
from django.core.exceptions import ObjectDoesNotExist | ||
from django.test import TestCase | ||
|
||
from edx_name_affirmation.models import VerifiedName | ||
|
@@ -16,6 +18,9 @@ | |
Test suite for the VerifiedName models | ||
""" | ||
def setUp(self): | ||
self.idv_attempt_id = 34455 | ||
self.idv_attempt_status = 'submitted' | ||
self.idv_attempt_id_notfound = 404 | ||
self.verified_name = 'Test Tester' | ||
self.user = User.objects.create(username='modelTester', email='[email protected]') | ||
self.verified_name = VerifiedName.objects.create( | ||
|
@@ -29,11 +34,11 @@ | |
""" | ||
Test the model history is recording records as expected | ||
""" | ||
|
||
verified_name_history = self.verified_name.history.all().order_by('history_date') | ||
assert len(verified_name_history) == 1 | ||
idv_attempt_id = 34455 | ||
self.verified_name.status = VerifiedNameStatus.APPROVED | ||
self.verified_name.verification_attempt_id = idv_attempt_id | ||
self.verified_name.verification_attempt_id = self.idv_attempt_id | ||
self.verified_name.save() | ||
verified_name_history = self.verified_name.history.all().order_by('history_date') | ||
assert len(verified_name_history) == 2 | ||
|
@@ -44,4 +49,37 @@ | |
|
||
second_history_record = verified_name_history[1] | ||
assert second_history_record.status == VerifiedNameStatus.APPROVED | ||
assert second_history_record.verification_attempt_id == idv_attempt_id | ||
assert second_history_record.verification_attempt_id == self.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_notfound_status = None | ||
|
||
sspv_mock.objects.get = self._mocked_model_get | ||
|
||
self.verified_name.verification_attempt_id = self.idv_attempt_id_notfound | ||
assert self.verified_name.verification_attempt_status is idv_attempt_id_notfound_status | ||
|
||
self.verified_name.verification_attempt_id = self.idv_attempt_id | ||
assert self.verified_name.verification_attempt_status is self.idv_attempt_status | ||
|
||
# Helper methods | ||
|
||
def _obj(self, dictionary): | ||
"Helper method to turn a dict into an object. Used to mock below." | ||
|
||
return type('obj', (object,), dictionary) | ||
|
||
def _mocked_model_get(self, id): # pylint: disable=redefined-builtin | ||
"Helper method to mock the behavior of SoftwareSecurePhotoVerification model. Used to mock below." | ||
if id == self.idv_attempt_id_notfound: | ||
raise ObjectDoesNotExist | ||
|
||
if id == self.idv_attempt_id: | ||
return self._obj({'status': self.idv_attempt_status}) | ||
|
||
return self._obj({'status': None}) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can omit the
Missing coverage
warning since this is just a mock for testing. I'm not sure why is this a thing on a test file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. I think it's fine to ignore!