コード例 #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
ファイル: routes.py プロジェクト: jonatho7/SnapBYOBServer
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)