From 023e4472867440e441332d4de8fae24231d297bc Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 22 Sep 2016 12:10:18 -0400 Subject: [PATCH] Add tests for vetting during set_take_for --- gratipay/models/team/mixins/takes.py | 4 +-- tests/py/test_team_takes.py | 42 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/gratipay/models/team/mixins/takes.py b/gratipay/models/team/mixins/takes.py index 53b8789297..16a7bbcc43 100644 --- a/gratipay/models/team/mixins/takes.py +++ b/gratipay/models/team/mixins/takes.py @@ -53,10 +53,10 @@ def set_take_for(self, participant, take, recorder, cursor=None): def vet(p): if p.is_suspicious: raise NotAllowed("user must not be flagged as suspicious") - elif not p.has_verified_identity: - raise NotAllowed("user must have a verified identity") elif not p.email_address: raise NotAllowed("user must have added at least one email address") + elif not p.has_verified_identity: + raise NotAllowed("user must have a verified identity") elif not p.is_claimed: raise NotAllowed("user must have claimed the account") diff --git a/tests/py/test_team_takes.py b/tests/py/test_team_takes.py index ce7cb3b3f6..6025ff85b9 100644 --- a/tests/py/test_team_takes.py +++ b/tests/py/test_team_takes.py @@ -123,6 +123,48 @@ def test_stf_doesnt_let_anyone_set_a_take_who_is_not_already_on_the_team_even_to assert actual == 'can only set take if already a member of the team' + def test_stf_vets_participant_for_suspiciousness(self): + mallory = self.make_participant('mallory', is_suspicious=True) + actual = self.err(mallory, 0, self.picard) + assert actual == 'user must not be flagged as suspicious' + + def test_stf_vets_participant_for_email(self): + mallory = self.make_participant('mallory') + actual = self.err(mallory, 0, self.picard) + assert actual == 'user must have added at least one email address' + + def test_stf_vets_participant_for_verified_identity(self): + mallory = self.make_participant('mallory', email_address='m@example.com') + actual = self.err(mallory, 0, self.picard) + assert actual == 'user must have a verified identity' + + def test_stf_vets_participant_for_claimed(self): + mallory = self.make_participant('mallory', email_address='m@example.com', verified_in='TT') + actual = self.err(mallory, 0, self.picard) + assert actual == 'user must have claimed the account' + + + def test_stf_vets_recorder_for_suspiciousness(self): + mallory = self.make_participant('mallory', is_suspicious=True) + actual = self.err(self.crusher, 0, mallory) + assert actual == 'user must not be flagged as suspicious' + + def test_stf_vets_recorder_for_email(self): + mallory = self.make_participant('mallory') + actual = self.err(self.crusher, 0, mallory) + assert actual == 'user must have added at least one email address' + + def test_stf_vets_recorder_for_verified_identity(self): + mallory = self.make_participant('mallory', email_address='m@example.com') + actual = self.err(self.crusher, 0, mallory) + assert actual == 'user must have a verified identity' + + def test_stf_vets_recorder_for_claimed(self): + mallory = self.make_participant('mallory', email_address='m@example.com', verified_in='TT') + actual = self.err(self.crusher, 0, mallory) + assert actual == 'user must have claimed the account' + + # gtlwf - get_take_last_week_for def test_gtlwf_gets_take_last_week_for_someone(self):