def test_links_delete_post(client, onelink): id = ObjectId("5b92b2cd5e378f694898087a") create_link(_id=ObjectId(id), **onelink) res = client.post(f"/links/delete/{id}/") assert res.status_code == 302 assert not get_db().links.find_one({"_id": id})
def test_create_link_on_make_a_copy(app, onelink, monkeypatch, mock_make_copy): onelink["make_a_copy"] = True monkeypatch.setattr("firefly.links.make_copy_of_url", mock_make_copy) create_link(**onelink) assert mock_make_copy.url == onelink["url"] assert mock_make_copy.link_id
def test_create_link_doesnt_put_pdf_prefix_if_disabled_in_prefs(app, onelink): # this creates a default preferences get_preferences() update_preferences(prepend_pdf_in_title=False) onelink["url"] = "https://example.com/sample.pdf" create_link(**onelink) fetched = list(get_db().links.find())[0] assert not fetched["title"].startswith("[PDF] ")
def test_links_update_post(client, onelink): id = ObjectId("5b92b2cd5e378f694898087d") create_link(_id=ObjectId(id), **onelink) onelink["url"] = "https://google.com/asdf/" res = client.post(f"/links/update/{id}/", data=onelink) assert res.status_code == 302 fetched = get_db().links.find_one({"_id": id}) assert fetched["url"] == "https://google.com/asdf/"
def test_create_link_puts_url_in_if_title_is_not_provided(app, onelink): onelink.pop("title") create_link(**onelink) fetched = list(get_db().links.find())[0] assert fetched["title"] == onelink["url"]
def test_create_link(app, onelink): create_link(**onelink) fetched = list(get_db().links.find())[0] assert "csrf_token" not in fetched, "should exclude csrf_token" assert "created_at" in fetched, "should add created_at"
def test_links_delete_get_with_valid_id(client, onelink): id = ObjectId("5b92b2cd5e378f694898087a") create_link(_id=ObjectId(id), **onelink) res = client.get(f"/links/delete/{id}/") assert res.status_code == 200
def test_delete_link(client, onelink): id = ObjectId("5b92b2cd5e378f694898087a") create_link(_id=ObjectId(id), **onelink) res = delete_link(id) assert res.deleted_count == 1
def test_links_update_get_valid_url(client, onelink): id = ObjectId("5b92b2cd5e378f694898087c") create_link(_id=ObjectId(id), **onelink) res = client.get(f"/links/update/{id}/") assert res.status_code == 200