This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4092 from gratipay/test-helpers
test helpers
- Loading branch information
Showing
2 changed files
with
22 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
from gratipay.models.account_elsewhere import AccountElsewhere | ||
from gratipay.models.exchange_route import ExchangeRoute | ||
from gratipay.models.participant import Participant | ||
from gratipay.models.team import Team | ||
from gratipay.security import user | ||
from gratipay.testing.vcr import use_cassette | ||
from gratipay.testing.browser import Browser | ||
|
@@ -31,6 +32,11 @@ | |
PROJECT_ROOT = str(TOP) | ||
|
||
|
||
D = Decimal | ||
P = Participant.from_username | ||
T = Team.from_slug | ||
|
||
|
||
class ClientWithAuth(Client): | ||
|
||
def __init__(self, *a, **kw): | ||
|
@@ -173,14 +179,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 | ||
|
@@ -218,6 +222,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() | ||
|
@@ -231,6 +236,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 | ||
|
||
|
||
|
@@ -329,7 +341,7 @@ class BrowserHarness(Harness): | |
"""This harness passes everything through to an underlying Splinter Browser. | ||
""" | ||
|
||
_browser = Browser('phantomjs') | ||
_browser = Browser(os.environ['WEBDRIVER_BROWSER']) | ||
use_VCR = False # without this we get fixture spam from communication with PhantomJS | ||
base_url = os.environ['WEBDRIVER_BASE_URL'] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters