|
|
|
@ -71,16 +71,6 @@ def get_user_name_from_auth_blob(authblob):
|
|
|
|
|
return d['username']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def buy_item(item_id, what_about_it, user_name):
|
|
|
|
|
require_type(int, item_id)
|
|
|
|
|
assert(what_about_it in (ITEM_ONLY, DEPOSIT_ONLY, ITEM_AND_DEPOSIT))
|
|
|
|
|
|
|
|
|
|
content = _request('buyable/item/' + urllib.quote(str(item_id)),
|
|
|
|
|
{'user':user_name, 'deposit':what_about_it, 'amount':1}, method='POST')
|
|
|
|
|
if content != 'Created':
|
|
|
|
|
raise ValueError('Server says "%s"' % content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def bulk_buy(buycommands, user_name):
|
|
|
|
|
item_ids = tuple(e.item_id() for e in buycommands if e.includes_commodity())
|
|
|
|
|
deposit_ids = tuple(e.item_id() for e in buycommands if e.includes_deposit())
|
|
|
|
@ -131,8 +121,6 @@ if __name__ == '__main__':
|
|
|
|
|
user_name = get_user_name_from_auth_blob(os.environ['BARCODE_PLUGIN_TEST_AUTH_BLOB'])
|
|
|
|
|
print('User name: ' + user_name)
|
|
|
|
|
|
|
|
|
|
buy_item(1, True, user_name)
|
|
|
|
|
|
|
|
|
|
balance = get_balance(user_name)
|
|
|
|
|
print('Balance is %f, type is "%s"' % (balance, type(balance).__name__))
|
|
|
|
|
|
|
|
|
|