예제 #1
0
파일: test.py 프로젝트: pconrad/reddit
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
파일: test.py 프로젝트: pconrad/reddit
 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)
예제 #7
0
 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)
예제 #8
0
파일: test.py 프로젝트: pconrad/reddit
 def test_ucsantabarbara(self):
     post = reddit.get_posts("ucsantabarbara", sort_mode='random')[0]
     comments = reddit.get_comments(post)
예제 #9
0
 def test_ucsantabarbara(self):
     post = reddit.get_posts("ucsantabarbara", sort_mode='random')[0]
     comments = reddit.get_comments(post)