def test_validate_get_content( wallet: Wallet, post_with_multilvl_comments, initdelegate_post, bob_comment_lv1, alice_comment_lv2 ): for post in post_with_multilvl_comments: validate_response(wallet.post_comment(**post), wallet.post_comment.__name__) time_config = wallet.get_config() def validate_cashout_interval(comment: dict): date_start = to_date(comment['created']) date_finish = to_date(comment['cashout_time']) delta = date_finish - date_start cashout_window = int(time_config["SCORUM_CASHOUT_WINDOW_SECONDS"]) assert delta.total_seconds() == cashout_window def validate_url(comment: dict): if comment['parent_author']: assert comment['url'] == '/{category}/@{root_author}/{root_permlink}#@{author}/{permlink}' \ .format(category=comment['category'], root_author=post['author'], root_permlink=post['permlink'], author=comment['author'], permlink=comment['permlink']) else: assert comment['url'] == '/{}/@{}/{}'.format(comment['category'], comment['author'], comment['permlink']) def validate_content(comment, comment_kwargs, parent=None): for key, value in comment_kwargs.items(): assert comment[key] == value, '{} value differs from expected'.format(key) assert comment['category'] == initdelegate_post['parent_permlink'] expected_depth = parent['depth'] + 1 if parent else 0 assert comment['depth'] == expected_depth assert comment['root_title'] == initdelegate_post['title'] assert comment['root_comment'] == post['id'] validate_cashout_interval(comment) validate_url(comment) post = wallet.get_content(initdelegate_post['author'], initdelegate_post['permlink']) validate_content(post, initdelegate_post) comment_level_1 = wallet.get_content(bob_comment_lv1['author'], bob_comment_lv1['permlink']) validate_content(comment_level_1, bob_comment_lv1, post) comment_level_2 = wallet.get_content(alice_comment_lv2['author'], alice_comment_lv2['permlink']) validate_content(comment_level_2, alice_comment_lv2, comment_level_1)
def test_get_parents(wallet: Wallet, posts): for post in posts: wallet.post_comment(**post) content = wallet.get_content(post["author"], post["permlink"]) parents = wallet.get_parents(**{ "author": post["author"], "permlink": post["permlink"] }) validate_response(parents, wallet.get_parents.__name__) assert len(parents) == content["depth"] current = post for parent in parents: assert current["parent_permlink"] == parent["permlink"] current = parent
def test_get_content(wallet: Wallet, posts): for post in posts: wallet.post_comment(**post) validate_response(wallet.get_content(post['author'], post['permlink']), wallet.get_content.__name__)