def test_authentication_fails(self): mock_auth_failure() backend = TokenAuthBackend() user = backend.authenticate("123") assert len(responses.calls) == 1, 'Expect only 1 call' assert user is None, 'Expect None to be returned if invalid user'
def test_authenticate(self): # setup: mock_auth_success() backend = TokenAuthBackend() token = 'some token' user = backend.authenticate(token) ## assert that a user exists in the Users db django_user_created = User.objects.get(username='******') assert len(responses.calls) == 1, 'Expect only 1 call' assert user.username == "joe.soap", 'Expect the correct user to be returned'