示例#1
0
def test_saving(fix_requests, fix_input):
    from campbot import CampBot

    fix_input.set_response(lambda x: "y")

    area = CampBot().wiki.get_area(area_id=14273)
    area.save("Test")
示例#2
0
def test_wiki(fix_requests, fix_input):
    from campbot import CampBot

    fix_input.set_response(lambda x: "y")

    route = CampBot().wiki.get_route(route_id=293549)
    route.is_personal()
    route.get_title("fr")

    xreport = CampBot().wiki.get_xreport(xreport_id=293549)
    xreport.is_personal()

    image = CampBot().wiki.get_image(image_id=1005116)
    image.is_personal()

    waypoint = CampBot().wiki.get_waypoint(waypoint_id=952999)
    waypoint.get_invalidity_reason()

    article = CampBot().wiki.get_article(article_id=1003911)
    article.is_personal()

    area = CampBot().wiki.get_area(area_id=14273)
    area.save("Test")

    CampBot().wiki.get_profile(profile_id=293549)
    CampBot().wiki.get_book(book_id=293549)
    CampBot().wiki.get_map(map_id=293549)

    list(CampBot().wiki.get_routes({}))
    list(CampBot().wiki.get_waypoints({}))
    list(CampBot().wiki.get_outings({}))
    list(CampBot().wiki.get_xreports({}))

    for _ in CampBot().wiki.get_route_ids():
        break

    for _ in CampBot().wiki.get_xreport_ids():
        break

    for _ in CampBot().wiki.get_document_ids(document_type="r"):
        break

    for _ in CampBot().wiki.get_documents(document_type="r"):
        break

    assert CampBot().wiki.ui_url == "https://www.camptocamp.org"

    version = CampBot().wiki.get_wiki_object_version(293549, "r", "fr",
                                                     1738922)
    assert version.get_diff_url("fr") is not None
    assert version.get_locale_length("fr") != 0

    CampBot().wiki.get_wiki_object_version(None, "", "", None)

    version = CampBot().wiki.get_wiki_object_version(293549, "r", "fr",
                                                     1738922)
    version.previous_version_id = None
    assert version.get_diff_url("fr") is not None

    route = CampBot().wiki.get_wiki_object(item_id=293549, document_type="r")
    assert route.get_url() == "https://www.camptocamp.org/routes/293549"
    assert (route.get_history_url("fr") ==
            "https://www.camptocamp.org/routes/history/293549/fr")

    CampBot().wiki.get_contributions(oldest_date="2017-12-12",
                                     newest_date="2017-12-13")

    with pytest.raises(Exception):
        CampBot().wiki.get_user(forum_name="unknown")

    user = CampBot().wiki.get_user(forum_name="CharlesB")
    user.is_personal()
    user.save("test", ask_before_saving=False)

    contrib = user.get_last_contribution()
    contrib.get_full_document()
    contrib.user.get_wiki_user()
    contrib.user.is_newbie()
    contrib.user.get_contributions_url()