david / django-invitation
Built on top of django-registration, it restricts registration to a given number of invited person per active user (strategy introduced by GMail to involve 2.0 users).
Clone this repository (size: 60.6 KB): HTTPS / SSH
$ hg clone http://code.welldev.org/django-invitation
| commit 27: | 9abce3cf31f9 |
| parent 26: | be8229c1326b |
| branch: | default |
Created utility test method assertRedirect.
Changed (Δ213 bytes):
raw changeset »
invitation/tests.py (8 lines added, 4 lines removed)
Up to file-list invitation/tests.py:
| … | … | @@ -45,6 +45,13 @@ class InvitationTestCase(TestCase): |
45 |
45 |
self.expired_key.date_invited -= datetime.timedelta(days=settings.ACCOUNT_INVITATION_DAYS + 1) |
46 |
46 |
self.expired_key.save() |
47 |
47 |
|
48 |
def assertRedirect(self, response, viewname): |
|
49 |
"""Assert that response has been redirected to ``viewname``.""" |
|
50 |
self.assertEqual(response.status_code, 302) |
|
51 |
expected_location = 'http://testserver' + reverse(viewname) |
|
52 |
redirect_location = response._headers['location'][1] |
|
53 |
self.assertEqual(redirect_location, expected_location) |
|
54 |
||
48 |
55 |
|
49 |
56 |
class InvitationModelTests(InvitationTestCase): |
50 |
57 |
""" |
| … | … | @@ -246,10 +253,7 @@ class InvitationViewTests(InvitationTest |
246 |
253 |
# The first use of the key to register a new user works. |
247 |
254 |
response = self.client.post(reverse('registration_register'), |
248 |
255 |
data=registration_data) |
249 |
self.assertEqual(response.status_code, 302) |
|
250 |
redirect_location = response._headers['location'][1] |
|
251 |
self.assertTrue(redirect_location.endswith( |
|
252 |
reverse('registration_complete'))) |
|
256 |
self.assertRedirect(response, 'registration_complete') |
|
253 |
257 |
user = User.objects.get(username='new_user') |
254 |
258 |
key = InvitationKey.objects.get_key(self.sample_key.key) |
255 |
259 |
self.assertEqual(user, key.registrant) |
