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

Commit

Permalink
Merge pull request #4092 from gratipay/test-helpers
Browse files Browse the repository at this point in the history
test helpers
  • Loading branch information
Nashe authored Jul 21, 2016
2 parents 223679a + 5decbc1 commit 342d5da
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
30 changes: 21 additions & 9 deletions gratipay/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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


Expand Down Expand Up @@ -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']

Expand Down
1 change: 1 addition & 0 deletions tests/test.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DATABASE_URL="dbname=gratipay-test"
BASE_URL=
WEBDRIVER_BROWSER="phantomjs"
WEBDRIVER_BASE_URL="http://localhost:8537"
UPDATE_HOMEPAGE_EVERY=0
CHECK_DB_EVERY=0
Expand Down

0 comments on commit 342d5da

Please sign in to comment.