Example #1
0
 def post(self):
    import static
    atom = static.get('/stage/atom.xml')
    static.set('/feed/atom.xml', atom.body,
            'application/atom+xml; charset=utf-8', indexed=False,
            last_modified=datetime.datetime.now())
    self.redirect('/admin/')
    def check_balance(self):
        result = get(SERVER + '/' + GET_DONATIONS,
                     {'accountNumber': self.account})

        self.donations = {
            dct['donationId']: dct['balance']
            for dct in result['output']
        }
        return sum(list(self.donations.values()))
 def spend(self):
     for donation_id, balance in self.donations.items():
         account = random.choice(ACCOUNTS)
         if balance > 100:
             amount = random.randint(2 * balance // 3, balance)
         else:
             amount = balance
         assert amount > 0
         params = {
             'donateId': donation_id,
             'amount': amount,
             'accountNumber': account,
             'purpose': '_'
         }
         answer = get(SERVER + '/' + ADD_TRANSACTION, params)
         self.logger.info(
             f'add_transaction answer = {answer}, params = {params}')
     return answer['result']
Example #4
0
 def document(self):
     import static
     return static.get(self.path)