def active(self, sess, comment, investor): active_investments = sess.query(Investment).\ filter(Investment.done == 0).\ filter(Investment.name == investor.name).\ order_by(Investment.time).\ all() comment.reply_wrap(message.modify_active(active_investments))
def attivi(self, sess, comment, investor): """ Returns a list of all active investments made by the user """ active_investments = (sess.query(Investment).filter( Investment.done == 0).filter( Investment.name == investor.name).order_by( Investment.time).all()) return comment.reply_wrap(message.modify_active(active_investments))
def test_active(self): self.command('!create') self.command('!invest 100', post='post1') self.command('!invest 100', post='post2') replies = self.command('!active') self.assertEqual(len(replies), 1) self.assertEqual( replies[0], message.modify_active([ Investment('post1', 100, 100, time.time()), Investment('post2', 100, 100, time.time()) ]))
def test_active(self): self.command('!create') self.command('!invest 100', post='post1') self.command('!invest 100', post='post2') replies = self.command('!attivi') self.assertEqual(len(replies), 1) self.assertEqual( replies[0].body.split('\n')[0], message.modify_active([ Investment('post1', 100, 100, time.time(), ''), Investment('post2', 100, 100, time.time(), '') ]).split('\n')[0])
def test_active(self): self.command("!create") self.command("!invest 100", post="post1") self.command("!invest 100", post="post2") replies = self.command("!attivi") self.assertEqual(len(replies), 1) self.assertEqual( replies[0].body.split("\n")[0], message.modify_active( [ Investment("post1", 100, 100, time.time(), ""), Investment("post2", 100, 100, time.time(), ""), ] ).split("\n")[0], )
def test_active_none(self): self.command("!create") replies = self.command("!attivi") self.assertEqual(len(replies), 1) self.assertEqual(replies[0].body, message.modify_active([]))
def activity(comment, author): active = database.investor_get_active(author) send_reply(comment, message.modify_active(active))
def activity(comment, author): investor = users[author] active = investor.get_active() send_not(comment, message.modify_active(active), False) return True
def active(self, sess, comment, investor): total = sess.query( func.count(Investment.id) ).filter(Investment.done == 0).\ filter(Investment.name == investor.name).scalar() comment.reply_wrap(message.modify_active(total))
def test_active_none(self): self.command('!create') replies = self.command('!active') self.assertEqual(len(replies), 1) self.assertEqual(replies[0], message.modify_active([]))