diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1133812a3a5c552f1a6caadc27804c18e33ce2b4..c3bf17f4246faad9bf58cfee1522ad9de5f20fcb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,5 +1,13 @@ Changelog ========= +0.24.12 +------- +* Fix beempy witnessfeed for HF24 +* Fix more hbd renaming in beempy +* improved RankedPosts class +* New AccountPosts class for account feed and more +* Comment class has been cleaned up, use_tags_api has been replaced by api + 0.24.11 ------- * assumes that a rpc server uses appbase diff --git a/beem/account.py b/beem/account.py index f8bc8aa3d6cd65beb26e958e485136f46475b3f6..a54156d1321340086303d374391709fb4559ce9d 100644 --- a/beem/account.py +++ b/beem/account.py @@ -1132,7 +1132,7 @@ class Account(BlockchainObject): self.blockchain.rpc.set_next_node_on_empty_reply(True) return self.blockchain.rpc.list_all_subscriptions({'account': account}, api='bridge') - def get_account_posts(self, sort="feed", account=None, observer=None, raw_data=False): + def get_account_posts(self, sort="feed", limit=20, account=None, observer=None, raw_data=False): """Returns account feed""" if account is None: account = self["name"] @@ -1142,16 +1142,8 @@ class Account(BlockchainObject): observer = account if not self.blockchain.is_connected(): raise OfflineHasNoRPCException("No RPC available in offline mode!") - self.blockchain.rpc.set_next_node_on_empty_reply(True) - posts = self.blockchain.rpc.get_account_posts({'sort': sort, 'account': account, - 'observer': observer}, api='bridge') - if raw_data: - return posts - comments = [] - from .comment import Comment - for post in posts: - comments.append(Comment(post, blockchain_instance=self.blockchain)) - return comments + from beem.comment import AccountPosts + return AccountPosts(sort, account, observer=observer, limit=limit, raw_data=raw_data) @property def available_balances(self): diff --git a/beem/cli.py b/beem/cli.py index 44e56083dd33f7cb44e2d5562df4d070469b05b6..ec19930d1a6cba4fd3b6346032de496cb5c7b81c 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -3092,8 +3092,9 @@ def stream(lines, head, table, follow): return @cli.command() -@click.option('--sbd-to-steem', '-i', help='Show ticker in SBD/STEEM', is_flag=True, default=False) -def ticker(sbd_to_steem): +@click.option('--sbd-to-steem', help='Show ticker in SBD/STEEM', is_flag=True, default=False) +@click.option('--hbd-to-hive', '-i', help='Show ticker in HBD/HIVE', is_flag=True, default=False) +def ticker(sbd_to_steem, hbd_to_hive): """ Show ticker """ stm = shared_blockchain_instance() @@ -3104,9 +3105,9 @@ def ticker(sbd_to_steem): market = Market(blockchain_instance=stm) ticker = market.ticker() for key in ticker: - if key in ["highest_bid", "latest", "lowest_ask"] and sbd_to_steem: + if key in ["highest_bid", "latest", "lowest_ask"] and (sbd_to_steem or hbd_to_hive): t.add_row([key, str(ticker[key].as_base(stm.backed_token_symbol))]) - elif key in "percent_change" and sbd_to_steem: + elif key in "percent_change" and (sbd_to_steem or hbd_to_hive): t.add_row([key, "%.2f %%" % -ticker[key]]) elif key in "percent_change": t.add_row([key, "%.2f %%" % ticker[key]]) @@ -3153,12 +3154,13 @@ def pricehistory(width, height, ascii): @cli.command() @click.option('--days', '-d', help='Limit the days of shown trade history (default 7)', default=7.) @click.option('--hours', help='Limit the intervall history intervall (default 2 hours)', default=2.0) -@click.option('--sbd-to-steem', '-i', help='Show ticker in SBD/STEEM', is_flag=True, default=False) +@click.option('--sbd-to-steem', help='Show ticker in SBD/STEEM', is_flag=True, default=False) +@click.option('--hbd-to-hive', '-i', help='Show ticker in HBD/HIVE', is_flag=True, default=False) @click.option('--limit', '-l', help='Limit number of trades which is fetched at each intervall point (default 100)', default=100) @click.option('--width', '-w', help='Plot width (default 75)', default=75) @click.option('--height', '-h', help='Plot height (default 15)', default=15) @click.option('--ascii', help='Use only ascii symbols', is_flag=True, default=False) -def tradehistory(days, hours, sbd_to_steem, limit, width, height, ascii): +def tradehistory(days, hours, sbd_to_steem, hbd_to_hive, limit, width, height, ascii): """ Show price history """ stm = shared_blockchain_instance() @@ -3171,7 +3173,7 @@ def tradehistory(days, hours, sbd_to_steem, limit, width, height, ascii): intervall = timedelta(hours=hours) trades = m.trade_history(start=start, stop=stop, limit=limit, intervall=intervall) price = [] - if sbd_to_steem: + if sbd_to_steem or hbd_to_hive: base_str = stm.token_symbol else: base_str = stm.backed_token_symbol @@ -3187,7 +3189,7 @@ def tradehistory(days, hours, sbd_to_steem, limit, width, height, ascii): else: charset = u'utf8' chart = AsciiChart(height=height, width=width, offset=3, placeholder='{:6.2f} ', charset=charset) - if sbd_to_steem: + if sbd_to_steem or hbd_to_hive: print("\n Trade history %s - %s \n\n%s/%s" % (formatTimeString(start), formatTimeString(stop), stm.backed_token_symbol, stm.token_symbol)) else: @@ -3641,23 +3643,35 @@ def witnessenable(witness, signing_key, export): @click.option('--maximum_block_size', help='Max block size', default=65536) @click.option('--account_creation_fee', help='Account creation fee', default=0.1) @click.option('--sbd_interest_rate', help='SBD interest rate in percent', default=0.0) +@click.option('--hbd_interest_rate', help='HBD interest rate in percent', default=0.0) @click.option('--url', help='Witness URL', default="") @click.option('--export', '-e', help='When set, transaction is stored in a file') -def witnesscreate(witness, pub_signing_key, maximum_block_size, account_creation_fee, sbd_interest_rate, url, export): +def witnesscreate(witness, pub_signing_key, maximum_block_size, account_creation_fee, sbd_interest_rate, hbd_interest_rate, url, export): """Create a witness""" stm = shared_blockchain_instance() if stm.rpc is not None: stm.rpc.rpcconnect() if not unlock_wallet(stm): return - props = { - "account_creation_fee": - Amount("%.3f %s" % (float(account_creation_fee), stm.token_symbol), blockchain_instance=stm), - "maximum_block_size": - int(maximum_block_size), - "sbd_interest_rate": - int(sbd_interest_rate * 100) - } + if stm.is_hive and stm.hardfork >= 24: + + props = { + "account_creation_fee": + Amount("%.3f %s" % (float(account_creation_fee), stm.token_symbol), blockchain_instance=stm), + "maximum_block_size": + int(maximum_block_size), + "hbd_interest_rate": + int(hbd_interest_rate * 100) + } + else: + props = { + "account_creation_fee": + Amount("%.3f %s" % (float(account_creation_fee), stm.token_symbol), blockchain_instance=stm), + "maximum_block_size": + int(maximum_block_size), + "sbd_interest_rate": + int(sbd_interest_rate * 100) + } tx = stm.witness_update(pub_signing_key, url, props, account=witness) if stm.unsigned and stm.nobroadcast and stm.steemconnect is not None: @@ -3730,9 +3744,17 @@ def witnessfeed(witness, wif, base, quote, support_peg): return witness = Witness(witness, blockchain_instance=stm) market = Market(blockchain_instance=stm) - old_base = witness["sbd_exchange_rate"]["base"] - old_quote = witness["sbd_exchange_rate"]["quote"] - last_published_price = Price(witness["sbd_exchange_rate"], blockchain_instance=stm) + use_hbd = False + if "hbd_exchange_rate" in witness: + use_hbd = True + old_base = witness["hbd_exchange_rate"]["base"] + old_quote = witness["hbd_exchange_rate"]["quote"] + last_published_price = Price(witness["hbd_exchange_rate"], blockchain_instance=stm) + else: + old_base = witness["sbd_exchange_rate"]["base"] + old_quote = witness["sbd_exchange_rate"]["quote"] + last_published_price = Price(witness["sbd_exchange_rate"], blockchain_instance=stm) + steem_usd = None hive_usd = None print("Old price %.3f (base: %s, quote %s)" % (float(last_published_price), old_base, old_quote)) @@ -3770,9 +3792,12 @@ def witnessfeed(witness, wif, base, quote, support_peg): base = Amount(base, stm.backed_token_symbol, blockchain_instance=stm) new_price = Price(base=base, quote=quote, blockchain_instance=stm) print("New price %.3f (base: %s, quote %s)" % (float(new_price), base, quote)) - if wif is not None: - props = {"sbd_exchange_rate": new_price} + if wif is not None and use_hbd: + props = {"hbd_exchange_rate": new_price} tx = stm.witness_set_properties(wif, witness["owner"], props) + elif wif is not None: + props = {"sbd_exchange_rate": new_price} + tx = stm.witness_set_properties(wif, witness["owner"], props) else: tx = witness.feed_publish(base, quote=quote) if stm.unsigned and stm.nobroadcast and stm.steemconnect is not None: diff --git a/beem/comment.py b/beem/comment.py index ba70ed07b6f9439bd37af59b0c0a0f6c29f558b3..f16775ae941a48ea3709cc7080fd593884d54840 100644 --- a/beem/comment.py +++ b/beem/comment.py @@ -4,6 +4,7 @@ import re import logging import pytz import math +import warnings from datetime import datetime, date, time from .instance import shared_blockchain_instance from .account import Account @@ -23,8 +24,8 @@ class Comment(BlockchainObject): :param str authorperm: identifier to post/comment in the form of ``@author/permlink`` - :param boolean use_tags_api: when set to False, list_comments from the database_api is used - :param Steem blockchain_instance: :class:`beem.steem.Steem` instance to use when accessing a RPC + :param str tags: defines which api is used. Can be bridge, tags, condenser or database (default = bridge) + :param Hive blockchain_instance: :class:`beem.hive.Steem` instance to use when accessing a RPC .. code-block:: python @@ -45,7 +46,8 @@ class Comment(BlockchainObject): def __init__( self, authorperm, - use_tags_api=True, + api="bridge", + observer="", full=True, lazy=False, blockchain_instance=None, @@ -53,7 +55,8 @@ class Comment(BlockchainObject): ): self.full = full self.lazy = lazy - self.use_tags_api = use_tags_api + self.api = api + self.observer = observer if blockchain_instance is None: if kwargs.get("steem_instance"): blockchain_instance = kwargs["steem_instance"] @@ -153,28 +156,24 @@ class Comment(BlockchainObject): [author, permlink] = resolve_authorperm(self.identifier) self.blockchain.rpc.set_next_node_on_empty_reply(True) if self.blockchain.rpc.get_use_appbase(): + from beemapi.exceptions import InvalidParameters try: - if self.use_tags_api: + if self.api == "tags": content = self.blockchain.rpc.get_discussion({'author': author, 'permlink': permlink}, api="tags") - else: + elif self.api == "database": content =self.blockchain.rpc.list_comments({"start": [author, permlink], "limit": 1, "order": "by_permlink"}, api="database") + elif self.api == "bridge": + content = self.blockchain.rpc.get_post({"author": author, "permlink": permlink, "observer": self.observer}, api="bridge") + elif self.api == "condenser": + content = self.blockchain.rpc.get_content(author, permlink, api="condenser") + else: + raise ValueError("api must be: tags, database, bridge or condenser") if content is not None and "comments" in content: content =content["comments"] if isinstance(content, list) and len(content) >0: content =content[0] - except: - if self.blockchain.config["use_condenser"]: - from beemapi.exceptions import InvalidParameters - try: - content = self.blockchain.rpc.get_content(author, permlink) - except InvalidParameters: - raise ContentDoesNotExistsException(self.identifier) - else: - content =self.blockchain.rpc.find_comments({"start": [author, permlink], "limit": 1, "order": "by_permlink"}, api="database") - if content is not None and "comments" in content: - content =content["comments"] - if isinstance(content, list) and len(content) >0: - content =content[0] + except InvalidParameters: + raise ContentDoesNotExistsException(self.identifier) else: from beemapi.exceptions import InvalidParameters try: @@ -858,6 +857,8 @@ class RecentReplies(list): account = Account(author, blockchain_instance=self.blockchain) replies = account.get_account_posts(sort="replies", raw_data=True) comments = [] + if replies is None: + replies = [] for post in replies: if skip_own and post["author"] == author: continue @@ -866,12 +867,28 @@ class RecentReplies(list): class RecentByPath(list): - """ Obtain a list of posts recent by path + """ Obtain a list of posts recent by path, does the same as RankedPosts :param str account: Account name :param Steem blockchain_instance: Steem() instance to use when accesing a RPC """ def __init__(self, path="trending", category=None, lazy=False, full=True, blockchain_instance=None, **kwargs): + + super(RecentByPath, self).__init__(RankedPosts(sort=path, tag=category)) + + +class RankedPosts(list): + """ Obtain a list of ranked posts + + :param str sort: can be: trending, hot, muted, created + :param str tag: tag, when used my, the community posts of the observer are shown + :param str observer: Observer name + :param int limit: limits the number of returns comments + :param str start_author: start author + :param str start_permlink: start permlink + :param Steem blockchain_instance: Steem() instance to use when accesing a RPC + """ + def __init__(self, sort="trending", tag="", observer="", limit=21, start_author="", start_permlink="", lazy=False, full=True, raw_data=False, blockchain_instance=None, **kwargs): if blockchain_instance is None: if kwargs.get("steem_instance"): blockchain_instance = kwargs["steem_instance"] @@ -880,26 +897,46 @@ class RecentByPath(list): self.blockchain = blockchain_instance or shared_blockchain_instance() if not self.blockchain.is_connected(): return None - self.blockchain.rpc.set_next_node_on_empty_reply(True) - state = self.blockchain.rpc.get_state("/" + path) - if state == '' or state is None or len(state["discussion_idx"]) == 0: - return None - replies = state["discussion_idx"][''].get(path, []) comments = [] - for reply in replies: - post = state["content"][reply] - if category is None or (category is not None and post["category"] == category): - comments.append(Comment(post, lazy=lazy, full=full, blockchain_instance=self.blockchain)) - super(RecentByPath, self).__init__(comments) + api_limit = limit + if api_limit > 100: + api_limit = 100 + last_n = -1 + while len(comments) < limit and last_n != len(comments): + last_n = len(comments) + self.blockchain.rpc.set_next_node_on_empty_reply(True) + posts = self.blockchain.rpc.get_ranked_posts({"sort": sort, "tag": tag, "observer": observer, + "limit": api_limit, "start_author": start_author, + "start_permlink": start_permlink}, api="bridge") + + for post in posts: + if len(comments) > 0 and comments[-1]["author"] == post["author"] and comments[-1]["permlink"] == post["permlink"]: + continue + if len(comments) >= limit: + continue + if raw_data: + comments.append(post) + else: + comments.append(Comment(post, lazy=lazy, full=full, blockchain_instance=self.blockchain)) + start_author = comments[-1]["author"] + start_permlink = comments[-1]["permlink"] + if limit - len(comments) < 100: + api_limit = limit - len(comments) + 1 + super(RankedPosts, self).__init__(comments) -class RankedPosts(list): - """ Obtain a list of ranked posts +class AccountPosts(list): + """ Obtain a list of account related posts + :param str sort: can be: comments, posts, blog, replies, feed :param str account: Account name - :param Steem blockchain_instance: Steem() instance to use when accesing a RPC + :param str observer: Observer name + :param int limit: limits the number of returns comments + :param str start_author: start author + :param str start_permlink: start permlink + :param Hive blockchain_instance: Hive() instance to use when accesing a RPC """ - def __init__(self, sort="trending", tag="", observer="", lazy=False, full=True, blockchain_instance=None, **kwargs): + def __init__(self, sort, account, observer="", limit=20, start_author="", start_permlink="", lazy=False, full=True, raw_data=False, blockchain_instance=None, **kwargs): if blockchain_instance is None: if kwargs.get("steem_instance"): blockchain_instance = kwargs["steem_instance"] @@ -908,9 +945,28 @@ class RankedPosts(list): self.blockchain = blockchain_instance or shared_blockchain_instance() if not self.blockchain.is_connected(): return None - self.blockchain.rpc.set_next_node_on_empty_reply(True) - posts = self.blockchain.rpc.get_ranked_posts({"sort": sort, "tag": tag, "observer": observer}, api="bridge") comments = [] - for post in posts: - comments.append(Comment(post, lazy=lazy, full=full, blockchain_instance=self.blockchain)) - super(RankedPosts, self).__init__(comments) + api_limit = limit + if api_limit > 100: + api_limit = 100 + last_n = -1 + while len(comments) < limit and last_n != len(comments): + last_n = len(comments) + self.blockchain.rpc.set_next_node_on_empty_reply(True) + posts = self.blockchain.rpc.get_account_posts({"sort": sort, "account": account, "observer": observer, + "limit": api_limit, "start_author": start_author, + "start_permlink": start_permlink}, api="bridge") + for post in posts: + if len(comments) > 0 and comments[-1]["author"] == post["author"] and comments[-1]["permlink"] == post["permlink"]: + continue + if len(comments) >= limit: + continue + if raw_data: + comments.append(post) + else: + comments.append(Comment(post, lazy=lazy, full=full, blockchain_instance=self.blockchain)) + start_author = comments[-1]["author"] + start_permlink = comments[-1]["permlink"] + if limit - len(comments) < 100: + api_limit = limit - len(comments) + 1 + super(AccountPosts, self).__init__(comments) \ No newline at end of file diff --git a/beem/discussions.py b/beem/discussions.py index 7f6855b3d155fd8dc59623cf65e8878eb6e81800..1a4f196e10508933b647179df7dcec045cd3372f 100644 --- a/beem/discussions.py +++ b/beem/discussions.py @@ -222,7 +222,9 @@ class Discussions_by_trending(list): if self.blockchain.rpc.get_use_appbase() and use_appbase: posts = self.blockchain.rpc.get_discussions_by_trending(reduced_query, api="tags")['discussions'] if len(posts) == 0: - posts = self.blockchain.rpc.get_discussions_by_trending(reduced_query) + posts = self.blockchain.rpc.get_discussions_by_trending(reduced_query, api="condenser") + if posts is None: + posts = [] if raw_data: super(Discussions_by_trending, self).__init__( [ diff --git a/beem/version.py b/beem/version.py index e8ff34b8027df4cd00b411ed54d19a0ae825c5d7..b2417fa41b70582f74def03e42e0b2d38d261c1c 100644 --- a/beem/version.py +++ b/beem/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.11' +version = '0.24.12' diff --git a/beem/vote.py b/beem/vote.py index 7688c603530dd2512276a4b990438e02971020e9..722eba25d4dee35cb8aafc97751a5e3592473e2a 100644 --- a/beem/vote.py +++ b/beem/vote.py @@ -104,11 +104,11 @@ class Vote(BlockchainObject): except: from beemapi.exceptions import InvalidParameters try: - votes = self.blockchain.rpc.get_active_votes(author, permlink, api="database_api") + votes = self.blockchain.rpc.get_active_votes(author, permlink, api="condenser") except InvalidParameters: raise VoteDoesNotExistsException(self.identifier) else: - votes = self.blockchain.rpc.get_active_votes(author, permlink, api="database_api") + votes = self.blockchain.rpc.get_active_votes(author, permlink, api="condenser") except UnkownKey: raise VoteDoesNotExistsException(self.identifier) @@ -392,7 +392,7 @@ class ActiveVotes(VotesObject): 'permlink': authorperm["permlink"]}, api="tags")['votes'] else: - votes = self.blockchain.rpc.get_active_votes(authorperm["author"], authorperm["permlink"]) + votes = self.blockchain.rpc.get_active_votes(authorperm["author"], authorperm["permlink"], api="condenser") authorperm = authorperm["authorperm"] elif isinstance(authorperm, string_types): [author, permlink] = resolve_authorperm(authorperm) @@ -408,7 +408,7 @@ class ActiveVotes(VotesObject): 'permlink': permlink}, api="tags")['votes'] else: - votes = self.blockchain.rpc.get_active_votes(author, permlink) + votes = self.blockchain.rpc.get_active_votes(author, permlink, api="condenser") elif isinstance(authorperm, list): votes = authorperm authorperm = None diff --git a/beemapi/version.py b/beemapi/version.py index e8ff34b8027df4cd00b411ed54d19a0ae825c5d7..b2417fa41b70582f74def03e42e0b2d38d261c1c 100644 --- a/beemapi/version.py +++ b/beemapi/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.11' +version = '0.24.12' diff --git a/beembase/version.py b/beembase/version.py index e8ff34b8027df4cd00b411ed54d19a0ae825c5d7..b2417fa41b70582f74def03e42e0b2d38d261c1c 100644 --- a/beembase/version.py +++ b/beembase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.11' +version = '0.24.12' diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py index e8ff34b8027df4cd00b411ed54d19a0ae825c5d7..b2417fa41b70582f74def03e42e0b2d38d261c1c 100644 --- a/beemgraphenebase/version.py +++ b/beemgraphenebase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.24.11' +version = '0.24.12' diff --git a/setup.py b/setup.py index 08d7c4a9e8dad45da4c20d73c42983ea698251b5..35dfbb31ec3a97adceb9688c229678b6628dd50d 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ except LookupError: ascii = codecs.lookup('ascii') codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')) -VERSION = '0.24.11' +VERSION = '0.24.12' tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized'] diff --git a/tests/beem/test_comment.py b/tests/beem/test_comment.py index df1537f2695d867367efdb24388e19d20ac49d86..b6b892bc4a8f000bc9d82fcab9ade4443d682c07 100644 --- a/tests/beem/test_comment.py +++ b/tests/beem/test_comment.py @@ -3,7 +3,7 @@ import unittest from parameterized import parameterized from pprint import pprint from beem import Hive, exceptions -from beem.comment import Comment, RecentReplies, RecentByPath, RankedPosts +from beem.comment import Comment, RecentReplies, RecentByPath, RankedPosts, AccountPosts from beem.vote import Vote from beem.account import Account from beem.instance import set_shared_blockchain_instance @@ -40,12 +40,19 @@ class Testcases(unittest.TestCase): # set_shared_blockchain_instance(cls.bts) # cls.bts.set_default_account("test") - def test_comment(self): + @parameterized.expand([ + ("bridge"), + ("tags"), + ("condenser"), + ("database") + ]) + def test_comment(self, api): bts = self.bts with self.assertRaises( exceptions.ContentDoesNotExistsException ): - Comment("@abcdef/abcdef", blockchain_instance=bts) + Comment("@abcdef/abcdef", api=api, blockchain_instance=bts) + title = '' cnt = 0 while title == '' and cnt < 5: @@ -78,12 +85,18 @@ class Testcases(unittest.TestCase): self.assertTrue(len(votes) > 0) self.assertTrue(isinstance(votes[0], Vote)) - def test_comment_dict(self): + @parameterized.expand([ + ("bridge"), + ("tags"), + ("condenser"), + ("database") + ]) + def test_comment_dict(self, api): bts = self.bts title = '' cnt = 0 while title == '' and cnt < 5: - c = Comment({'author': self.author, 'permlink': self.permlink}, blockchain_instance=bts) + c = Comment({'author': self.author, 'permlink': self.permlink}, api=api, blockchain_instance=bts) c.refresh() title = c.title cnt += 1 @@ -131,7 +144,13 @@ class Testcases(unittest.TestCase): op = tx["operations"][0][1] self.assertEqual(op["weight"], -9990) - def test_export(self): + @parameterized.expand([ + ("bridge"), + ("tags"), + ("condenser"), + ("database") + ]) + def test_export(self, api): bts = self.bts if bts.rpc.get_use_appbase(): @@ -139,7 +158,7 @@ class Testcases(unittest.TestCase): else: content = bts.rpc.get_content(self.author, self.permlink) - c = Comment(self.authorperm, blockchain_instance=bts) + c = Comment(self.authorperm, api=api, blockchain_instance=bts) keys = list(content.keys()) json_content = c.json() exclude_list = ["json_metadata", "reputation", "active_votes", "net_rshares", "author_reputation"] @@ -234,6 +253,19 @@ class Testcases(unittest.TestCase): def test_ranked_posts(self): bts = self.bts - r = RankedPosts(sort="trending", blockchain_instance=bts) - self.assertTrue(len(r) > 0) + r = RankedPosts(sort="trending", limit=102, blockchain_instance=bts) + self.assertTrue(len(r) == 102) + self.assertTrue(r[0] is not None) + + r = RankedPosts(sort="trending", limit=102, raw_data=True, blockchain_instance=bts) + self.assertTrue(len(r) == 102) + self.assertTrue(r[0] is not None) + + def test_account_posts(self): + bts = self.bts + r = AccountPosts("feed", "holger80", limit=102, blockchain_instance=bts) + self.assertTrue(len(r) == 102) self.assertTrue(r[0] is not None) + + r = AccountPosts("feed", "holger80", limit=102, raw_data=True, blockchain_instance=bts) + self.assertTrue(len(r) == 102) \ No newline at end of file