Skip to content

Commit

Permalink
test: move tests to common directory and update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
GlugovGrGlib committed Feb 22, 2024
1 parent 04cba7e commit 684161d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,19 @@ def test_get_requested_user(self, user_role, username, expected_username, mock_g
elif user_role == "staff":
request_user = self.admin_user
elif user_role == "student":
request_user = self.user
request_user = self.student_user

self.request.user = request_user

if expected_username:
expected_user = User.objects.get(username=expected_username)
mock_get.return_value = expected_user
else:
expected_user = None
if expected_username == "student_user":
mock_user = self.student_user
mock_get.return_value = mock_user

result_user = BlocksInfoInCourseView().get_requested_user(self.request.user, username)
if expected_user:
if expected_username:
self.assertEqual(result_user.username, expected_username)
mock_get.assert_called_with(username=username)
if username:
mock_get.assert_called_with(username=username)
else:
self.assertIsNone(result_user)

Expand Down

0 comments on commit 684161d

Please sign in to comment.