mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-04-22 04:07:17 +00:00

* Disable job condition for unhealth & unsupported systems * Add JobManager API ignore * Apply suggestions from code review Co-authored-by: Paulus Schoutsen <balloob@gmail.com> * Update tests/resolution/evaluation/test_evaluate_job_conditions.py Co-authored-by: Paulus Schoutsen <balloob@gmail.com> * fix names * address comments * Update decorator.py * adjust security * add reset * Apply suggestions from code review Co-authored-by: Joakim Sørensen <joasoe@gmail.com> Co-authored-by: Paulus Schoutsen <balloob@gmail.com> Co-authored-by: Joakim Sørensen <joasoe@gmail.com>
53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
"""Test Docker API."""
|
|
import pytest
|
|
|
|
from supervisor.jobs.const import ATTR_IGNORE_CONDITIONS, JobCondition
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_api_jobs_info(api_client):
|
|
"""Test jobs info api."""
|
|
resp = await api_client.get("/jobs/info")
|
|
result = await resp.json()
|
|
|
|
assert result["data"][ATTR_IGNORE_CONDITIONS] == []
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_api_jobs_options(api_client, coresys):
|
|
"""Test jobs options api."""
|
|
resp = await api_client.post(
|
|
"/jobs/options", json={ATTR_IGNORE_CONDITIONS: [JobCondition.HEALTHY]}
|
|
)
|
|
result = await resp.json()
|
|
assert result["result"] == "ok"
|
|
|
|
resp = await api_client.get("/jobs/info")
|
|
result = await resp.json()
|
|
assert result["data"][ATTR_IGNORE_CONDITIONS] == [JobCondition.HEALTHY]
|
|
|
|
assert coresys.jobs.save_data.called
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_api_jobs_reset(api_client, coresys):
|
|
"""Test jobs reset api."""
|
|
resp = await api_client.post(
|
|
"/jobs/options", json={ATTR_IGNORE_CONDITIONS: [JobCondition.HEALTHY]}
|
|
)
|
|
result = await resp.json()
|
|
assert result["result"] == "ok"
|
|
|
|
resp = await api_client.get("/jobs/info")
|
|
result = await resp.json()
|
|
assert result["data"][ATTR_IGNORE_CONDITIONS] == [JobCondition.HEALTHY]
|
|
|
|
assert coresys.jobs.save_data.called
|
|
assert coresys.jobs.ignore_conditions == [JobCondition.HEALTHY]
|
|
|
|
resp = await api_client.post("/jobs/reset")
|
|
result = await resp.json()
|
|
assert result["result"] == "ok"
|
|
|
|
assert coresys.jobs.ignore_conditions == []
|