A pull that brings a role a better text, as fetch text does, puts it back in extract's queue beside dropping its vector, so a role extract read from its title alone is read again from its text.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7ac63dea7c
commit
0b92f19f4d
3 files changed
+77
-10
No files matched your search
@@ -130,6 +130,46 @@ def test_the_next_upsert_keeps_what_extract_filled(
|
||||
assert role is not None and (role.country, role.seniority) == ("DE", "mid")
|
||||
|
||||
|
||||
def test_a_role_read_from_its_title_is_read_again_once_its_text_arrives(
|
||||
store: Store, config: Config, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Fetch text stores what a page filled through `upsert_role`: a better
|
||||
text than the role was read from puts it back in extract's queue, its
|
||||
tries forgiven, and a pull that brings no better text does not."""
|
||||
bare = posting("1")
|
||||
bare.body = ""
|
||||
upsert(store, bare)
|
||||
ranked(store, bare)
|
||||
stub(monkeypatch, lambda roles: [answer(r["uid"], seniority="mid", function="sales")
|
||||
for r in roles])
|
||||
modeltask.run(extract.TASK, config, store)
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET extract_tries = 2 WHERE source_id = '1'")
|
||||
|
||||
upsert(store, bare)
|
||||
assert store.extract_pending() == 0, "the same text again is no reason to read it"
|
||||
|
||||
upsert(store, posting("1", function="engineering"))
|
||||
|
||||
role = store.role(bare.uid)
|
||||
assert role is not None and role.extracted_at is None
|
||||
assert role.function == "sales", "the pull that brings the text keeps extract's function"
|
||||
assert [r.uid for r in store.extract_waiting(10)] == [bare.uid]
|
||||
with store.transaction() as conn:
|
||||
assert conn.execute("SELECT extract_tries FROM roles WHERE uid = ?",
|
||||
(bare.uid,)).fetchone()[0] == 0
|
||||
model = stub(monkeypatch, lambda roles: [answer(r["uid"], seniority="senior")
|
||||
for r in roles])
|
||||
modeltask.run(extract.TASK, config, store)
|
||||
[[sent]] = model.asked
|
||||
assert sent["text"] == "We pay 80.000-95.000 EUR. Hybrid in Berlin."
|
||||
role = store.role(bare.uid)
|
||||
assert role is not None and role.extracted_at is not None
|
||||
assert (role.seniority_model, role.seniority) == ("senior", "senior")
|
||||
|
||||
upsert(store, posting("1"))
|
||||
assert store.extract_pending() == 0, "a text no better than before is read once"
|
||||
|
||||
|
||||
def test_closed_and_answered_roles_are_not_offered(
|
||||
store: Store, config: Config, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
for sid in ("open", "closed", "done"):
|
||||
|
||||
@@ -237,6 +237,24 @@ def test_a_batch_stores_what_the_pages_filled_and_drops_those_vectors(
|
||||
assert again.place == "Copenhagen"
|
||||
|
||||
|
||||
def test_a_role_extract_read_without_text_waits_for_it_again_once_its_page_is_read(
|
||||
store: Store, tmp_path: Path, web: dict[str, Any]) -> None:
|
||||
"""Extract read the title alone; the page's text puts the role back in
|
||||
its queue, and a page that gave nothing leaves it read."""
|
||||
board(store, "fake:acme")
|
||||
filled, empty = (role(store, "fake:acme", n) for n in ("1", "2"))
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET extracted_at = '2026-09-22T00:00:00+00:00', "
|
||||
"extract_tries = 1")
|
||||
web["answers"].update({f"{BASE}/acme/1": b"Python in full"})
|
||||
|
||||
fetch_text.run_batch(config(tmp_path), store, target="fake:acme", uids=[filled, empty])
|
||||
|
||||
first, second = store.role(filled), store.role(empty)
|
||||
assert first is not None and first.extracted_at is None
|
||||
assert second is not None and second.extracted_at == "2026-09-22T00:00:00+00:00"
|
||||
|
||||
|
||||
def test_a_board_switched_off_since_the_plan_reads_nothing(
|
||||
store: Store, tmp_path: Path, web: dict[str, Any]) -> None:
|
||||
sub = board(store, "fake:acme")
|
||||
|
||||
Reference in new issue
Block a user