def test_cache(self): reddit._start_editing() p1 = reddit.get_posts("askreddit")[0] p2 = reddit.get_posts("empty") p3 = reddit.get_posts("corgis")[0] p4 = reddit.get_posts("ucsantabarbara")[0] self.assertEqual(len(reddit._CACHE), 4) reddit.get_comments(p1, max_depth=4, max_breadth=4) reddit.get_comments(p3, max_depth=4, max_breadth=4) self.assertGreater(sum([len(element) for key, element in reddit._CACHE.items()]), 4)
def test_cache(self): reddit._start_editing() p1 = reddit.get_posts("askreddit")[0] p2 = reddit.get_posts("empty") p3 = reddit.get_posts("corgis")[0] p4 = reddit.get_posts("ucsantabarbara")[0] self.assertEqual(len(reddit._CACHE), 4) reddit.get_comments(p1, max_depth=4, max_breadth=4) reddit.get_comments(p3, max_depth=4, max_breadth=4) self.assertGreater( sum([len(element) for key, element in reddit._CACHE.items()]), 4)
def start_query(self, sub, starttime, endtime): """begins retrieving reddit comments""" self.sub = sub self.starttime = starttime self.endtime = endtime self.posts = reddit.get_posts(self.__reddit, sub, endtime, starttime) self.commlist = reddit.get_comments(self.posts)
def redditComments(): postID = str(request.args.get('postID')) sort_mode = 'hot' max_depth = 5 max_breadth = 5 commentsList = red.get_comments(postID, sort_mode, max_depth, max_breadth) commentsJson = red.comments_to_json(commentsList) return jsonify(redditReport=commentsJson)
def redditComments(): postID = str(request.args.get('postID')) sort_mode='hot' max_depth=5 max_breadth=5 commentsList = red.get_comments(postID, sort_mode, max_depth, max_breadth) commentsJson = red.comments_to_json(commentsList) return jsonify(redditReport=commentsJson)
def test_comments(self): post = reddit.get_posts("askreddit")[1] comments = reddit.get_comments(post,max_depth=5, max_breadth=1) self.assertTrue(comments) self.assertTrue(comments[0].replies) self.assertTrue(comments[0].replies[0].replies) self.assertTrue(comments[0].replies[0].replies[0].replies[0]) self.assertTrue(comments[0].replies[0].replies[0].replies[0].replies) self.assertFalse(comments[0].replies[0].replies[0].replies[0].replies[0].replies)
def test_comments(self): post = reddit.get_posts("askreddit")[1] comments = reddit.get_comments(post, max_depth=5, max_breadth=1) self.assertTrue(comments) self.assertTrue(comments[0].replies) self.assertTrue(comments[0].replies[0].replies) self.assertTrue(comments[0].replies[0].replies[0].replies[0]) self.assertTrue(comments[0].replies[0].replies[0].replies[0].replies) self.assertFalse( comments[0].replies[0].replies[0].replies[0].replies[0].replies)
def test_ucsantabarbara(self): post = reddit.get_posts("ucsantabarbara", sort_mode='random')[0] comments = reddit.get_comments(post)