def test_market(self): replies = self.command('!mercato') self.assertEqual(len(replies), 1) self.assertEqual(replies[0].body, message.modify_market(0, 0, 0)) self.command('!create') replies = self.command('!mercato') self.assertEqual(len(replies), 1) self.assertEqual(replies[0].body, message.modify_market(0, 1000, 0)) self.command('!invest 100') replies = self.command('!mercato') self.assertEqual(len(replies), 1) self.assertEqual(replies[0].body, message.modify_market(1, 900, 100))
def market(comment): user_cap = database.market_user_coins() invest_cap = database.market_invest_coins() active_number = database.market_count_investments() send_reply(comment, message.modify_market(active_number, user_cap, invest_cap))
def market(self, sess, comment): total = sess.query(func.coalesce(func.sum(Investor.balance), 0)).scalar() invested, active = sess.query( func.coalesce(func.sum(Investment.amount), 0), func.count(Investment.id)).filter(Investment.done == 0).first() comment.reply_wrap(message.modify_market(active, total, invested))
def mercato(self, sess, comment): """ Return the meme market's current state """ total = sess.query(func.coalesce(func.sum(Investor.balance), 0)).scalar() invested, active = sess.query( func.coalesce(func.sum(Investment.amount), 0), func.count(Investment.id)).filter(Investment.done == 0).first() return comment.reply_wrap( message.modify_market(active, total, invested))
def market(comment, author): number_of_invs = len(awaiting) users_balance = all_balance() invest_balance = all_investments() send_not(comment, message.modify_market(number_of_invs, users_balance, invest_balance), False) return True