Example #1
0
    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))
Example #2
0
    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))
Example #3
0
    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())
            ]))
Example #4
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])
Example #5
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],
        )
Example #6
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([]))
Example #7
0
def activity(comment, author):

    active = database.investor_get_active(author)
    send_reply(comment, message.modify_active(active))
Example #8
0
def activity(comment, author):
    investor = users[author] 
    active = investor.get_active()
    send_not(comment, message.modify_active(active), False)
    return True
Example #9
0
 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))
Example #10
0
    def test_active_none(self):
        self.command('!create')

        replies = self.command('!active')
        self.assertEqual(len(replies), 1)
        self.assertEqual(replies[0], message.modify_active([]))