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

Commit

Permalink
Make it easier to verify participants in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Jul 16, 2016
1 parent a182c5c commit 2af9e57
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions gratipay/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,12 @@ def make_team(self, *a, **kw):
_kw['available'] = 0

if Participant.from_username(_kw['owner']) is None:
owner = self.make_participant( _kw['owner']
, claimed_time='now'
, last_paypal_result=''
, email_address=_kw['owner']+'@example.com'
)
TT = self.db.one("SELECT id FROM countries WHERE code='TT'")
owner.store_identity_info(TT, 'nothing-enforced', {'name': 'Owner'})
owner.set_identity_verification(TT, True)
self.make_participant( _kw['owner']
, claimed_time='now'
, last_paypal_result=''
, email_address=_kw['owner']+'@example.com'
, verified_in='TT'
)

team = self.db.one("""
INSERT INTO teams
Expand Down Expand Up @@ -218,6 +216,7 @@ def make_participant(self, username, **kw):
ExchangeRoute.insert(participant, 'paypal', '[email protected]', kw.pop('last_paypal_result'))

# Update participant
verified_in = kw.pop('verified_in', [])
if kw:
if kw.get('claimed_time') == 'now':
kw['claimed_time'] = utcnow()
Expand All @@ -231,6 +230,13 @@ def make_participant(self, username, **kw):
RETURNING participants.*::participants
""".format(cols, placeholders), vals+(username,))

# Verify identity
countries = [verified_in] if type(verified_in) in (str, unicode) else verified_in
for code in countries:
country = self.db.one("SELECT id FROM countries WHERE code=%s", (code,))
participant.store_identity_info(country, 'nothing-enforced', {'name': username})
participant.set_identity_verification(country, True)

return participant


Expand Down

0 comments on commit 2af9e57

Please sign in to comment.