Exemplo n.º 1
0
def test_pinboard_bookmark(session, test_user):
    runner = CliRunner()
    json_path = path.join(test_data_path, "pinboard-bookmark.json")
    result = runner.invoke(
        sut.pinboard_import,
        [str(test_user.user_uuid), json_path],
        catch_exceptions=False,
    )
    assert result.exit_code == 0

    expected_url = sut.URL.from_string(
        "https://mitpress.mit.edu/books/"
        "building-successful-online-communities")
    bookmark = sut.get_bookmark_by_url(sut.db.session, test_user.user_uuid,
                                       expected_url.to_string())
    creation_dt = datetime(2019, 12, 18, 16, 51, 31, tzinfo=timezone.utc)
    assert bookmark == sut.Bookmark(
        url=expected_url,
        title="Building Successful Online Communities | The MIT Press",
        description=
        "<blockquote>How insights from the social sciences, including social psychology and economics, can improve the design of online communities.\n                Online communities are among the most popular destinations on the Internet, but not all online communities are equally successful. For every flourishing Facebook, there is a moribund Friendster—not to mention the scores of smaller social networking sites that never attracted enough members to be viable. This book offers lessons from theory an...",
        created=creation_dt,
        updated=datetime(2018, 1, 3, tzinfo=timezone.utc),
        unread=True,
        deleted=False,
        tag_triples=frozenset((t, creation_dt, False) for t in [
            "mitpress",
            "online",
            "sociology",
        ]),
    )
Exemplo n.º 2
0
def test_pinboard_with_note(session, test_user):
    runner = CliRunner()
    json_path = path.join(test_data_path, "pinboard-note.json")
    result = runner.invoke(
        sut.pinboard_import,
        [str(test_user.user_uuid), json_path],
        catch_exceptions=False,
    )
    assert result.exit_code == 0

    expected_url = sut.URL.from_string(
        "http://notes.pinboard.in/u:calpaterson/abc123")
    bookmark = sut.get_bookmark_by_url(sut.db.session, test_user.user_uuid,
                                       expected_url.to_string())
    creation_dt = datetime(2011, 12, 13, 11, 38, 4, tzinfo=timezone.utc)
    assert bookmark == sut.Bookmark(
        url=expected_url,
        title="Secret Password",
        created=creation_dt,
        description="",
        updated=datetime(2018, 1, 3, tzinfo=timezone.utc),
        unread=False,
        deleted=False,
        tag_triples=frozenset([("london", creation_dt, False)]),
    )
Exemplo n.º 3
0
def test_syncing_with_an_extension_that_doesnt_know_about_tags(
        client, session, test_user):
    """This test checks that syncs from extensions that don't know about tags
    don't clober existing tags."""
    url = sut.URL.from_string("http://example/com/1")
    bm_1 = make_bookmark(url=url, title="Example 1")

    initial_sync = post_bookmarks(client, test_user, [bm_1])
    assert initial_sync.status_code == 200

    bm_1_no_tags = sut.Bookmark(
        url=url,
        title=bm_1.title,
        description=bm_1.description,
        created=bm_1.created,
        updated=bm_1.updated,
        unread=bm_1.unread,
        deleted=bm_1.deleted,
        tag_triples=frozenset(),
    )
    second_sync = post_bookmarks(client, test_user, [bm_1_no_tags])
    assert second_sync.status_code == 200

    end_state = sut.get_bookmark_by_url(session, test_user.user_uuid,
                                        url.to_string())
    assert end_state == bm_1
Exemplo n.º 4
0
def make_bookmark(**kwargs) -> sut.Bookmark:
    epoch_start = datetime(1970, 1, 1, tzinfo=timezone.utc)
    bookmark_defaults: Mapping[str, Any] = {
        "url": random_url(),  # FIXME: random_url()
        "title": "Example",
        "created": epoch_start,
        "updated": epoch_start,
        "description": "An example bookmark",
        "unread": False,
        "deleted": False,
        "tag_triples": frozenset([("test", epoch_start, False)]),
    }
    return sut.Bookmark(**{**bookmark_defaults, **kwargs})