From 1180ddb63a6308fb13f2c0d63eb4c5da694c4c02 Mon Sep 17 00:00:00 2001 From: Rohit Paul Kuruvilla Date: Fri, 12 Sep 2014 06:29:59 +0530 Subject: [PATCH] Added tests --- gratipay/models/participant.py | 1 - tests/py/test_participant.py | 23 ++++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gratipay/models/participant.py b/gratipay/models/participant.py index 04fdf9d8c7..40149ffcb6 100644 --- a/gratipay/models/participant.py +++ b/gratipay/models/participant.py @@ -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: diff --git a/tests/py/test_participant.py b/tests/py/test_participant.py index 5d8ee50aa4..40e0f95336 100644 --- a/tests/py/test_participant.py +++ b/tests/py/test_participant.py @@ -209,22 +209,27 @@ def test_john_is_plural(self): assert actual == expected def test_can_change_email(self): - self.alice.update_email('alice@gratipay.com') + self.alice.change_email('alice@gratipay.com') expected = 'alice@gratipay.com' actual = self.alice.email.address assert actual == expected - def test_cannot_confirm_email_in_one_step(self): - self.alice.update_email('alice@gratipay.com', 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('alice@gratipay.com') - self.alice.update_email('alice@gratipay.com', 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('alice@gratipay.com') + 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)))