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

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Mar 24, 2015
1 parent fb849ca commit f815f3b
Show file tree
Hide file tree
Showing 15 changed files with 250 additions and 398 deletions.
18 changes: 16 additions & 2 deletions gratipay/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from gratipay.elsewhere import UserInfo
from gratipay.main import website
from gratipay.models.account_elsewhere import AccountElsewhere
from gratipay.models.exchange_route import ExchangeRoute
from gratipay.security.user import User
from gratipay.testing.vcr import use_cassette
from psycopg2 import IntegrityError, InternalError
Expand Down Expand Up @@ -161,6 +162,12 @@ def make_participant(self, username, **kw):
VALUES (%s,%s,%s,%s)
""", (platform, participant.id, username, username))

# Insert exchange routes
if 'last_bill_result' in kw:
ExchangeRoute.insert(participant, 'balanced-cc', '/cards/foo', kw.pop('last_bill_result'))
if 'last_ach_result' in kw:
ExchangeRoute.insert(participant, 'balanced-ba', '/bank_accounts/bar', kw.pop('last_ach_result'))

# Update participant
if kw:
if kw.get('claimed_time') == 'now':
Expand All @@ -184,8 +191,15 @@ def fetch_payday(self):
return self.db.one("SELECT * FROM paydays", back_as=dict)


def make_exchange(self, kind, amount, fee, participant, status='succeeded', error=''):
e_id = record_exchange(self.db, kind, amount, fee, participant, 'pre')
def make_exchange(self, route, amount, fee, participant, status='succeeded', error=''):
if not isinstance(route, ExchangeRoute):
network = route
route = ExchangeRoute.from_network(participant, network)
if not route:
from .balanced import BalancedHarness
route = ExchangeRoute.insert(participant, network, BalancedHarness.card_href)
assert route
e_id = record_exchange(self.db, route, amount, fee, participant, 'pre')
record_exchange_result(self.db, e_id, status, error, participant)
return e_id

Expand Down
9 changes: 5 additions & 4 deletions gratipay/testing/balanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import balanced

from gratipay.models.exchange_route import ExchangeRoute
from gratipay.testing import Harness
from gratipay.testing.vcr import use_cassette

Expand All @@ -16,12 +17,12 @@ def setUp(self):
balanced_customer_href=self.david_href)
self.janet = self.make_participant('janet', is_suspicious=False,
claimed_time='now',
balanced_customer_href=self.janet_href,
last_bill_result='')
balanced_customer_href=self.janet_href)
self.janet_route = ExchangeRoute.insert(self.janet, 'balanced-cc', self.card_href)
self.homer = self.make_participant('homer', is_suspicious=False,
claimed_time='now',
balanced_customer_href=self.homer_href,
last_ach_result='')
balanced_customer_href=self.homer_href)
self.homer_route = ExchangeRoute.insert(self.homer, 'balanced-ba', self.bank_account_href)

@classmethod
def tearDownClass(cls):
Expand Down
220 changes: 0 additions & 220 deletions tests/py/test_billing.py

This file was deleted.

Loading

0 comments on commit f815f3b

Please sign in to comment.