|
|
@ -1,8 +1,10 @@ |
|
|
|
from django.core import mail |
|
|
|
|
|
|
|
from django.conf import settings |
|
|
|
from django.test.utils import override_settings |
|
|
|
from hc.test import BaseTestCase |
|
|
|
from hc.accounts.models import Member |
|
|
|
from hc.api.models import TokenBucket |
|
|
|
|
|
|
|
|
|
|
|
class ProjectTestCase(BaseTestCase): |
|
|
@ -83,6 +85,20 @@ class ProjectTestCase(BaseTestCase): |
|
|
|
" Alice's Project on %s" % settings.SITE_NAME) |
|
|
|
self.assertEqual(mail.outbox[0].subject, subj) |
|
|
|
|
|
|
|
@override_settings(SECRET_KEY="test-secret") |
|
|
|
def test_it_rate_limits_invites(self): |
|
|
|
obj = TokenBucket(value="invite-%d" % self.alice.id) |
|
|
|
obj.tokens = 0 |
|
|
|
obj.save() |
|
|
|
|
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|
form = {"invite_team_member": "1", "email": "[email protected]"} |
|
|
|
r = self.client.post(self.url, form) |
|
|
|
self.assertContains(r, "Too Many Requests") |
|
|
|
|
|
|
|
self.assertEqual(len(mail.outbox), 0) |
|
|
|
|
|
|
|
def test_it_requires_owner_to_add_team_member(self): |
|
|
|
self.client.login(username="[email protected]", password="password") |
|
|
|
|
|
|
|