Exemple #1
0
 def test_parent__chain(self):
     comment = Comment(self.reddit, "dkk4qjd")
     counter = 0
     with self.recorder.use_cassette("TestComment.test_parent__chain"):
         comment.refresh()
         parent = comment.parent()
         while parent != comment.submission:
             if counter % 9 == 0:
                 parent.refresh()
             counter += 1
             parent = parent.parent()
Exemple #2
0
 def test_parent__chain(self):
     comment = Comment(self.reddit, 'dkk4qjd')
     counter = 0
     with self.recorder.use_cassette('TestComment.test_parent__chain'):
         comment.refresh()
         parent = comment.parent()
         while parent != comment.submission:
             if counter % 9 == 0:
                 parent.refresh()
             counter += 1
             parent = parent.parent()
Exemple #3
0
def get_comment_stat(comment: Comment) -> dict:
    comment.refresh()
    comment.replies.replace_more(limit=0)

    result = {}
    result['comment_body'] = comment.body.replace('\n', '\\n')
    result['created_utc'] = datetime.fromtimestamp(
        comment.created_utc).strftime('%Y-%m-%d %H:%M')
    result['replies_count'] = len(comment.replies.list())
    result['score'] = comment.score

    return result
Exemple #4
0
 def test_refresh__with_reply_sort_and_limit(self):
     with self.use_cassette():
         comment = Comment(self.reddit, "e4j4830")
         comment.reply_limit = 4
         comment.reply_sort = "new"
         comment.refresh()
         replies = comment.replies
     last_created = float("inf")
     for reply in replies:
         if isinstance(reply, Comment):
             if reply.created_utc > last_created:
                 assert False, "sort order incorrect"
             last_created = reply.created_utc
     assert len(comment.replies) == 3
Exemple #5
0
 def test_refresh__with_reply_sort_and_limit(self):
     with self.recorder.use_cassette(
             'TestComment.test_refresh__with_reply_sort_and_limit'):
         comment = Comment(self.reddit, 'e4j4830')
         comment.reply_limit = 4
         comment.reply_sort = 'new'
         comment.refresh()
         replies = comment.replies
     last_created = float('inf')
     for reply in replies:
         if isinstance(reply, Comment):
             if (reply.created_utc > last_created):
                 assert False, 'sort order incorrect'
             last_created = reply.created_utc
     assert len(comment.replies) == 3
Exemple #6
0
 def test_refresh__with_reply_sort_and_limit(self):
     with self.recorder.use_cassette(
         "TestComment.test_refresh__with_reply_sort_and_limit"
     ):
         comment = Comment(self.reddit, "e4j4830")
         comment.reply_limit = 4
         comment.reply_sort = "new"
         comment.refresh()
         replies = comment.replies
     last_created = float("inf")
     for reply in replies:
         if isinstance(reply, Comment):
             if reply.created_utc > last_created:
                 assert False, "sort order incorrect"
             last_created = reply.created_utc
     assert len(comment.replies) == 3
Exemple #7
0
 def test_refresh(self):
     comment = Comment(self.reddit, "d81vwef")
     with self.recorder.use_cassette("TestComment.test_refresh"):
         assert len(comment.replies) == 0
         comment.refresh()
         assert len(comment.replies) > 0