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"):
|
||||
|
||||
Reference in new issue
Block a user