test(reader): the service tests hold each rule their mutant broke
A reorder's left-out item, a playlisted video beside one not asked about, another user's tag, and the user's own channel link committed before the auto-tagger reads the table.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Feed cursor endpoint: a malformed ?cursor= must be a clean HTTP 400, not a 500.
|
||||
|
||||
Locks the refactor that split cursor handling across modules — feedquery.decode_cursor raises a
|
||||
plain ValueError and routes/feed.get_feed translates it to 400 — so a future regression (a dropped
|
||||
Cursor handling spans modules — feedquery.decode_cursor raises a plain ValueError, feed_page turns
|
||||
it into BadCursor, and routes/feed.get_feed translates that to 400 — so a regression (a dropped
|
||||
try/except, or a new decode_cursor caller without its own catch) turns the 400 back into a 500 and
|
||||
fails right here. DB lane (`db` fixture) — skipped without Postgres.
|
||||
"""
|
||||
|
||||
@@ -55,8 +55,9 @@ def test_a_row_of_someone_elses_reads_as_a_missing_one(db, make_user):
|
||||
|
||||
|
||||
def test_a_system_tag_is_nobodys_to_edit(db, make_user):
|
||||
user = make_user()
|
||||
user, other = make_user(), make_user()
|
||||
system = service.ensure_system_tag(db, "Music", "topic", None)
|
||||
service.create_tag(db, other, "Theirs", "other", None) # another user's tag stays theirs
|
||||
db.commit()
|
||||
assert queries.own_tag(db, user, system.id) is None
|
||||
assert [t.id for t, _ in queries.tags_with_counts(db, user)] == [system.id]
|
||||
@@ -96,6 +97,7 @@ def test_the_auto_tagger_moves_only_its_own_links(db, make_user):
|
||||
assert service.ensure_system_tag(db, "Gaming", "topic", None) is gaming # made once
|
||||
mine = service.create_tag(db, user, "Fav", "other", None)
|
||||
db.add(ChannelTag(channel_id="UCr", tag_id=mine.id, user_id=user.id, source="user"))
|
||||
db.commit() # the user's link is in the table the auto-tagger reads
|
||||
service.set_auto_tags(db, "UCr", {gaming.id: 0.5})
|
||||
db.commit()
|
||||
service.set_auto_tags(db, "UCr", {music.id: None})
|
||||
@@ -253,9 +255,9 @@ def test_a_reorder_keeps_what_it_left_out_after_the_listed(db, make_user):
|
||||
for v in ("a", "b", "c"):
|
||||
service.add_item(db, pl, v, mark_dirty=False)
|
||||
db.commit()
|
||||
assert service.reorder_items(db, pl, ["c", "zzz", "a"]) == 3
|
||||
assert service.reorder_items(db, pl, ["c", "zzz", "b"]) == 3
|
||||
db.commit()
|
||||
assert _ids(db, pl) == ["c", "a", "b"]
|
||||
assert _ids(db, pl) == ["c", "b", "a"]
|
||||
|
||||
|
||||
def test_a_rename_and_a_delete(db, make_user):
|
||||
@@ -278,13 +280,14 @@ def test_a_rename_and_a_delete(db, make_user):
|
||||
|
||||
def test_a_video_someone_holds_is_kept_and_its_playlisters_are_known(db, make_user):
|
||||
user = make_user()
|
||||
_videos(db, "watched", "listed", "loose")
|
||||
_videos(db, "watched", "listed", "also", "loose")
|
||||
service.mark(db, user, "watched", "watched")
|
||||
pl = service.create_playlist(db, user, "L")
|
||||
service.add_item(db, pl, "listed", mark_dirty=False)
|
||||
service.add_item(db, pl, "also", mark_dirty=False)
|
||||
db.commit()
|
||||
kept = db.execute(select(Video.id).where(queries.kept_by_a_reader(Video.id))).scalars()
|
||||
assert sorted(kept) == ["listed", "watched"]
|
||||
assert sorted(kept) == ["also", "listed", "watched"]
|
||||
assert queries.playlisted_by(db, ["listed", "loose"]) == [(user.id, "listed")]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user