Close a role of a swept board only when two finished sweeps in a row missed it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a19c528e3f
commit
a91032b60f
5 files changed
+373
-11
No files matched your search
+78
-3
@@ -206,14 +206,17 @@ def _row(job_id: str) -> dict[str, object]:
|
||||
"description": "", "remote": None, "salary_text": ""}
|
||||
|
||||
|
||||
def _answer(monkeypatch: pytest.MonkeyPatch, answer: object, filtered: bool = False) -> None:
|
||||
def _answer(monkeypatch: pytest.MonkeyPatch, answer: object, filtered: bool = False,
|
||||
swept: bool = False) -> None:
|
||||
"""Every board's listing is `answer`, `(rows, complete)`, or raises it;
|
||||
with `filtered`, a read the board's filter narrowed."""
|
||||
with `filtered`, a read the board's filter narrowed, with `swept` one that
|
||||
finished a sweep across pulls."""
|
||||
def fake(*args: object, **kwargs: object) -> _runner.Listing:
|
||||
if isinstance(answer, Exception):
|
||||
raise answer
|
||||
rows, complete = answer # type: ignore[misc]
|
||||
return _runner.Listing(rows, complete, [r["source_id"] for r in rows], filtered)
|
||||
return _runner.Listing(rows, complete, [r["source_id"] for r in rows], filtered,
|
||||
swept=swept)
|
||||
|
||||
monkeypatch.setattr(_runner, "read_listing", fake)
|
||||
|
||||
@@ -302,6 +305,78 @@ def test_a_filtered_read_closes_what_it_left_out_except_roles_acted_on(
|
||||
assert _open(acme) == {"workable:acme:1"}
|
||||
|
||||
|
||||
def test_a_swept_read_closes_only_what_two_sweeps_in_a_row_missed(
|
||||
acme: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_answer(monkeypatch, ([_row(i) for i in "123"], True))
|
||||
_pull(acme)
|
||||
|
||||
_answer(monkeypatch, ([_row("1")], True), swept=True)
|
||||
result = _pull(acme)
|
||||
assert _open(acme) == {"workable:acme:1", "workable:acme:2", "workable:acme:3"}
|
||||
assert result["closed"] == 0
|
||||
assert json.loads(acme.state["ats:missing:workable:acme"]) == [
|
||||
"workable:acme:2", "workable:acme:3"]
|
||||
|
||||
# 3 came back, 2 did not: 2 has two strikes, 3 starts over.
|
||||
_answer(monkeypatch, ([_row("1"), _row("3")], True), swept=True)
|
||||
result = _pull(acme)
|
||||
assert _open(acme) == {"workable:acme:1", "workable:acme:3"}
|
||||
assert result["closed"] == 1
|
||||
assert json.loads(acme.state["ats:missing:workable:acme"]) == []
|
||||
|
||||
|
||||
def test_an_incomplete_read_between_two_sweeps_keeps_the_strike(
|
||||
acme: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_answer(monkeypatch, ([_row(i) for i in "12"], True))
|
||||
_pull(acme)
|
||||
_answer(monkeypatch, ([_row("1")], True), swept=True)
|
||||
_pull(acme)
|
||||
_answer(monkeypatch, ([_row("1")], False))
|
||||
_pull(acme)
|
||||
_answer(monkeypatch, ValueError("down"))
|
||||
_pull(acme)
|
||||
assert json.loads(acme.state["ats:missing:workable:acme"]) == ["workable:acme:2"]
|
||||
|
||||
_answer(monkeypatch, ([_row("1")], True), swept=True)
|
||||
_pull(acme)
|
||||
assert _open(acme) == {"workable:acme:1"}
|
||||
|
||||
|
||||
def test_a_filtered_swept_read_keeps_the_roles_acted_on(
|
||||
acme: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_answer(monkeypatch, ([_row(i) for i in "1234"], True))
|
||||
_pull(acme)
|
||||
uid = {r.source_id: r.uid for r in acme.roles()}
|
||||
agent = acme.save_agent("Hunt")
|
||||
acme.set_vote(agent.id, uid["workable:acme:2"], 0)
|
||||
acme.save_application(Application(role_uid=uid["workable:acme:3"], role_title="Engineer"))
|
||||
|
||||
_answer(monkeypatch, ([_row("1")], True), filtered=True, swept=True)
|
||||
assert _pull(acme)["closed"] == 0
|
||||
assert _open(acme) == {f"workable:acme:{i}" for i in "1234"}
|
||||
|
||||
result = _pull(acme)
|
||||
assert result["closed"] == 1
|
||||
assert _open(acme) == {"workable:acme:1", "workable:acme:2", "workable:acme:3"}
|
||||
assert json.loads(acme.state["ats:missing:workable:acme"]) == [
|
||||
"workable:acme:2", "workable:acme:3"]
|
||||
|
||||
|
||||
def test_a_narrowed_swept_read_closes_nothing_and_keeps_the_record(
|
||||
acme: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_answer(monkeypatch, ([_row(i) for i in "12"], True))
|
||||
_pull(acme)
|
||||
_answer(monkeypatch, ([_row("1")], True), swept=True)
|
||||
_pull(acme)
|
||||
|
||||
def fake(*args: object, **kwargs: object) -> _runner.Listing:
|
||||
return _runner.Listing([_row("1")], True, ["1"], swept=True, narrowed=True)
|
||||
|
||||
monkeypatch.setattr(_runner, "read_listing", fake)
|
||||
assert _pull(acme)["closed"] == 0
|
||||
assert json.loads(acme.state["ats:missing:workable:acme"]) == ["workable:acme:2"]
|
||||
|
||||
|
||||
def test_a_board_subscriptions_params_reach_the_runner_as_its_ask(
|
||||
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
store.add_subscription("ats", "workable:acme", label="Acme", company="Acme",
|
||||
|
||||
Reference in new issue
Block a user