Bring the Python side to the ADR: the judge scores 0 to 10 with the cap at 4 and migration 33 clears every judgement, summarise reads the top 30 of the want and the match order, a hidden company's roles are never in the feed, and the company switch is called All locations.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6cad9713ac
commit
6d82287402
27 files changed
+390
-247
No files matched your search
@@ -148,7 +148,7 @@ def test_migration_20_seeds_an_old_file_and_leaves_collisions(tmp_path: Path) ->
|
||||
"VALUES (?, ?, '', '')", (key, name))
|
||||
conn.execute("PRAGMA user_version = 19")
|
||||
reopened = Store(path)
|
||||
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert reopened.migrations_applied == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert reopened.duplicate_companies() == [("orsted", ["orsted", "ørsted"])]
|
||||
assert len(reopened.companies()) == 3
|
||||
|
||||
@@ -186,7 +186,7 @@ def test_migration_21_tags_the_favourites_and_the_boards_that_read_all_roles(tmp
|
||||
conn.execute("ALTER TABLE companies DROP COLUMN all_countries")
|
||||
conn.execute("PRAGMA user_version = 20")
|
||||
reopened = Store(path)
|
||||
assert reopened.migrations_applied == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert reopened.migrations_applied == [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
# The tag of 21 is All countries and All roles since 24.
|
||||
tagged = {"mistral-ai": 1, "acme": 0, "black-forest-labs": 1, "liked": 0}
|
||||
assert {c.key: c.all_roles for c in reopened.companies()} == tagged
|
||||
|
||||
+17
-17
@@ -65,8 +65,8 @@ def setup(store: Store) -> tuple[Any, dict[str, str]]:
|
||||
uid[sid] = posting(sid).uid
|
||||
store.replace_scores(owner.id, [(uid["a"], 0.9, ""), (uid["b"], 0.8, ""),
|
||||
(uid["c"], 0.7, ""), (uid["d"], 0.6, "gated")])
|
||||
store.set_judgement(owner.id, uid["c"], "k", 90, 90, 90, ["Leads data."], ["Small team."])
|
||||
store.set_judgement(owner.id, uid["b"], "k", 60, 60, 60, ["Data."], ["Junior."])
|
||||
store.set_judgement(owner.id, uid["c"], "k", 9, 9, 9, ["Leads data."], ["Small team."])
|
||||
store.set_judgement(owner.id, uid["b"], "k", 6, 6, 6, ["Data."], ["Junior."])
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE roles SET languages_required = ? WHERE uid = ?", (json.dumps(
|
||||
[{"language": "sv", "level": "fluent", "kind": "required"}]), uid["a"]))
|
||||
@@ -94,22 +94,22 @@ def test_best_cv_match_puts_the_judged_first_by_cv_score(
|
||||
def test_a_broken_must_have_caps_career_in_the_order_and_the_reader(
|
||||
client: TestClient, store: Store) -> None:
|
||||
owner, uid = setup(store)
|
||||
# c: 90 on all three, but one must-have broken: career counts as 39.
|
||||
# c: 9 on all three, but one must-have broken: career counts as 4.
|
||||
musts = [{"id": "M1", "text": "Permanent", "verdict": "met"},
|
||||
{"id": "M2", "text": "Remote", "verdict": "broken"}]
|
||||
store.set_judgement(owner.id, uid["c"], "k", 90, 90, 90, [], [], musts)
|
||||
capped = round((30 * 90 + 25 * 90 + 30 * 39) / 85, 1)
|
||||
store.set_judgement(owner.id, uid["c"], "k", 9, 9, 9, [], [], musts)
|
||||
capped = round(10 * (30 * 9 + 25 * 9 + 30 * 4) / 85, 1)
|
||||
rows = client.get("/api/roles", params={"agent": owner.id, "order": "cv"}).json()["items"]
|
||||
assert [(r["uid"], r["cv_score"]) for r in rows[:2]] == [(uid["c"], capped), (uid["b"], 60.0)]
|
||||
# With career weighted up the capped value drops under b's 60.
|
||||
store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id, cv_text=owner.cv_text,
|
||||
weights=Weights(cv_skills=0, cv_experience=0, cv_career=1))
|
||||
rows = client.get("/api/roles", params={"agent": owner.id, "order": "cv"}).json()["items"]
|
||||
assert [(r["uid"], r["cv_score"]) for r in rows[:2]] == [(uid["b"], 60.0), (uid["c"], 39.0)]
|
||||
assert [(r["uid"], r["cv_score"]) for r in rows[:2]] == [(uid["b"], 60.0), (uid["c"], 40.0)]
|
||||
one = client.get(f"/api/roles/{uid['c']}", params={"agent": owner.id}).json()
|
||||
j = one["judgement"]
|
||||
assert (j["career"], j["career_capped"], j["broken"]) == (90, 39, 1)
|
||||
assert j["musts"] == musts and one["cv_score"] == j["cv_score"] == 39.0
|
||||
assert (j["career"], j["career_capped"], j["broken"]) == (9, 4, 1)
|
||||
assert j["musts"] == musts and one["cv_score"] == j["cv_score"] == 40.0
|
||||
|
||||
|
||||
def test_a_met_or_unclear_must_have_leaves_career_as_the_model_gave_it(
|
||||
@@ -117,16 +117,16 @@ def test_a_met_or_unclear_must_have_leaves_career_as_the_model_gave_it(
|
||||
owner, uid = setup(store)
|
||||
musts = [{"id": "M1", "text": "Permanent", "verdict": "met"},
|
||||
{"id": "M2", "text": "Remote", "verdict": "unclear"}]
|
||||
store.set_judgement(owner.id, uid["c"], "k", 90, 90, 90, [], [], musts)
|
||||
store.set_judgement(owner.id, uid["c"], "k", 9, 9, 9, [], [], musts)
|
||||
j = client.get(f"/api/roles/{uid['c']}", params={"agent": owner.id}).json()["judgement"]
|
||||
assert (j["career"], j["career_capped"], j["broken"], j["cv_score"]) == (90, 90, 0, 90.0)
|
||||
assert (j["career"], j["career_capped"], j["broken"], j["cv_score"]) == (9, 9, 0, 90.0)
|
||||
|
||||
|
||||
def test_the_agents_weights_make_the_cv_score_at_read_time(
|
||||
client: TestClient, store: Store) -> None:
|
||||
owner, uid = setup(store)
|
||||
# c: skills 100, experience 0, career 0; b: 60 on all three.
|
||||
store.set_judgement(owner.id, uid["c"], "k", 100, 0, 0, ["Leads data."], ["Small team."])
|
||||
# c: skills 10, experience 0, career 0; b: 6 on all three.
|
||||
store.set_judgement(owner.id, uid["c"], "k", 10, 0, 0, ["Leads data."], ["Small team."])
|
||||
key_before = input_key(owner, "text")
|
||||
|
||||
def asked() -> tuple[list[tuple[str, float | None]], float | None]:
|
||||
@@ -150,7 +150,7 @@ def test_the_agents_weights_make_the_cv_score_at_read_time(
|
||||
assert [c for _, c in rows] == [None, None, None] and one is None
|
||||
assert [u for u, _ in rows] == [uid["a"], uid["b"], uid["c"]], "by score, as none is judged"
|
||||
assert client.get(f"/api/roles/{uid['c']}",
|
||||
params={"agent": owner.id}).json()["judgement"]["skills"] == 100
|
||||
params={"agent": owner.id}).json()["judgement"]["skills"] == 10
|
||||
refreshed = store.agent(owner.id)
|
||||
assert refreshed is not None and input_key(refreshed, "text") == key_before, \
|
||||
"the weights are no part of what the judge read"
|
||||
@@ -160,9 +160,9 @@ def test_the_weights_are_per_agent_json_with_the_old_values_as_default(store: St
|
||||
owner = store.save_agent("Data", prompts=[Prompt(name="Lead", text="Head of data")])
|
||||
assert (owner.weights.cv_skills, owner.weights.cv_experience,
|
||||
owner.weights.cv_career) == (30, 25, 30)
|
||||
assert cv_score(80, 60, 40, owner.weights) == round((2400 + 1500 + 1200) / 85, 1)
|
||||
assert cv_score(80, 60, 40, Weights(cv_skills=0, cv_experience=1, cv_career=1)) == 50.0
|
||||
assert cv_score(80, 60, 40, Weights(cv_skills=0, cv_experience=0, cv_career=0)) is None
|
||||
assert cv_score(8, 6, 4, owner.weights) == round(10 * (240 + 150 + 120) / 85, 1)
|
||||
assert cv_score(8, 6, 4, Weights(cv_skills=0, cv_experience=1, cv_career=1)) == 50.0
|
||||
assert cv_score(8, 6, 4, Weights(cv_skills=0, cv_experience=0, cv_career=0)) is None
|
||||
|
||||
|
||||
def test_a_row_carries_the_deadline_and_the_language_flag(
|
||||
@@ -199,7 +199,7 @@ def test_the_role_carries_its_judgement_and_languages(
|
||||
owner, uid = setup(store)
|
||||
role = client.get(f"/api/roles/{uid['c']}", params={"agent": owner.id}).json()
|
||||
judgement = role["judgement"]
|
||||
assert (judgement["skills"], judgement["cv_score"]) == (90, 90.0)
|
||||
assert (judgement["skills"], judgement["cv_score"]) == (9, 90.0)
|
||||
assert judgement["strengths"] == ["Leads data."] and judgement["gaps"] == ["Small team."]
|
||||
assert judgement["judged_at"]
|
||||
assert role["cv_score"] == 90.0 and role["lang_flag"] == "plus"
|
||||
|
||||
+51
-9
@@ -75,7 +75,7 @@ def test_new_agents_have_the_cut_by_default(store: Store) -> None:
|
||||
made = store.save_agent("Data")
|
||||
assert made.limits.model_dump() == {"cut_fit_top": 500, "cut_fit_min": 0.6,
|
||||
"cut_cv_top": 150, "cut_cv_min": 0.6,
|
||||
"summarise_top": 50}
|
||||
"summarise_top": 30}
|
||||
|
||||
|
||||
# --------------------------------------------------------------- migration
|
||||
@@ -98,7 +98,7 @@ def test_v28_adds_the_cv_columns_and_the_host_deadline_and_runs_twice(tmp_path:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [28, 29, 30, 31, 32, 33]
|
||||
rows = {r["source_id"]: r for r in migrated._rows(
|
||||
"SELECT source_id, languages_required, deadline_host, deadline FROM roles")}
|
||||
assert (rows["a"]["deadline_host"], rows["a"]["deadline"]) == ("2026-10-18", None)
|
||||
@@ -110,7 +110,7 @@ def test_v28_adds_the_cv_columns_and_the_host_deadline_and_runs_twice(tmp_path:
|
||||
assert migrated.role(posting("a").uid).deadline == "2026-10-18"
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 27")
|
||||
assert Store(path).migrations_applied == [28, 29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [28, 29, 30, 31, 32, 33]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- deadline
|
||||
@@ -229,8 +229,9 @@ def test_the_language_flag() -> None:
|
||||
|
||||
|
||||
def test_the_cv_score_weighs_skills_and_career_above_experience() -> None:
|
||||
assert cv_score(100, 100, 100) == 100.0
|
||||
assert cv_score(80, 60, 40) == round((2400 + 1500 + 1200) / 85, 1)
|
||||
assert cv_score(10, 10, 10) == 100.0
|
||||
assert cv_score(8, 6, 4) == round(10 * (240 + 150 + 120) / 85, 1)
|
||||
assert cv_score(8, 6, 9, broken=1) == cv_score(8, 6, 4)
|
||||
|
||||
|
||||
def test_a_stored_language_list_survives_a_bad_entry(store: Store) -> None:
|
||||
@@ -251,12 +252,12 @@ def test_v29_adds_the_musts_and_broken_columns_and_runs_twice(tmp_path: Path) ->
|
||||
conn.execute(f"ALTER TABLE role_judgements DROP COLUMN {column}")
|
||||
conn.execute("PRAGMA user_version = 28")
|
||||
|
||||
assert Store(path).migrations_applied == [29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [29, 30, 31, 32, 33]
|
||||
with sqlite3.connect(path) as conn:
|
||||
columns = {r[1] for r in conn.execute("PRAGMA table_info(role_judgements)")}
|
||||
assert {"musts", "broken"} <= columns
|
||||
conn.execute("PRAGMA user_version = 28")
|
||||
assert Store(path).migrations_applied == [29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [29, 30, 31, 32, 33]
|
||||
|
||||
|
||||
def test_v30_adds_like_text_and_runs_twice(tmp_path: Path) -> None:
|
||||
@@ -268,12 +269,53 @@ def test_v30_adds_like_text_and_runs_twice(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [30, 31, 32]
|
||||
assert migrated.migrations_applied == [30, 31, 32, 33]
|
||||
[data] = migrated.agents()
|
||||
assert (data.like_text, data.avoid_text) == ("", "Reporting.")
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 29")
|
||||
assert Store(path).migrations_applied == [30, 31, 32]
|
||||
assert Store(path).migrations_applied == [30, 31, 32, 33]
|
||||
|
||||
|
||||
def test_v33_clears_every_judgement_and_lowers_the_old_summarise_default(
|
||||
tmp_path: Path) -> None:
|
||||
"""A judgement on the 0 to 100 scale is never shown on the 0 to 10 one:
|
||||
migration 33 clears every row and gives the tries back, and the judge
|
||||
reads the pair again. `summarise_top` 50, migration 32's default, is 30;
|
||||
any other value, and a limits object without the key, stay."""
|
||||
path = tmp_path / "v32.db"
|
||||
store = Store(path)
|
||||
item = posting("1")
|
||||
upsert(store, item)
|
||||
old = store.save_agent("Old", "data leadership", cv_text="CV.")
|
||||
own = store.save_agent("Own", "data leadership")
|
||||
bare = store.save_agent("Bare", "data leadership")
|
||||
musts = [{"id": "M1", "text": "Remote", "verdict": "broken"}]
|
||||
assert store.set_judgement(old.id, item.uid, "key", 80, 70, 90, ["Good."], ["Bad."], musts)
|
||||
store.judge_missed([(own.id, item.uid)])
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("UPDATE agents SET limits = json_set(limits, '$.summarise_top', 50) "
|
||||
"WHERE id = ?", (old.id,))
|
||||
conn.execute("UPDATE agents SET limits = json_set(limits, '$.summarise_top', 12) "
|
||||
"WHERE id = ?", (own.id,))
|
||||
conn.execute("UPDATE agents SET limits = '{}' WHERE id = ?", (bare.id,))
|
||||
conn.execute("PRAGMA user_version = 32")
|
||||
|
||||
for _ in range(2): # runs twice without harm
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [33]
|
||||
assert migrated.judgement(old.id, item.uid) is None
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT skills, experience, career, cv_score, strengths, gaps, musts, broken, "
|
||||
"input_key, tries, judged_at FROM role_judgements").fetchall()
|
||||
assert rows == [(None, None, None, None, "[]", "[]", "[]", 0, "", 0, None)] * 2
|
||||
conn.execute("PRAGMA user_version = 32")
|
||||
assert {a.name: a.limits.summarise_top for a in migrated.agents()} == {
|
||||
"Old": 30, "Own": 12, "Bare": 30}
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert conn.execute("SELECT limits FROM agents WHERE id = ?",
|
||||
(bare.id,)).fetchone() == ("{}",)
|
||||
|
||||
|
||||
def test_the_musts_text_is_one_must_have_per_line() -> None:
|
||||
|
||||
@@ -282,7 +282,7 @@ def test_migration_31_adds_the_column_and_the_table_and_runs_twice(tmp_path: Pat
|
||||
conn.execute("DROP TABLE agent_cv_vectors")
|
||||
conn.execute("ALTER TABLE scores DROP COLUMN cv_fit")
|
||||
conn.execute("PRAGMA user_version = 30")
|
||||
assert Store(path).migrations_applied == [31, 32]
|
||||
assert Store(path).migrations_applied == [31, 32, 33]
|
||||
step = {v: s for v, _, s in MIGRATIONS}[31]
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert callable(step)
|
||||
|
||||
@@ -279,7 +279,7 @@ def test_a_v17_file_gains_dup_of_with_its_first_rebuild(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert dup_of(migrated) == {first.uid: None, second.uid: first.uid}
|
||||
with sqlite3.connect(path) as conn:
|
||||
assert conn.execute("SELECT 1 FROM sqlite_master WHERE name = 'idx_roles_dup_of'"
|
||||
|
||||
@@ -300,7 +300,7 @@ def test_the_reach_line_counts_the_terms(store: Store) -> None:
|
||||
plan = reach.plan(store)
|
||||
philips = _sub(store, "phenom:www.careers.philips.com/global/en")
|
||||
assert reach.line(plan, philips) == \
|
||||
"all countries (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, head of"
|
||||
"all locations (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, head of"
|
||||
assert reach.line(plan, _sub(store, "smartrecruiters:BoschGroup")) == \
|
||||
"all places, too many countries to ask · follows agents' terms: data, engineer, head of"
|
||||
|
||||
@@ -520,7 +520,7 @@ def test_migration_23_gives_every_agent_no_terms(tmp_path: Path) -> None:
|
||||
conn.execute("ALTER TABLE agents DROP COLUMN fetch_terms")
|
||||
conn.execute("PRAGMA user_version = 22")
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert migrated.agents()[0].fetch_terms == []
|
||||
|
||||
|
||||
|
||||
+21
-12
@@ -51,7 +51,7 @@ class Model:
|
||||
|
||||
|
||||
def judged(items: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
return [{"key": i["key"], "skills": 80, "experience": 70, "career": 90,
|
||||
return [{"key": i["key"], "skills": 8, "experience": 7, "career": 9,
|
||||
"strengths": ["Leads a data science team.", "", "Python.", "ML.", "Fourth."],
|
||||
"gaps": ["No people budget stated."]} for i in items]
|
||||
|
||||
@@ -100,8 +100,8 @@ def test_a_run_writes_the_judgement_and_its_total(
|
||||
|
||||
found = store.judgement(owner.id, uid)
|
||||
assert found is not None
|
||||
assert (found.skills, found.experience, found.career) == (80, 70, 90)
|
||||
assert found.cv_score == round((30 * 80 + 25 * 70 + 30 * 90) / 85, 1)
|
||||
assert (found.skills, found.experience, found.career) == (8, 7, 9)
|
||||
assert found.cv_score == round(10 * (30 * 8 + 25 * 7 + 30 * 9) / 85, 1)
|
||||
assert found.strengths == ["Leads a data science team.", "Python.", "ML."]
|
||||
assert found.gaps == ["No people budget stated."]
|
||||
assert result["judged"] == 1 and result["pending"] == 0
|
||||
@@ -125,7 +125,7 @@ def test_the_musts_are_numbered_in_the_profile_and_stored_with_their_text(
|
||||
[uid] = ranked(store, owner, "1")
|
||||
|
||||
def reply(items: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
return [{**one, "career": 80, "musts": [
|
||||
return [{**one, "career": 8, "musts": [
|
||||
{"id": "M1", "verdict": "met"}, {"id": "M2", "verdict": "broken"},
|
||||
{"id": "M9", "verdict": "broken"}, {"id": "M3", "verdict": "maybe"}]}
|
||||
for one in judged(items)]
|
||||
@@ -140,8 +140,8 @@ def test_the_musts_are_numbered_in_the_profile_and_stored_with_their_text(
|
||||
assert [(m.id, m.text, m.verdict) for m in found.musts] == [
|
||||
("M1", "Permanent contract", "met"), ("M2", "Remote two days", "broken"),
|
||||
("M3", "Danish team", "unclear")]
|
||||
assert (found.career, found.career_capped, found.broken) == (80, 39, 1)
|
||||
assert found.cv_score == round((30 * 80 + 25 * 70 + 30 * 39) / 85, 1)
|
||||
assert (found.career, found.career_capped, found.broken) == (8, 4, 1)
|
||||
assert found.cv_score == round(10 * (30 * 8 + 25 * 7 + 30 * 4) / 85, 1)
|
||||
|
||||
|
||||
def test_a_must_the_model_left_out_is_unclear_and_nothing_is_broken_by_silence(
|
||||
@@ -153,7 +153,7 @@ def test_a_must_the_model_left_out_is_unclear_and_nothing_is_broken_by_silence(
|
||||
found = store.judgement(owner.id, uid)
|
||||
assert found is not None
|
||||
assert [(m.id, m.verdict) for m in found.musts] == [("M1", "unclear")]
|
||||
assert (found.career, found.career_capped, found.broken) == (90, 90, 0)
|
||||
assert (found.career, found.career_capped, found.broken) == (9, 9, 0)
|
||||
|
||||
|
||||
def test_the_schema_requires_the_verdicts_and_the_prompt_leaves_the_cap_to_code() -> None:
|
||||
@@ -161,7 +161,8 @@ def test_the_schema_requires_the_verdicts_and_the_prompt_leaves_the_cap_to_code(
|
||||
assert "musts" in item["required"]
|
||||
verdict = item["properties"]["musts"]["items"]["properties"]["verdict"]
|
||||
assert verdict["enum"] == ["met", "broken", "unclear"]
|
||||
assert "career 0-39" not in judge.SYSTEM and "clearly contradicts" in judge.SYSTEM
|
||||
assert "career 0-3" not in judge.SYSTEM and "clearly contradicts" in judge.SYSTEM
|
||||
assert "0 to 10" in judge.SYSTEM and "80-100" not in judge.SYSTEM
|
||||
|
||||
|
||||
def test_judgements_made_before_the_format_are_made_again(store: Store) -> None:
|
||||
@@ -169,6 +170,14 @@ def test_judgements_made_before_the_format_are_made_again(store: Store) -> None:
|
||||
assert judge.input_key(owner, "text") != hashlib_old_key(owner, "text")
|
||||
|
||||
|
||||
def test_a_judgement_on_the_0_to_100_scale_is_made_again(
|
||||
store: Store, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
owner = hunter(store)
|
||||
now = judge.input_key(owner, "text")
|
||||
monkeypatch.setattr(judge, "FORMAT", 3)
|
||||
assert judge.input_key(owner, "text") != now
|
||||
|
||||
|
||||
def test_what_the_person_likes_is_part_of_what_a_judgement_read(store: Store) -> None:
|
||||
owner = hunter(store)
|
||||
liked = store.save_agent("Data", prompts=owner.prompts, agent_id=owner.id,
|
||||
@@ -265,16 +274,16 @@ def test_an_answer_without_its_three_numbers_is_rejected(
|
||||
owner = hunter(store)
|
||||
[uid] = ranked(store, owner, "1")
|
||||
stub(monkeypatch, lambda items: [{"key": items[0]["key"], "skills": None,
|
||||
"experience": 50, "career": 250,
|
||||
"experience": 5, "career": 25,
|
||||
"strengths": [], "gaps": []}])
|
||||
modeltask.run(judge.TASK, config, store)
|
||||
assert store.judgement(owner.id, uid) is None
|
||||
stub(monkeypatch, lambda items: [{"key": items[0]["key"], "skills": 40.4,
|
||||
"experience": 50, "career": 250,
|
||||
stub(monkeypatch, lambda items: [{"key": items[0]["key"], "skills": 4.4,
|
||||
"experience": 5, "career": 25,
|
||||
"strengths": [], "gaps": []}])
|
||||
modeltask.run(judge.TASK, config, store)
|
||||
found = store.judgement(owner.id, uid)
|
||||
assert found is not None and (found.skills, found.career) == (40, 100)
|
||||
assert found is not None and (found.skills, found.career) == (4, 10)
|
||||
|
||||
|
||||
def test_a_batch_holds_one_agents_pairs_with_that_agents_profile(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""A company's two fetch overrides (see "The agents set the reach of a pull"
|
||||
and "Fetch terms" in `docs/decisions.md`): All countries reads its big boards
|
||||
and "Fetch terms" in `docs/decisions.md`): All locations reads its big boards
|
||||
with the agents' wide reach, All roles with no fetch terms. The four
|
||||
combinations, the reach line, migration 24 and a merge. No network."""
|
||||
|
||||
@@ -53,9 +53,9 @@ def _read(store: Store, target: str) -> tuple[Ask, str]:
|
||||
@pytest.mark.parametrize("countries, roles, line", [
|
||||
(False, False, "follows agents: DK, SE · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(False, True, "follows agents: DK, SE · remote not asked on Phenom · all roles"),
|
||||
(True, False, "all countries (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(True, True, "all countries (Europe) · remote not asked on Phenom · all roles"),
|
||||
], ids=["neither", "all roles alone", "all countries alone", "both"])
|
||||
(True, False, "all locations (Europe) · remote not asked on Phenom · follows agents' terms: data, engineer, product"),
|
||||
(True, True, "all locations (Europe) · remote not asked on Phenom · all roles"),
|
||||
], ids=["neither", "all roles alone", "all locations alone", "both"])
|
||||
def test_the_four_combinations(store: Store, countries: bool, roles: bool, line: str) -> None:
|
||||
_board(store, PHILIPS, "Philips")
|
||||
store.set_all_countries("philips", countries)
|
||||
@@ -122,7 +122,7 @@ def test_migration_24_splits_the_tag_and_moves_terms_off(tmp_path: Path) -> None
|
||||
conn.execute("UPDATE companies SET all_roles=1 WHERE key='mistral-ai'")
|
||||
conn.execute("PRAGMA user_version = 23")
|
||||
migrated = Store(path)
|
||||
assert migrated.migrations_applied == [24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
flags = {c.key: (c.all_countries, c.all_roles) for c in migrated.companies()}
|
||||
assert flags == {"mistral-ai": (1, 1), "acme": (0, 1), "plain": (0, 0)}
|
||||
params = {s.target: s.params for s in migrated.subscriptions(source="ats")}
|
||||
|
||||
+1
-1
@@ -316,7 +316,7 @@ def test_migration_22_fills_the_host_words_from_raw(tmp_path: Path) -> None:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
one = row(migrated, "1")
|
||||
assert (one["seniority_host"], one["employment_host"], one["remote_host"],
|
||||
one["country_host"]) == ("senior", "full_time", "true", "DK")
|
||||
|
||||
+3
-3
@@ -117,7 +117,7 @@ def test_a_company_tagged_all_roles_is_read_across_the_require_reach(store: Stor
|
||||
# Europe, and the base's remote, which a tag never reads less than.
|
||||
assert why == "countries" and {"DE", "FR", "DK"} <= wide.countries and wide.remote
|
||||
# The gate lists Europe's countries one by one; the line names the continent.
|
||||
assert reach.line(plan, subs["workday:mistral"]) == "all countries (Europe) · all roles"
|
||||
assert reach.line(plan, subs["workday:mistral"]) == "all locations (Europe) · all roles"
|
||||
assert plan.why(subs["workday:acme"]) == (plan.base, "agents")
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ def test_a_tag_asks_phenom_for_europe_in_one_request(store: Store) -> None:
|
||||
store.set_all_countries("mistral-ai", True)
|
||||
[sub] = store.subscriptions(source="ats")
|
||||
found = reach.plan(store)
|
||||
assert reach.line(found, sub) == "all countries (Europe) · remote not asked on Phenom · all roles"
|
||||
assert reach.line(found, sub) == "all locations (Europe) · remote not asked on Phenom · all roles"
|
||||
|
||||
|
||||
def test_an_agent_without_a_required_place_makes_the_tag_everywhere(store: Store) -> None:
|
||||
@@ -157,7 +157,7 @@ def test_an_agent_without_a_required_place_makes_the_tag_everywhere(store: Store
|
||||
[sub] = store.subscriptions(source="ats")
|
||||
assert plan.why(sub) == (reach.EVERYWHERE, "countries")
|
||||
assert plan.for_subscription(sub) is None
|
||||
assert reach.line(plan, sub) == "all countries (everywhere): read whole"
|
||||
assert reach.line(plan, sub) == "all locations (everywhere): read whole"
|
||||
|
||||
|
||||
def test_a_boards_own_reach_wins_over_the_tag(store: Store) -> None:
|
||||
|
||||
@@ -530,7 +530,7 @@ def test_migration_27_keeps_an_older_readers_remote_as_the_hosts_word(tmp_path:
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [27, 28, 29, 30, 31, 32, 33]
|
||||
assert migrated.gazetteer().anywhere is not None
|
||||
row = migrated._row("SELECT remote_host, remote_model, remote_where_model FROM roles "
|
||||
"WHERE uid = ?", (board,))
|
||||
@@ -540,7 +540,7 @@ def test_migration_27_keeps_an_older_readers_remote_as_the_hosts_word(tmp_path:
|
||||
assert area(migrated, search.uid) == ("", "")
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 26")
|
||||
assert Store(path).migrations_applied == [27, 28, 29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [27, 28, 29, 30, 31, 32, 33]
|
||||
|
||||
|
||||
def test_a_role_waits_for_extract_until_it_was_asked_where(store: Store) -> None:
|
||||
|
||||
+2
-2
@@ -443,7 +443,7 @@ def test_a_favourite_is_gated_by_a_require_gate_it_fails(
|
||||
def test_all_countries_passes_the_any_group_a_favourite_does_not(
|
||||
store: Store, config: Config, fake: FakeEmbedder) -> None:
|
||||
""""Denmark or remote" gates the onsite German role of a neutral company
|
||||
and of a favourite, and lets the same role of an All countries company
|
||||
and of a favourite, and lets the same role of an All locations company
|
||||
through."""
|
||||
for name in ("Fave", "Wide", "Other"):
|
||||
store.add_company(name)
|
||||
@@ -465,7 +465,7 @@ def test_all_countries_passes_the_any_group_a_favourite_does_not(
|
||||
|
||||
|
||||
def test_all_countries_skips_the_place_part_and_all_roles_the_titles() -> None:
|
||||
"""The region applies to every company; All countries lifts the `any`
|
||||
"""The region applies to every company; All locations lifts the `any`
|
||||
group, All roles the exclude gates on title and no other exclude gate."""
|
||||
gates = [Gate(field="country", values=["DK", "SE", "EU"]),
|
||||
Gate(field="country", values=["DK"], mode="any"),
|
||||
|
||||
+56
-28
@@ -71,7 +71,7 @@ def test_schema_creates_on_an_empty_file(tmp_path: Path) -> None:
|
||||
"application_events", "agents", "scores", "state"} <= tables
|
||||
assert "idx_roles_cluster" in indexes
|
||||
assert store.migrations_applied == []
|
||||
assert LATEST == 32
|
||||
assert LATEST == 33
|
||||
# A second open finds it current and applies nothing.
|
||||
assert Store(path).migrations_applied == []
|
||||
|
||||
@@ -191,7 +191,7 @@ def test_a_v14_file_gains_the_watchlist_columns_and_leaves_companies_unrated(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.ats, acme.careers_url) == ("teamtailor", "https://a.example")
|
||||
@@ -396,7 +396,7 @@ def test_v14_makes_each_intent_the_agents_one_prompt_with_its_vector(tmp_path: P
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert migrated.agent(backend.id).prompts == [ # type: ignore[union-attr]
|
||||
Prompt(name="Backend", text="python backend")]
|
||||
assert migrated.agent(blank.id).prompts == [] # type: ignore[union-attr]
|
||||
@@ -420,7 +420,7 @@ def test_v16_gives_a_company_no_reason_and_keeps_its_row(tmp_path: Path) -> None
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
acme = migrated.company("acme")
|
||||
assert acme is not None
|
||||
assert (acme.careers_url, acme.notes, acme.hand_reason) == (
|
||||
@@ -449,7 +449,7 @@ def test_v17_folds_every_place_and_levels_the_titles_extract_has_not_read(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
with sqlite3.connect(path) as conn:
|
||||
rows = {uid: (fold, level) for uid, fold, level in conn.execute(
|
||||
"SELECT uid, place_fold, seniority FROM roles")}
|
||||
@@ -691,7 +691,7 @@ def test_v19_gives_every_role_its_places_and_splits_its_level(tmp_path: Path) ->
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
assert [p.name for p in migrated.role_places(joined.uid)] == ["Copenhagen", "Malmö"]
|
||||
assert [p.name for p in migrated.role_places(detailed.uid)] == ["Aarhus"]
|
||||
assert migrated.role_places(stated.uid) == []
|
||||
@@ -733,7 +733,7 @@ def test_v25_clears_the_model_levels_the_ladder_splits_and_sets_the_level(
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [25, 26, 27, 28, 29, 30, 31, 32, 33]
|
||||
with sqlite3.connect(path) as conn:
|
||||
found = {sid: rest for sid, *rest in conn.execute(
|
||||
"SELECT source_id, seniority_model, seniority_stated, seniority_title, seniority "
|
||||
@@ -751,12 +751,12 @@ def test_v26_adds_posting_url_empty_and_runs_twice_without_harm(tmp_path: Path)
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [26, 27, 28, 29, 30, 31, 32]
|
||||
assert migrated.migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33]
|
||||
role = migrated.role(posting("a").uid)
|
||||
assert role is not None and role.posting_url == ""
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 25") # the column is there already
|
||||
assert Store(path).migrations_applied == [26, 27, 28, 29, 30, 31, 32]
|
||||
assert Store(path).migrations_applied == [26, 27, 28, 29, 30, 31, 32, 33]
|
||||
|
||||
|
||||
def test_a_pull_keeps_the_posting_url(store: Store) -> None:
|
||||
@@ -1005,7 +1005,7 @@ def test_the_newest_feed_query_uses_the_partial_posted_at_index(
|
||||
upsert(store, posting("1"))
|
||||
sql, _ = store._roles_from(
|
||||
company=None, place=None, open_only=True, q=None, function=None, remote=None,
|
||||
days=None, hide_muted=False, include_read=True, tags=(), tag_mode="any",
|
||||
days=None, include_read=True, tags=(), tag_mode="any",
|
||||
agent=None, by_score=True, gated=False, judged=None)
|
||||
assert "INDEXED BY" not in sql # the hint belongs to roles(), not the shared builder
|
||||
|
||||
@@ -1171,7 +1171,7 @@ def test_open_companies_and_places_are_what_the_rail_suggests_from(store: Store)
|
||||
assert sorted(store.open_places()) == [("Gentofte", "DK", 2), ("Malmö", "SE", 2)]
|
||||
|
||||
|
||||
def test_roles_hide_muted_excludes_before_the_limit(store: Store, clock: Clock) -> None:
|
||||
def test_roles_leave_out_a_hidden_company_before_the_limit(store: Store, clock: Clock) -> None:
|
||||
agent = store.save_agent("A")
|
||||
store.add_company("Acme", key="acme")
|
||||
store.set_affinity(agent.id, "acme", -1)
|
||||
@@ -1180,18 +1180,18 @@ def test_roles_hide_muted_excludes_before_the_limit(store: Store, clock: Clock)
|
||||
for i in range(3):
|
||||
upsert(store, posting(f"a{i}", company="Acme"))
|
||||
clock.tick()
|
||||
# Acme's roles are the three newest, so a plain limit=1 shows only Acme;
|
||||
# hide_muted has to reach past all three to find "other" rather than
|
||||
# just dropping Acme's rows out of an already-limited page.
|
||||
# Acme's roles are the three newest, so a plain limit=1 would show only
|
||||
# Acme; leaving it out has to reach past all three to find "other"
|
||||
# rather than just dropping Acme's rows out of an already-limited page.
|
||||
listing = {"agent": agent.id, "by_score": False}
|
||||
assert [r.source_id for r in store.roles(limit=1, **listing)] == ["a2"]
|
||||
assert [r.source_id for r in store.roles(limit=1, hide_muted=True, **listing)] == ["other"]
|
||||
assert {r.source_id for r in store.roles(hide_muted=True, **listing)} == {"other"}
|
||||
assert {r.source_id for r in store.roles(**listing)} == {"a0", "a1", "a2", "other"}
|
||||
assert [r.source_id for r in store.roles(limit=1, **listing)] == ["other"]
|
||||
assert {r.source_id for r in store.roles(**listing)} == {"other"}
|
||||
assert store.count_roles(**listing) == 1
|
||||
assert sum(n for _, n in store.role_facets(**listing)["seniority"]) == 1
|
||||
# Hidden is per agent: another agent, or no agent, hides nothing.
|
||||
other = store.save_agent("B")
|
||||
assert store.count_roles(hide_muted=True, agent=other.id, by_score=False) == 4
|
||||
assert store.count_roles(hide_muted=True) == 4
|
||||
assert store.count_roles(agent=other.id, by_score=False) == 4
|
||||
assert store.count_roles() == 4
|
||||
|
||||
|
||||
def test_roles_page_by_offset_and_count_the_same_filter(
|
||||
@@ -1206,7 +1206,7 @@ def test_roles_page_by_offset_and_count_the_same_filter(
|
||||
agent = store.save_agent("A")
|
||||
store.add_company("Other", key="other")
|
||||
store.set_affinity(agent.id, "other", -1)
|
||||
assert store.count_roles(hide_muted=True, agent=agent.id, by_score=False) == 3
|
||||
assert store.count_roles(agent=agent.id, by_score=False) == 3
|
||||
|
||||
|
||||
def test_a_vote_is_stamped_cleared_and_filtered(store: Store, clock: Clock) -> None:
|
||||
@@ -1383,21 +1383,20 @@ def test_roles_filters_by_tags_any_and_all(store: Store) -> None:
|
||||
store.roles(tags=["python"], tag_mode="maybe")
|
||||
|
||||
|
||||
def test_tag_counts_orders_by_count_then_tag_and_respects_muted(store: Store) -> None:
|
||||
def test_tag_counts_orders_by_count_then_tag_and_leaves_out_hidden(store: Store) -> None:
|
||||
store.add_company("Hidden", key="hidden")
|
||||
agent = store.save_agent("A")
|
||||
store.set_affinity(agent.id, "hidden", -1)
|
||||
upsert(store, posting("1", company="Acme"))
|
||||
upsert(store, posting("2", company="Acme"))
|
||||
upsert(store, posting("3", company="Hidden"))
|
||||
uid = {r.source_id: r.uid for r in store.roles(hide_muted=False)}
|
||||
uid = {r.source_id: r.uid for r in store.roles()}
|
||||
store.set_tags(uid["1"], ["python", "backend"])
|
||||
store.set_tags(uid["2"], ["python"])
|
||||
store.set_tags(uid["3"], ["python", "backend"])
|
||||
store.set_read(uid["1"])
|
||||
|
||||
assert store.tag_counts(agent.id) == [("python", 2, 1), ("backend", 1, 0)]
|
||||
assert store.tag_counts(agent.id, show_muted=True) == [("python", 3, 2), ("backend", 2, 1)]
|
||||
assert store.tag_counts() == [("python", 3, 2), ("backend", 2, 1)] # no agent, nothing hidden
|
||||
|
||||
|
||||
@@ -1774,11 +1773,40 @@ def test_summarise_waits_on_the_top_of_each_enabled_agent_by_its_own_limits(
|
||||
assert [r.uid for r in store.summarise_waiting(10, uids=[d])] == [d]
|
||||
store.save_agent("Two", "python backend", agent_id=two.id, limits=Limits(summarise_top=0))
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a}
|
||||
# '{}' is the defaults, 50 deep.
|
||||
# '{}' is the defaults, 30 deep.
|
||||
with store.transaction() as conn:
|
||||
conn.execute("UPDATE agents SET limits = '{}'")
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, b, c}
|
||||
assert store.agents()[0].limits == Limits()
|
||||
assert Limits().summarise_top == 30
|
||||
|
||||
|
||||
def test_summarise_waits_on_the_top_of_the_want_and_the_match_order(store: Store) -> None:
|
||||
"""An agent with a CV adds the top of its match order to the top of its
|
||||
want order: the judged roles by `cv_score`, then the rest by `cv_fit`,
|
||||
as `order=cv` lists them. Without a prompt only the match top counts,
|
||||
without a CV only the want top, which the vote moves as in the feed."""
|
||||
for sid in "abcd":
|
||||
upsert(store, posting(sid))
|
||||
a, b, c, d = (posting(s).uid for s in "abcd")
|
||||
both = store.save_agent("Both", "python backend", cv_text="Python engineer.",
|
||||
limits=Limits(summarise_top=1))
|
||||
store.replace_scores(both.id, [(a, 0.9, "", "", 0.1), (b, 0.5, "", "", 0.95),
|
||||
(c, 0.4, "", "", 0.2), (d, 0.3, "remote", "", 0.99)])
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, b}
|
||||
# A judged role leads the match order whatever its closeness.
|
||||
assert store.set_judgement(both.id, c, "key", 6, 6, 6, [], [])
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a, c}
|
||||
|
||||
store.save_agent("Both", agent_id=both.id, prompts=[], cv_text="Python engineer.",
|
||||
limits=Limits(summarise_top=1))
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {c}
|
||||
|
||||
store.save_agent("Both", "python backend", agent_id=both.id, cv_text="",
|
||||
limits=Limits(summarise_top=1))
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {a}
|
||||
store.set_vote(both.id, a, -1) # 0.9 halved falls below b's 0.5
|
||||
assert {r.uid for r in store.summarise_waiting(10)} == {b}
|
||||
|
||||
|
||||
# ------------------------------------------------------------- migration 32
|
||||
@@ -1827,7 +1855,7 @@ def test_v32_resets_the_limits_drops_prefer_gates_and_renames_enrich(tmp_path: P
|
||||
|
||||
migrated = Store(path)
|
||||
|
||||
assert migrated.migrations_applied == [32]
|
||||
assert migrated.migrations_applied == [32, 33]
|
||||
by_name = {a.name: a for a in migrated.agents()}
|
||||
assert by_name["Wolf"].limits == Limits() == by_name["Bare"].limits
|
||||
assert [(g.field, g.mode) for g in by_name["Wolf"].gates] == [
|
||||
@@ -1852,14 +1880,14 @@ def test_v32_runs_twice_and_keeps_limits_set_since(tmp_path: Path) -> None:
|
||||
store = Store(path)
|
||||
agent = store.save_agent("Wolf", limits=Limits(cut_fit_top=900))
|
||||
_v31(path)
|
||||
assert Store(path).migrations_applied == [32]
|
||||
assert Store(path).migrations_applied == [32, 33]
|
||||
assert Store(path).agent(agent.id).limits == Limits() # type: ignore[union-attr]
|
||||
narrow = Limits(cut_fit_top=900, summarise_top=10)
|
||||
store.save_agent("Wolf", agent_id=agent.id, limits=narrow)
|
||||
with sqlite3.connect(path) as conn:
|
||||
conn.execute("PRAGMA user_version = 31") # the columns are there already
|
||||
again = Store(path)
|
||||
assert again.migrations_applied == [32]
|
||||
assert again.migrations_applied == [32, 33]
|
||||
assert again.agent(agent.id).limits == narrow # type: ignore[union-attr]
|
||||
|
||||
|
||||
|
||||
+10
-7
@@ -279,7 +279,7 @@ def test_list_roles_limit_is_bounded(client: TestClient, store: Store) -> None:
|
||||
assert client.get("/api/roles", params={"limit": 1001}).status_code == 422
|
||||
|
||||
|
||||
def test_muted_roles_are_hidden_unless_show_muted(client: TestClient, store: Store) -> None:
|
||||
def test_a_hidden_companys_roles_are_never_shown(client: TestClient, store: Store) -> None:
|
||||
store.add_company("Acme", key="acme")
|
||||
upsert(store, posting("1", company="Acme"))
|
||||
upsert(store, posting("2", company="Other"))
|
||||
@@ -296,7 +296,10 @@ def test_muted_roles_are_hidden_unless_show_muted(client: TestClient, store: Sto
|
||||
# without `agent` hides for.
|
||||
assert client.post("/api/companies/acme/affinity", json={"affinity": -1}).status_code == 200
|
||||
assert shown() == {uid["2"]}
|
||||
assert shown(show_muted="true") == {uid["1"], uid["2"]}
|
||||
# `show_muted` is gone: the parameter is ignored and lifts nothing.
|
||||
assert shown(show_muted="true") == {uid["2"]}
|
||||
assert shown(agent=agent.id) == {uid["2"]}
|
||||
assert client.get("/api/roles", params={"agent": agent.id}).json()["total"] == 1
|
||||
assert shown(agent=agent.id, order="newest") == {uid["2"]}
|
||||
# Hidden is per agent: the other agent still sees Acme.
|
||||
assert shown(agent=other.id, order="newest") == {uid["1"], uid["2"]}
|
||||
@@ -528,14 +531,14 @@ def test_list_roles_filters_by_tags_any_and_all(client: TestClient, store: Store
|
||||
assert item["tags"] == ["backend", "python"]
|
||||
|
||||
|
||||
def test_filters_lists_tag_counts_and_respects_show_muted(
|
||||
def test_filters_lists_tag_counts_without_a_hidden_company(
|
||||
client: TestClient, store: Store) -> None:
|
||||
store.add_company("Hidden", key="hidden")
|
||||
agent = store.save_agent("A") # the default agent, whose hidden companies count
|
||||
store.set_affinity(agent.id, "hidden", -1)
|
||||
upsert(store, posting("1", company="Acme"))
|
||||
upsert(store, posting("2", company="Hidden"))
|
||||
uid = {r.source_id: r.uid for r in store.roles(hide_muted=False)}
|
||||
uid = {r.source_id: r.uid for r in store.roles()}
|
||||
store.set_tags(uid["1"], ["python"])
|
||||
store.set_tags(uid["2"], ["python"])
|
||||
|
||||
@@ -544,7 +547,7 @@ def test_filters_lists_tag_counts_and_respects_show_muted(
|
||||
assert res.json() == {"tags": [{"tag": "python", "count": 1, "unread": 1}]}
|
||||
|
||||
muted = client.get("/api/filters", params={"show_muted": "true"})
|
||||
assert muted.json() == {"tags": [{"tag": "python", "count": 2, "unread": 2}]}
|
||||
assert muted.json() == {"tags": [{"tag": "python", "count": 1, "unread": 1}]}
|
||||
|
||||
|
||||
def test_one_role_and_its_read_page(client: TestClient, store: Store) -> None:
|
||||
@@ -1204,7 +1207,7 @@ def test_an_agents_limits_are_saved_listed_and_checked(client: TestClient) -> No
|
||||
outside 0..1 and a key from before the cut are refused."""
|
||||
default = client.post("/api/agents", json={"name": "Wide"}).json()
|
||||
assert default["limits"] == {"cut_fit_top": 500, "cut_fit_min": 0.6,
|
||||
"cut_cv_top": 150, "cut_cv_min": 0.6, "summarise_top": 50}
|
||||
"cut_cv_top": 150, "cut_cv_min": 0.6, "summarise_top": 30}
|
||||
narrow = {"cut_fit_top": 50, "cut_fit_min": 0.7, "cut_cv_top": 10, "cut_cv_min": 0.75,
|
||||
"summarise_top": 5}
|
||||
saved = client.post("/api/agents", json={"name": "Narrow", "limits": narrow})
|
||||
@@ -1916,7 +1919,7 @@ def test_saved_filters_are_listed_saved_and_deleted_per_agent(
|
||||
|
||||
def test_an_override_queues_a_rescore_and_fetch_text_either_way(
|
||||
client: TestClient, store: Store, queue: Any) -> None:
|
||||
"""All countries and All roles change the agents' fetch gates for the
|
||||
"""All locations and All roles change the agents' fetch gates for the
|
||||
roles already stored, so either switch, on or off, rescores."""
|
||||
states = ("queued", "running", "done", "failed", "cancelled")
|
||||
store.add_company("Acme")
|
||||
|
||||
@@ -108,7 +108,7 @@ def test_all_countries_reads_the_wide_reach_and_on_queues_a_pull(
|
||||
row = _row(client)
|
||||
# Wolf requires no place, so the wide reach is everywhere.
|
||||
assert (row["all_countries"], row["all_roles"], row["reach"]) == (
|
||||
True, False, "all countries (everywhere): read whole")
|
||||
True, False, "all locations (everywhere): read whole")
|
||||
# A board's own countries win over it.
|
||||
client.post(f"/api/sources/{bosch}/reach", json={"mode": "own", "countries": ["DE"]})
|
||||
assert _row(client)["reach"] == "set here: DE · all roles"
|
||||
|
||||
Reference in new issue
Block a user