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

Commit

Permalink
Add tests for vetting during set_take_for
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Nov 21, 2016
1 parent b979dc2 commit 023e447
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gratipay/models/team/mixins/takes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
42 changes: 42 additions & 0 deletions tests/py/test_team_takes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]')
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='[email protected]', 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='[email protected]')
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='[email protected]', 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):
Expand Down

0 comments on commit 023e447

Please sign in to comment.