Skip to content

Commit

Permalink
Test should not try to refresh token (#5382)
Browse files Browse the repository at this point in the history
* Test should not try to refresh token

* fixing the test
  • Loading branch information
annagav authored Apr 12, 2024
1 parent 0a68c3d commit 9889789
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions dashboard/views_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,17 @@ def test_exam_course_id_mandatory(self):
resp = self.client.post(self.url, {}, format='json')
assert resp.status_code == status.HTTP_400_BAD_REQUEST

def test_user_is_not_authorized(self):
@patch('backends.utils.refresh_user_token', autospec=True)
@patch('dashboard.views.ExamAuthorization.objects', autospec=True)
def test_user_is_not_authorized(self, mock_exam_auth, mock_refresh):
"""
The user must be authorized for this exam run
in order to be enrolled
"""
mock_exam_auth.filter.return_value.exists.return_value = False
resp = self.client.post(self.url, {'exam_course_id': self.exam_course_id}, format='json')
assert resp.status_code == status.HTTP_401_UNAUTHORIZED
assert resp.status_code == status.HTTP_400_BAD_REQUEST
assert mock_refresh.call_count == 0

@patch('backends.utils.refresh_user_token', autospec=True)
def test_refresh_token_fails(self, mock_refresh):
Expand Down

0 comments on commit 9889789

Please sign in to comment.