test(pending): regression test for loading records without app_name

This commit is contained in:
Claude
2026-06-26 15:56:36 +08:00
parent 0b4ad578e4
commit a6e99b051c
+34
View File
@@ -126,3 +126,37 @@ def test_delete_returns_true_when_present():
def test_delete_returns_false_when_absent():
assert pending_store.store.delete("nope") is False
def test_loads_records_with_missing_or_null_app_name(tmp_path: Path):
"""Records persisted before app_name became required/optional must still load."""
shard = tmp_path / "pending_jobs" / "2026-06-24.json"
shard.parent.mkdir(parents=True, exist_ok=True)
base = {
"pending_id": "p_no_app",
"connection": "prod",
"master": "yarn",
"deploy_mode": "cluster",
"script_path": "/tmp/j.py",
"queue": "default",
"executor_memory": "4G",
"executor_cores": 2,
"num_executors": 2,
"spark_conf": {},
"created_at": "2026-06-24T00:00:00",
}
missing_app = dict(base, pending_id="p_no_app")
null_app = dict(base, pending_id="p_null_app", app_name=None)
shard.write_text(
json.dumps({"p_no_app": missing_app, "p_null_app": null_app}),
encoding="utf-8",
)
records = pending_store.store.list_all()
assert len(records) == 2
by_id = {r.pending_id: r for r in records}
assert by_id["p_no_app"].app_name is None
assert by_id["p_null_app"].app_name is None
assert pending_store.store.get("p_no_app").app_name is None
assert pending_store.store.get("p_null_app").app_name is None