Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
All tests were assuming that the user was authenticated, which caused
tests to fail now that we are actually checking that the user is authenticated
post-pipeline (a none user is obviously not authenticated so pre-pipeline this
wasn't causing problems).

Mirrored the way that is_active is done.
  • Loading branch information
Ben Rogers-Newsome committed Jan 5, 2022
1 parent 1c072db commit 928431d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions social_core/tests/actions/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@


class LoginActionTest(BaseActionTest):
def setUp(self):
super().setUp()
User.set_authenticated(False)

def tearDown(self):
super().tearDown()
User.set_authenticated(True)

def test_login(self):
self.do_login()

Expand Down
8 changes: 8 additions & 0 deletions social_core/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class User(BaseModel):
NEXT_ID = 1
cache = {}
_is_active = True
_is_authenticated = True

def __init__(self, username, email=None, **extra_user_fields):
self.id = User.next_id()
Expand All @@ -39,10 +40,17 @@ def __init__(self, username, email=None, **extra_user_fields):
def is_active(self):
return self._is_active

def is_authenticated(self):
return self._is_authenticated

@classmethod
def set_active(cls, is_active=True):
cls._is_active = is_active

@classmethod
def set_authenticated(cls, is_authenticated=True):
cls._is_authenticated = is_authenticated

def set_password(self, password):
self.password = password

Expand Down

0 comments on commit 928431d

Please sign in to comment.