Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Make static method a global function
Browse files Browse the repository at this point in the history
  • Loading branch information
djperrefort committed Oct 9, 2023
1 parent 61e55e9 commit f0434ca
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_request_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
from crc_jupyter_auth.remote_user_auth import AuthenticatorSettings, RemoteUserLoginHandler


def mock_user() -> User:
"""Create a jupyterhub user object with mock/dummy data
Returns:
A partially instantiated User instance
"""

return User(id=1, name='mock_user', admin=False, created=datetime.now(), cookie_id=new_token())


class TestUtils:
"""Base class for general testing/setup utilities"""

Expand Down Expand Up @@ -151,12 +161,6 @@ def test_incorrect_role_redirect(self, mock_redirect_call: MagicMock) -> None:
class SuccessfulLoginRouting(TestUtils, TestCase):
"""Test the routing of users after a successful login"""

@staticmethod
def mock_user() -> User:
"""Create a jupyterhub user object with mock/dummy data"""

return User(id=1, name='mock_user', admin=False, created=datetime.now(), cookie_id=new_token())

@patch.object(RemoteUserLoginHandler, 'redirect', return_value=None)
@patch.object(RemoteUserLoginHandler, 'user_from_username', return_value=mock_user())
def test_user_is_redirected(self, mock_user: User, mock_redirect_call: MagicMock) -> None:
Expand Down

0 comments on commit f0434ca

Please sign in to comment.