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
b1e0472
commit d4a22db
Showing
2 changed files
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, division, print_function, unicode_literals | ||
|
||
from gratipay.testing import Harness | ||
from gratipay.models.participant import Participant | ||
|
||
|
||
class TestFromEmail(Harness): | ||
|
||
def test_returns_participant_by_primary_email(self): | ||
alice = self.make_participant('alice') | ||
self.add_and_verify_email(alice, '[email protected]') | ||
|
||
assert Participant.from_email('[email protected]').username == 'alice' | ||
|
||
def test_returns_participant_by_non_primary_email(self): | ||
alice = self.make_participant('alice') | ||
self.add_and_verify_email(alice, '[email protected]') | ||
self.add_and_verify_email(alice, '[email protected]') | ||
|
||
assert Participant.from_username('alice').email_address == '[email protected]' | ||
assert Participant.from_email('[email protected]').username == 'alice' | ||
|
||
def test_returns_none_for_unverified_email(self): | ||
alice = self.make_participant('alice') | ||
alice.start_email_verification('[email protected]') | ||
|
||
assert Participant.from_email('[email protected]') is None | ||
|
||
def test_returns_none_if_no_email_exists(self): | ||
assert Participant.from_email('[email protected]') is None |