예제 #1
0
def test_follow_user():
    follower = "follower_id"
    followee = "followee_id"
    f.write_document("users", follower, {"following_users": ["some_id"]})
    assert d.follow_user(follower, followee)
    assert followee in d.get_user(follower).get("following_users")
    assert len(d.get_user(follower).get("following_users")) == 2
예제 #2
0
def register_user_invite(invite_id: str, user_id: str, nickname: str) -> None:
    """
    Register an user on a specific invite.
    """
    log.info("Register user %s (%s) on invite %s", user_id, nickname,
             invite_id)
    f.update_document(
        INVITE_COLLECTION,
        invite_id,
        {
            "register_user": user_id,
            "register_nick": nickname,
            "register_date": f.SERVER_TIMESTAMP,
        },
    )
    inviter_id = f.get_document(INVITE_COLLECTION, invite_id)["user"]
    d.follow_user(inviter_id, user_id)
예제 #3
0
def test_follow_user__no_array():
    follower = "follower_id"
    followee = "followee_id"
    f.write_document("users", follower, {"some_data": "data"})
    assert d.follow_user(follower, followee)
    assert followee in d.get_user(follower).get("following_users")
예제 #4
0
def test_follow_user__not_found():
    try:
        d.follow_user("follower_id", "followee_id")
    except ValueError:
        pass  # expected