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

Commit

Permalink
Added the necessary code for properly creating fake exchanges
Browse files Browse the repository at this point in the history
  • Loading branch information
kaguillera committed Sep 14, 2016
1 parent 3a99242 commit 1a3f844
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions gratipay/utils/fake_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def fake_participant(db, is_admin=False, random_identities=True):
)
participant = Participant.from_username(username)

fake_exchange_route(db, participant)
if random_identities:
if random.randrange(100) < 66:
fake_participant_identity(participant)
Expand All @@ -97,6 +98,20 @@ def fake_participant(db, is_admin=False, random_identities=True):

return participant

def fake_exchange_route(db, participant, network=None):


if not network:
networks = ["balanced-ba", "balanced-cc", "paypal", "bitcoin"]
network = random.sample(networks, 1)[0]

insert_fake_data( db
, "exchange_routes"
, participant = participant.id
, network = network
, address = participant.email_address
, error = "None"
)

def fake_participant_identity(participant, verification=None):
"""Pick a country and make an identity for the participant there.
Expand Down Expand Up @@ -224,15 +239,21 @@ def fake_transfer(db, tipper, tippee):


def fake_exchange(db, participant, amount, fee, timestamp):

return insert_fake_data( db
, "exchanges"
, timestamp=timestamp
, participant=participant.username
, amount=amount
, fee=fee
, status='succeeded'
, route=get_exchange_route(db, participant.id)
)

def get_exchange_route(db, participant):

return db.one("SELECT id FROM exchange_routes WHERE participant={}"
.format(participant), participant)

def random_country_id(db):
return db.one("SELECT id FROM countries ORDER BY random() LIMIT 1")
Expand Down

0 comments on commit 1a3f844

Please sign in to comment.