37 lines
1018 B
Python
37 lines
1018 B
Python
# coding=utf-8
|
|
from datetime import datetime
|
|
from unittest.mock import patch
|
|
|
|
from spark_executor.core.job_store import JobStore
|
|
from spark_executor.models import Job
|
|
from spark_executor.tools import status
|
|
|
|
|
|
def test_get_job_status_returns_state():
|
|
status.store = JobStore()
|
|
status.store.put(
|
|
Job(
|
|
job_id="abc",
|
|
application_id="application_1",
|
|
script_path="/tmp/j.py",
|
|
queue="default",
|
|
submit_time=datetime(2026, 6, 24),
|
|
connection="prod",
|
|
)
|
|
)
|
|
with patch(
|
|
"spark_executor.tools.status.get_application_status",
|
|
return_value=("RUNNING", "State : RUNNING\n"),
|
|
):
|
|
out = status.get_job_status("abc")
|
|
assert out.application_id == "application_1"
|
|
assert out.state == "RUNNING"
|
|
assert "RUNNING" in out.raw
|
|
|
|
|
|
def test_get_job_status_raises_for_unknown_job():
|
|
status.store = JobStore()
|
|
import pytest
|
|
with pytest.raises(KeyError):
|
|
status.get_job_status("missing")
|