Beispiel #1
0
 def transfer_for_real(self, transfers):
     db = self.db
     print("Starting transfers (n=%i)" % len(transfers))
     msg = "Executing transfer #%i (amount=%s context=%s team=%s tipper_wallet_id=%s tippee_wallet_id=%s)"
     for i, t in enumerate(transfers):
         log(msg % (i, t.amount, t.context, t.team, t.tipper_wallet_id, t.tippee_wallet_id))
         transfer(db, **t.__dict__)
Beispiel #2
0
 def test_sync_with_mangopay_transfers(self):
     self.make_exchange('mango-cc', 10, 0, self.janet)
     with mock.patch('liberapay.billing.exchanges.record_transfer_result') as rtr:
         rtr.side_effect = Foobar()
         with self.assertRaises(Foobar):
             transfer(self.db, self.janet.id, self.david.id, D('10.00'), 'tip')
     t = self.db.one("SELECT * FROM transfers")
     assert t.status == 'pre'
     sync_with_mangopay(self.db)
     t = self.db.one("SELECT * FROM transfers")
     assert t.status == 'succeeded'
     assert Participant.from_username('david').balance == 10
     assert Participant.from_username('janet').balance == 0
Beispiel #3
0
 def test_sync_with_mangopay_deletes_transfers_that_didnt_happen(self):
     self.make_exchange('mango-cc', 10, 0, self.janet)
     with mock.patch('liberapay.billing.exchanges.record_transfer_result') as rtr \
        , mock.patch('liberapay.billing.mangoapi.transfers.Create') as Create:
         rtr.side_effect = Create.side_effect = Foobar
         with self.assertRaises(Foobar):
             transfer(self.db, self.janet.id, self.david.id, D('10.00'), 'tip')
     t = self.db.one("SELECT * FROM transfers")
     assert t.status == 'pre'
     sync_with_mangopay(self.db)
     transfers = self.db.all("SELECT * FROM transfers")
     assert not transfers
     assert Participant.from_username('david').balance == 0
     assert Participant.from_username('janet').balance == 10
Beispiel #4
0
 def test_sync_with_mangopay_deletes_transfers_that_didnt_happen(self):
     self.make_exchange('mango-cc', 10, 0, self.janet)
     with mock.patch('liberapay.billing.exchanges.record_transfer_result') as rtr, \
          mock.patch('liberapay.billing.mangoapi.transfers.Create') as Create:
         rtr.side_effect = Create.side_effect = Foobar
         with self.assertRaises(Foobar):
             transfer(self.db, self.janet.id, self.david.id, D('10.00'),
                      'tip')
     t = self.db.one("SELECT * FROM transfers")
     assert t.status == 'pre'
     sync_with_mangopay(self.db)
     transfers = self.db.all("SELECT * FROM transfers")
     assert not transfers
     assert Participant.from_username('david').balance == 0
     assert Participant.from_username('janet').balance == 10
Beispiel #5
0
 def test_sync_with_mangopay_transfers(self):
     self.make_exchange('mango-cc', 10, 0, self.janet)
     with mock.patch(
             'liberapay.billing.exchanges.record_transfer_result') as rtr:
         rtr.side_effect = Foobar()
         with self.assertRaises(Foobar):
             transfer(self.db, self.janet.id, self.david.id, D('10.00'),
                      'tip')
     t = self.db.one("SELECT * FROM transfers")
     assert t.status == 'pre'
     sync_with_mangopay(self.db)
     t = self.db.one("SELECT * FROM transfers")
     assert t.status == 'succeeded'
     assert Participant.from_username('david').balance == 10
     assert Participant.from_username('janet').balance == 0
Beispiel #6
0
 def test_cash_bundles_are_merged_after_transfer(self):
     bundles_count = lambda: self.db.one("SELECT count(*) FROM cash_bundles"
                                         )
     assert bundles_count() == 0
     self.make_exchange('mango-cc', 45, 0, self.janet)
     assert bundles_count() == 1
     transfer(self.db, self.janet.id, self.homer.id, D('10.00'), 'tip')
     assert bundles_count() == 2
     transfer(self.db, self.homer.id, self.janet.id, D('5.00'), 'tip')
     assert bundles_count() == 2
     transfer(self.db, self.homer.id, self.janet.id, D('5.00'), 'tip')
     assert bundles_count() == 1
     self.db.self_check()
Beispiel #7
0
 def transfer_for_real(self, transfers):
     db = self.db
     for t in transfers:
         transfer(db, **t.__dict__)
Beispiel #8
0
 def transfer_for_real(self, transfers):
     db = self.db
     for t in transfers:
         transfer(db, **t.__dict__)