|
@ -1,6 +1,9 @@ |
|
|
|
|
|
from django.contrib.auth.hashers import make_password |
|
|
from django.contrib.auth.models import User |
|
|
from django.contrib.auth.models import User |
|
|
from django.test import TestCase |
|
|
from django.test import TestCase |
|
|
|
|
|
|
|
|
|
|
|
from hc.accounts.models import Profile |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CheckTokenTestCase(TestCase): |
|
|
class CheckTokenTestCase(TestCase): |
|
|
|
|
|
|
|
@ -8,9 +11,12 @@ class CheckTokenTestCase(TestCase): |
|
|
super(CheckTokenTestCase, self).setUp() |
|
|
super(CheckTokenTestCase, self).setUp() |
|
|
|
|
|
|
|
|
self.alice = User(username="alice") |
|
|
self.alice = User(username="alice") |
|
|
self.alice.set_password("secret-token") |
|
|
|
|
|
self.alice.save() |
|
|
self.alice.save() |
|
|
|
|
|
|
|
|
|
|
|
self.profile = Profile(user=self.alice) |
|
|
|
|
|
self.profile.token = make_password("secret-token") |
|
|
|
|
|
self.profile.save() |
|
|
|
|
|
|
|
|
def test_it_redirects(self): |
|
|
def test_it_redirects(self): |
|
|
r = self.client.get("/accounts/check_token/alice/secret-token/") |
|
|
r = self.client.get("/accounts/check_token/alice/secret-token/") |
|
|
self.assertRedirects(r, "/checks/") |
|
|
self.assertRedirects(r, "/checks/") |
|
|