feat: add list_pending_jobs and get_pending_job
This commit is contained in:
@@ -130,3 +130,35 @@ def test_confirm_marks_failed_on_spark_submit_error(monkeypatch):
|
||||
p = submit.pending_store.get(pid)
|
||||
assert p.status == "FAILED"
|
||||
assert "boom" in (p.error or "")
|
||||
|
||||
|
||||
# --- list_pending_jobs ---
|
||||
|
||||
def test_list_pending_jobs_empty():
|
||||
assert submit.list_pending_jobs() == []
|
||||
|
||||
|
||||
def test_list_pending_jobs_returns_all(monkeypatch):
|
||||
monkeypatch.setattr(submit, "run_spark_submit", lambda cmd: None)
|
||||
submit.prepare_submit_job(connection="prod", script_path="/tmp/a.py")
|
||||
submit.prepare_submit_job(connection="prod", script_path="/tmp/b.py")
|
||||
out = submit.list_pending_jobs()
|
||||
assert {p["script_path"] for p in out} == {"/tmp/a.py", "/tmp/b.py"}
|
||||
assert all(p["status"] == "PENDING" for p in out)
|
||||
|
||||
|
||||
# --- get_pending_job ---
|
||||
|
||||
def test_get_pending_job_returns_dump(monkeypatch):
|
||||
monkeypatch.setattr(submit, "run_spark_submit", lambda cmd: None)
|
||||
submit.prepare_submit_job(connection="prod", script_path="/tmp/j.py")
|
||||
pid = _last_pending_id()
|
||||
out = submit.get_pending_job(pid)
|
||||
assert out["pending_id"] == pid
|
||||
assert out["connection"] == "prod"
|
||||
assert out["status"] == "PENDING"
|
||||
|
||||
|
||||
def test_get_pending_job_unknown_raises():
|
||||
with pytest.raises(KeyError):
|
||||
submit.get_pending_job("missing")
|
||||
|
||||
Reference in New Issue
Block a user