def test_update(self): new_acc = Account(username="******",password_hash="1234",balance=10000) new_acc2 = Account(username="******",password_hash="4321",balance=20000) new_acc.save() new_acc2.save() new_acc.username = "******" new_acc2.username = "******" new_acc.save() new_acc2.save() item1 = Account.one_from_pk(1) item2 = Account.one_from_pk(2) self.assertEqual(item1.username, "test") self.assertEqual(item2.username, "test2")
def createaccount(): if not request.json or 'username' not in request.json or 'password' not in request.json: return jsonify(BADREQUEST), 400 account = Account() r = request.json account.username = r['username'] account.set_password(r['password']) account.set_apikey() account.balance = 0.00 account.save() return jsonify({"username": account.username, "apikey": account.api_key})