"""The "shared with you" notice carries the download's title in its data, so the client can name the notice in the reader's language. Its stored title is an English sentence ("Cats was shared with you") — the only place the title lived, so a Hungarian reader got the English. Needs the DB.""" from sqlalchemy import select from app.models import DownloadJob, MediaAsset, Notification def test_a_share_notice_carries_the_title_and_the_sharer(db, make_user, as_user): owner = make_user("owner@example.com") friend = make_user("friend@example.com") asset = MediaAsset( source_kind="url", source_ref="share-e30", format_sig="sig", status="ready", ref_count=1 ) db.add(asset) db.flush() job = DownloadJob( user_id=owner.id, asset_id=asset.id, source_kind="url", source_ref="share-e30", status="done", queue_pos=1, profile_snapshot={}, display_name="Cats", ) db.add(job) db.commit() r = as_user(owner).post(f"/api/downloads/{job.id}/share", json={"email": "friend@example.com"}) assert r.status_code == 200, r.text notice = db.execute(select(Notification).where(Notification.user_id == friend.id)).scalar_one() assert notice.type == "download_shared" assert notice.data == { "kind": "download_shared", "from": "owner@example.com", "job_id": job.id, "title": "Cats", }