def test_template_not_op(self): post = Submission("post") comment = Comment("1/id", "commenter", "!template https://i.imgur.com/asdas.jps", post) self.worker(comment) self.assertEqual(len(comment.replies), 1) self.assertEqual(comment.replies[0].body, message.TEMPLATE_NOT_OP)
def test_template(self): post = Submission("post") comment = Comment("1/id", post.author.name, "!template https://i.imgur.com/asdas.jps", post) self.worker(comment) self.assertEqual(len(comment.replies), 1) self.assertEqual(comment.replies[0].body, message.TEMPLATE_SUCCESS)
def command(self, command, username='******', post='testpost', lcomment=None, lpost=None): submission = Submission(post) if lpost: lpost(submission) comment = Comment(post + '/id', username, command, submission) if lcomment: lcomment(comment) self.worker(comment) return comment.replies
def command(self, command, username="******", post="testpost", lcomment=None, lpost=None): submission = Submission(post) self.submissions.append(submission) if lpost: lpost(submission) comment = Comment(post + "/id", username, command, submission) submission.replies.append(comment) self.comments.append(comment) if lcomment: lcomment(comment) self.worker(comment) return comment.replies
def create_investment(self, amount, start_upvotes, end_upvotes, iid='0'): investor = Investor(name='investor' + iid) submission = Submission('sid' + iid) comment = Comment('cid' + iid, investor.name, 'dummy', submission) self.reddit.add_submission(submission) investment = Investment( post=comment.submission.id, upvotes=start_upvotes, comment=comment.id, name=comment.author.name, amount=amount, response="0", done=False, ) investment.time = int(time.time()) - config.INVESTMENT_DURATION - 1 submission.ups = end_upvotes sess = self.Session() sess.add(investor) sess.add(investment) sess.commit() return investor, investment
def create_investment(self, amount, iid="0"): investor = Investor(name="investor" + iid) submission = Submission("sid" + iid) comment = Comment("cid" + iid, investor.name, "dummy", submission) self.reddit.add_submission(submission) investment = Investment( post=comment.submission.id, upvotes=1, comment=comment.id, name=comment.author.name, amount=amount, response="0", done=False, ) buyable = Buyable(post=submission.id, name=submission.author.name, response="brid" + iid) buyable.time = int(time.time()) - config.INVESTMENT_DURATION - 1 sess = self.session sess.add(buyable) sess.add(investor) sess.add(investment) sess.commit() return investor, buyable, submission
def command(self, command, username='******', post='testpost'): comment = Comment(post + '/id', username, command, Submission(post)) self.worker(comment) return comment.replies
def test_template_not_op(self): post = Submission('post') comment = Comment('1/id', 'commenter', '!template https://i.imgur.com/asdas.jps', post) self.worker(comment) self.assertEqual(len(comment.replies), 1) self.assertEqual(comment.replies[0].body, message.TEMPLATE_NOT_OP)