Skip to content

Unit Test Django Client Login? #81

@meconlin

Description

@meconlin

How can I unit test authentication on my Django app using python-social-auth?

I attempted this:

    self.c = Client()
    self.u = User.objects.create(username="testuser", password="password", is_staff=True, is_active=True, is_superuser=True)
    self.u.save()
    self.auth = UserSocialAuth(user=self.u, provider="Facebook")
    self.auth.save()
    self.c.login(username=self.u.username, password=self.u.password) 

but this call to login returns False and the user is not authenticated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions