Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Sep 12, 2014
1 parent 1cb9a52 commit 1180ddb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
1 change: 0 additions & 1 deletion gratipay/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ def get_verification_link(self):
link = "%s://%s/%s/verify-email.html?hash=%s" % (gratipay.canonical_scheme, gratipay.canonical_host, username, hash_string)
return link


def update_goal(self, goal):
typecheck(goal, (Decimal, None))
with self.db.get_cursor() as c:
Expand Down
23 changes: 14 additions & 9 deletions tests/py/test_participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,27 @@ def test_john_is_plural(self):
assert actual == expected

def test_can_change_email(self):
self.alice.update_email('[email protected]')
self.alice.change_email('[email protected]')
expected = '[email protected]'
actual = self.alice.email.address
assert actual == expected

def test_cannot_confirm_email_in_one_step(self):
self.alice.update_email('[email protected]', True)
actual = self.alice.email.confirmed
assert actual == False

def test_can_confirm_email_in_second_step(self):
def test_can_verify_email(self):
self.alice.update_email('[email protected]')
self.alice.update_email('[email protected]', True)
actual = self.alice.email.confirmed
hash_string = Participant.from_username('alice').email.hash
self.alice.verify_email(hash_string)
actual = Participant.from_username('alice').email.confirmed
assert actual == True

def test_cannot_verify_email_with_wrong_hash(self):
self.alice.update_email('[email protected]')
hash_string = "some wrong hash"
self.alice.verify_email(hash_string)
actual = Participant.from_username('alice').email.confirmed
assert actual == False

# TODO - Add a test for expired hashes. (We don't have control over the ctime of emails)

def test_cant_take_over_claimed_participant_without_confirmation(self):
with self.assertRaises(NeedConfirmation):
self.alice.take_over(('twitter', str(self.bob.id)))
Expand Down

0 comments on commit 1180ddb

Please sign in to comment.