Beispiel #1
0
def test_get_discussions_by_created_exclude_tags(wallet: Wallet, by_tags,
                                                 exclude_tags, expected_cnt,
                                                 only_posts):
    for post in only_posts:
        wallet.post_comment(**post)

    posts = wallet.get_discussions_by(
        "created", **{
            "tags": by_tags,
            "limit": 100,
            "tags_logical_and": False,
            "exclude_tags": exclude_tags
        })
    validate_response(posts, wallet.get_discussions_by.__name__)
    assert len(posts) == expected_cnt
    for post in posts:
        tags = set(json.loads(post["json_metadata"])["tags"])
        assert not tags.intersection(set(exclude_tags))
Beispiel #2
0
def test_get_discussions_by_created(wallet: Wallet, alice_post, bob_post):
    validate_response(wallet.post_comment(**alice_post),
                      wallet.post_comment.__name__)
    validate_response(wallet.post_comment(**bob_post),
                      wallet.post_comment.__name__)

    posts = wallet.get_discussions_by(
        "created", **{
            "tags": ["hockey", "football"],
            "limit": 100,
            "tags_logical_and": False
        })
    validate_response(posts, wallet.get_discussions_by.__name__)
    assert len(posts) == 2
    # check that returned latest created post
    assert posts[0]["permlink"] == "bob-post" and posts[0]["author"] == "bob", \
        "Posts were not created in correct order"
    assert posts[1]["permlink"] == "alice-post" and posts[1]["author"] == "alice", \
        "Posts were not created in correct order"
Beispiel #3
0
def test_get_discussions_by_created_same_block(wallet: Wallet, node: Node,
                                               alice_post, bob_post):
    posts = [alice_post, bob_post]
    wallet.get_block(2, wait_for_block=True)
    # ugly workaround to create posts within same block
    result = parallel_create_posts(posts, node)
    assert 'error' not in result[0], "creation alice_post failed"
    assert 'error' not in result[1], "creation bob_post failed"
    assert result[0]["block_num"] == result[1][
        "block_num"], "posts are not created in single block"

    posts = wallet.get_discussions_by(
        "created", **{
            "tags": ["hockey", "football"],
            "limit": 100,
            "tags_logical_and": False
        })
    assert len(posts) == 2
    # check that returned latest created post
    # as id increments after creation, so latest post should have higher id num
    assert posts[0]["id"] > posts[1][
        "id"], "Posts were not created in correct order"
Beispiel #4
0
def test_get_discussions_by_author_order(wallet: Wallet, initdelegate_post):
    permlinks = ["initdelegate-post-%d" % i for i in range(1, 5)]

    post_creation_interval = int(
        int(wallet.get_config()["SCORUM_MIN_ROOT_COMMENT_INTERVAL"]) / 1000000)
    for permlink in permlinks:
        initdelegate_post["permlink"] = permlink
        res = wallet.post_comment(**initdelegate_post)
        validate_response(res, wallet.post_comment.__name__)
        if permlink != permlinks[-1]:
            time.sleep(post_creation_interval)  # 5 min for each post on prod

    discussions = wallet.get_discussions_by(
        "author", **{
            "start_author": DEFAULT_WITNESS,
            "limit": len(permlinks)
        })
    validate_response(discussions, "get_discussions_by_author")
    total_posts = len(permlinks)
    for current in range(0, total_posts):
        opposite = total_posts - current - 1
        assert permlinks[current] == discussions[opposite]["permlink"], \
            "Broken posts order, Post %d should be on %d position." % (current, opposite)