This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
012ce92
commit 271607d
Showing
7 changed files
with
10 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,30 +2,24 @@ | |
|
||
import json | ||
import sys | ||
import time | ||
|
||
from gratipay.exceptions import CannotRemovePrimaryEmail, EmailTaken, EmailNotVerified | ||
from gratipay.exceptions import TooManyEmailAddresses, ResendingTooFast | ||
from gratipay.exceptions import TooManyEmailAddresses | ||
from gratipay.testing import P | ||
from gratipay.testing.email import QueuedEmailHarness, SentEmailHarness | ||
from gratipay.models.participant import email as _email | ||
from gratipay.utils import encode_for_querystring | ||
from gratipay.cli import queue_branch_email as _queue_branch_email | ||
|
||
|
||
class AliceAndResend(QueuedEmailHarness): | ||
class Alice(QueuedEmailHarness): | ||
|
||
def setUp(self): | ||
QueuedEmailHarness.setUp(self) | ||
self.alice = self.make_participant('alice', claimed_time='now') | ||
self._old_threshold = self.client.website.env.resend_verification_threshold | ||
self.client.website.env.resend_verification_threshold = '0 seconds' | ||
|
||
def tearDown(self): | ||
self.client.website.env.resend_verification_threshold = self._old_threshold | ||
|
||
|
||
class TestEndpoints(AliceAndResend): | ||
class TestEndpoints(Alice): | ||
|
||
def hit_email_spt(self, action, address, user='alice', should_fail=False): | ||
f = self.client.PxST if should_fail else self.client.POST | ||
|
@@ -210,7 +204,7 @@ def test_remove_email(self): | |
self.hit_email_spt('remove', '[email protected]') | ||
|
||
|
||
class TestFunctions(AliceAndResend): | ||
class TestFunctions(Alice): | ||
|
||
def test_cannot_update_email_to_already_verified(self): | ||
bob = self.make_participant('bob', claimed_time='now') | ||
|
@@ -241,17 +235,6 @@ def test_cannot_add_too_many_emails(self): | |
with self.assertRaises(TooManyEmailAddresses): | ||
self.alice.add_email('[email protected]') | ||
|
||
def test_cannot_resend_verification_too_frequently(self): | ||
self.alice.add_email('[email protected]') | ||
time.sleep(0.05) | ||
with self.assertRaises(ResendingTooFast): | ||
self.alice.add_email('[email protected]', '0.1 seconds') | ||
|
||
def test_can_resend_verification_after_a_while(self): | ||
self.alice.add_email('[email protected]') | ||
time.sleep(0.15) | ||
self.alice.add_email('[email protected]', '0.1 seconds') | ||
|
||
def test_html_escaping(self): | ||
self.alice.add_email("foo'[email protected]") | ||
last_email = self.get_last_email() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -190,10 +190,10 @@ def test_email_addresses_merging(self): | |
alice.verify_email('[email protected]', alice.get_email('[email protected]').nonce) | ||
bob_github = self.make_elsewhere('github', 2, 'bob') | ||
bob = bob_github.opt_in('bob')[0].participant | ||
bob.add_email('[email protected]', '0 seconds') | ||
bob.add_email('[email protected]') | ||
bob.verify_email('[email protected]', bob.get_email('[email protected]').nonce) | ||
bob.add_email('[email protected]', '0 seconds') | ||
bob.add_email('[email protected]', '0 seconds') | ||
bob.add_email('[email protected]') | ||
bob.add_email('[email protected]') | ||
alice.take_over(bob_github, have_confirmation=True) | ||
|
||
alice_emails = {e.address: e for e in alice.get_emails()} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters