test: cover cancel_pending_job
This commit is contained in:
@@ -162,3 +162,29 @@ def test_get_pending_job_returns_dump(monkeypatch):
|
|||||||
def test_get_pending_job_unknown_raises():
|
def test_get_pending_job_unknown_raises():
|
||||||
with pytest.raises(KeyError):
|
with pytest.raises(KeyError):
|
||||||
submit.get_pending_job("missing")
|
submit.get_pending_job("missing")
|
||||||
|
|
||||||
|
|
||||||
|
# --- cancel_pending_job ---
|
||||||
|
|
||||||
|
def test_cancel_pending_job_marks_cancelled(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.cancel_pending_job(pid)
|
||||||
|
assert out == {"pending_id": pid, "status": "CANCELLED"}
|
||||||
|
assert submit.pending_store.get(pid).status == "CANCELLED"
|
||||||
|
|
||||||
|
|
||||||
|
def test_cancel_pending_job_unknown_raises():
|
||||||
|
with pytest.raises(KeyError):
|
||||||
|
submit.cancel_pending_job("missing")
|
||||||
|
|
||||||
|
|
||||||
|
def test_cancel_pending_job_refuses_submitted(monkeypatch):
|
||||||
|
submit.prepare_submit_job(connection="prod", script_path="/tmp/j.py")
|
||||||
|
pid = _last_pending_id()
|
||||||
|
p = submit.pending_store.get(pid)
|
||||||
|
p.status = "SUBMITTED"
|
||||||
|
submit.pending_store.save(p)
|
||||||
|
with pytest.raises(ValueError, match="SUBMITTED"):
|
||||||
|
submit.cancel_pending_job(pid)
|
||||||
|
|||||||
Reference in New Issue
Block a user