Skip to content
Snippets Groups Projects
Commit 664bbaa0 authored by Holger's avatar Holger
Browse files

Add get_all_replies to comment for fetching all replies

parent fc856711
No related branches found
No related tags found
No related merge requests found
......@@ -156,6 +156,12 @@ before transmitting the packed file. Please check the hash-sum after downloading
Changelog
=========
0.19.48
-------
* Fix issue #45 (upvote() and downvote() of a pending post/comment without vote did not work)
* fix Amount for condenser broadcast ops on appbase nodes (fixes transfer broadcast for example)
* Added get_all_replies() to Comment for fetching all replies to a post
0.19.47
-------
* Some bug fixes
......
......@@ -516,7 +516,7 @@ class Comment(BlockchainObject):
return self.steem.rpc.get_reblogged_by(post_author, post_permlink, api="follow")
def get_replies(self, raw_data=False, identifier=None):
""" Returns all content replies
""" Returns content replies
:param bool raw_data: When set to False, the replies will be returned as Comment class objects
"""
......@@ -536,6 +536,20 @@ class Comment(BlockchainObject):
return content_replies
return [Comment(c, steem_instance=self.steem) for c in content_replies]
def get_all_replies(self, parent=None):
""" Returns all content replies
"""
if parent is None:
parent = self
if parent["children"] > 0:
children = parent.get_replies()
if children is None:
return []
for cc in children[:]:
children.extend(self.get_all_replies(parent=cc))
return children
return []
def get_votes(self, raw_data=False):
"""Returns all votes as ActiveVotes object"""
if raw_data:
......
......@@ -38,7 +38,7 @@ class Testcases(unittest.TestCase):
num_retries=10
)
acc = Account("holger80", steem_instance=cls.bts)
comment = acc.get_blog(limit=20)[-1]
comment = acc.get_feed(limit=20)[-1]
cls.authorperm = comment.authorperm
[author, permlink] = resolve_authorperm(cls.authorperm)
cls.author = author
......@@ -63,7 +63,16 @@ class Testcases(unittest.TestCase):
exceptions.ContentDoesNotExistsException
):
Comment("@abcdef/abcdef", steem_instance=bts)
c = Comment(self.authorperm, steem_instance=bts)
title = ''
cnt = 0
while title == '' and cnt < 5:
c = Comment(self.authorperm, steem_instance=bts)
title = c.title
cnt += 1
if title == '':
c.steem.rpc.next()
c.refresh()
title = c.title
self.assertTrue(isinstance(c.id, int))
self.assertTrue(c.id > 0)
self.assertEqual(c.author, self.author)
......@@ -97,8 +106,18 @@ class Testcases(unittest.TestCase):
bts = self.bts
else:
bts = self.appbase
c = Comment({'author': self.author, 'permlink': self.permlink}, steem_instance=bts)
c.refresh()
title = ''
cnt = 0
while title == '' and cnt < 5:
c = Comment({'author': self.author, 'permlink': self.permlink}, steem_instance=bts)
c.refresh()
title = c.title
cnt += 1
if title == '':
c.steem.rpc.next()
c.refresh()
title = c.title
self.assertEqual(c.author, self.author)
self.assertEqual(c.permlink, self.permlink)
self.assertEqual(c.authorperm, self.authorperm)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment