diff --git a/edx_name_affirmation/tests/test_views.py b/edx_name_affirmation/tests/test_views.py index af74c2d..14dd1dc 100644 --- a/edx_name_affirmation/tests/test_views.py +++ b/edx_name_affirmation/tests/test_views.py @@ -8,7 +8,6 @@ from django.contrib.auth import get_user_model from django.core.cache import cache from django.urls import reverse -from functools import partial from edx_name_affirmation.api import ( create_verified_name, @@ -38,7 +37,6 @@ def setUp(self): # Create fresh configs with default values VerifiedNameConfig.objects.create(user=self.user) VerifiedNameConfig.objects.create(user=self.other_user) - self.json_post = partial(self.client.post, content_type="application/json") def tearDown(self): super().tearDown() @@ -116,9 +114,8 @@ def test_post_200(self): 'profile_name': self.PROFILE_NAME, 'verified_name': self.VERIFIED_NAME, 'verification_attempt_id': self.ATTEMPT_ID, - 'verification_attempt_status': None, } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name'), verified_name_data ) @@ -139,13 +136,11 @@ def test_post_200_if_staff(self): 'profile_name': self.PROFILE_NAME, 'verified_name': self.VERIFIED_NAME, 'proctored_exam_attempt_id': self.ATTEMPT_ID, - 'verification_attempt_status': None, 'status': VerifiedNameStatus.APPROVED.value, } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name'), - verified_name_data, - content_type='json' + verified_name_data ) self.assertEqual(response.status_code, 200) @@ -161,10 +156,9 @@ def test_post_403_non_staff(self): 'profile_name': self.PROFILE_NAME, 'verified_name': self.VERIFIED_NAME, 'verification_attempt_id': self.ATTEMPT_ID, - 'verification_attempt_status': None, 'status': VerifiedNameStatus.APPROVED.value, } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name'), verified_name_data ) @@ -177,10 +171,9 @@ def test_post_400_invalid_name(self, verified_name): 'profile_name': self.PROFILE_NAME, 'verified_name': verified_name, 'verification_attempt_id': self.ATTEMPT_ID, - 'verification_attempt_status': None, 'status': VerifiedNameStatus.SUBMITTED.value, } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name'), verified_name_data ) @@ -192,10 +185,9 @@ def test_post_400_invalid_serializer(self): 'profile_name': self.PROFILE_NAME, 'verified_name': self.VERIFIED_NAME, 'verification_attempt_id': 'xxyz', - 'verification_attempt_status': None, 'status': VerifiedNameStatus.APPROVED.value, } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name'), verified_name_data ) @@ -209,7 +201,7 @@ def test_post_400_two_attempt_ids(self): 'verification_attempt_id': self.ATTEMPT_ID, 'proctored_exam_attempt_id': self.ATTEMPT_ID } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name'), verified_name_data ) @@ -365,7 +357,6 @@ def _get_expected_data( 'verified_name': verified_name_obj.verified_name, 'profile_name': verified_name_obj.profile_name, 'verification_attempt_id': verified_name_obj.verification_attempt_id, - 'verification_attempt_status': None, 'proctored_exam_attempt_id': verified_name_obj.proctored_exam_attempt_id, 'status': verified_name_obj.status, 'use_verified_name_for_certs': use_verified_name_for_certs, @@ -465,6 +456,7 @@ def _get_expected_response( 'verified_name': verified_name_obj.verified_name, 'profile_name': verified_name_obj.profile_name, 'verification_attempt_id': verified_name_obj.verification_attempt_id, + 'verification_attempt_status': None, 'proctored_exam_attempt_id': verified_name_obj.proctored_exam_attempt_id, 'status': verified_name_obj.status } @@ -483,7 +475,7 @@ def test_post_201(self): 'username': self.user.username, 'use_verified_name_for_certs': True } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name_config'), config_data ) @@ -499,11 +491,11 @@ def test_post_201_missing_field(self): } config_data_missing_field = {'username': self.user.username} - first_response = self.json_post( + first_response = self.client.post( reverse('edx_name_affirmation:verified_name_config'), initial_config_data ) - second_response = self.json_post( + second_response = self.client.post( reverse('edx_name_affirmation:verified_name_config'), config_data_missing_field ) @@ -523,7 +515,7 @@ def test_post_201_if_staff(self): 'username': self.other_user.username, 'use_verified_name_for_certs': True } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name_config'), config_data ) @@ -537,7 +529,7 @@ def test_post_403_non_staff(self): 'username': self.other_user.username, 'use_verified_name_for_certs': True } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name_config'), config_data ) @@ -548,7 +540,7 @@ def test_post_400_invalid_serializer(self): 'username': self.user.username, 'use_verified_name_for_certs': 'not a boolean' } - response = self.json_post( + response = self.client.post( reverse('edx_name_affirmation:verified_name_config'), config_data )