Merge branch 'worktree-agent-a8e1a9fb17fbab9d8'

This commit is contained in:
Wolf committed 2026-09-25 21:52:39 +02:00
commit 15057ea230
13 files changed
+1216 -192

No files matched your search

+55
View File
@@ -205,6 +205,61 @@ def test_roles_hide_muted_excludes_before_the_limit(store: Store, clock: Clock)
assert {r.source_id for r in store.roles()} == {"a0", "a1", "a2", "other"}
def test_roles_page_by_offset_and_count_the_same_filter(
store: Store, clock: Clock) -> None:
for sid in ("1", "2", "3", "4"):
store.upsert_role(posting(sid, company="Acme" if sid != "4" else "Other"))
clock.tick()
assert [r.source_id for r in store.roles(limit=2, offset=1)] == ["3", "2"]
assert [r.source_id for r in store.roles(limit=2, offset=3)] == ["1"]
assert store.count_roles() == 4
assert store.count_roles(company="acme") == 3
store.add_company("Other", key="other", affinity=-1)
assert store.count_roles(hide_muted=True) == 3
def test_a_vote_is_stamped_cleared_and_filtered(store: Store, clock: Clock) -> None:
for sid in ("up", "down", "fine", "none"):
store.upsert_role(posting(sid))
uid = {r.source_id: r.uid for r in store.roles()}
role = store.set_vote(uid["up"], 1)
assert (role.vote, role.voted_at) == (1, clock().isoformat(timespec="seconds"))
store.set_vote(uid["down"], -1)
store.set_vote(uid["fine"], 0)
assert [r.source_id for r in store.roles(judged="liked")] == ["up"]
assert [r.source_id for r in store.roles(judged="passed")] == ["down"]
assert [r.source_id for r in store.roles(judged="unjudged")] == ["none"]
assert store.count_roles(judged="unjudged") == 1
with pytest.raises(ValueError, match="judged"):
store.roles(judged="maybe")
cleared = store.set_vote(uid["up"], None)
assert (cleared.vote, cleared.voted_at) == (None, None)
with pytest.raises(ValueError):
store.set_vote(uid["up"], 2)
with pytest.raises(ValueError):
store.set_vote(uid["up"], True)
with pytest.raises(KeyError):
store.set_vote("nope", 1)
def test_a_vote_moves_the_served_score_and_the_order(store: Store) -> None:
for sid in ("a", "b", "c"):
store.upsert_role(posting(sid))
uid = {r.source_id: r.uid for r in store.roles()}
agent = store.save_agent("A")
store.replace_scores(agent.id, [(uid["a"], 0.9, ""), (uid["b"], 0.5, ""),
(uid["c"], 0.4, "")])
store.set_vote(uid["a"], -1) # 0.45
store.set_vote(uid["c"], 1) # 0.48
ranked = [(r.source_id, round(r.score or 0, 3)) for r in store.roles(agent=agent.id)]
assert ranked == [("b", 0.5), ("c", 0.48), ("a", 0.45)]
assert store.scores(agent.id)[uid["a"]][0] == 0.9 # the stored score is kept
store.set_vote(uid["a"], 1)
assert store.roles(agent=agent.id, limit=1)[0].score == 1.0
def test_mark_closed_closes_what_the_board_no_longer_lists(store: Store) -> None:
sub = store.add_subscription("ats", "greenhouse:acme")
other = store.add_subscription("ats", "greenhouse:other")