mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-10 02:36:29 +00:00
Don't warn for removing unstarted jobs (#4632)
This commit is contained in:
parent
b1010c3c61
commit
010043f116
@ -190,7 +190,7 @@ class JobManager(FileConfiguration, CoreSysAttributes):
|
|||||||
if job.uuid not in self._jobs:
|
if job.uuid not in self._jobs:
|
||||||
raise JobNotFound(f"Could not find job {job.name}", _LOGGER.error)
|
raise JobNotFound(f"Could not find job {job.name}", _LOGGER.error)
|
||||||
|
|
||||||
if not job.done:
|
if job.done is False:
|
||||||
_LOGGER.warning("Removing incomplete job %s from job manager", job.name)
|
_LOGGER.warning("Removing incomplete job %s from job manager", job.name)
|
||||||
|
|
||||||
del self._jobs[job.uuid]
|
del self._jobs[job.uuid]
|
||||||
|
@ -22,12 +22,19 @@ async def test_add_job(coresys: CoreSys):
|
|||||||
async def test_remove_job_directly(coresys: CoreSys, caplog: pytest.LogCaptureFixture):
|
async def test_remove_job_directly(coresys: CoreSys, caplog: pytest.LogCaptureFixture):
|
||||||
"""Test removing jobs from manager."""
|
"""Test removing jobs from manager."""
|
||||||
job = coresys.jobs.new_job(TEST_JOB)
|
job = coresys.jobs.new_job(TEST_JOB)
|
||||||
|
|
||||||
assert job in coresys.jobs.jobs
|
assert job in coresys.jobs.jobs
|
||||||
|
|
||||||
coresys.jobs.remove_job(job)
|
coresys.jobs.remove_job(job)
|
||||||
assert job not in coresys.jobs.jobs
|
assert job not in coresys.jobs.jobs
|
||||||
assert f"Removing incomplete job {job.name}" in caplog.text
|
assert f"Removing incomplete job {job.name}" not in caplog.text
|
||||||
|
|
||||||
|
job = coresys.jobs.new_job(TEST_JOB)
|
||||||
|
assert job in coresys.jobs.jobs
|
||||||
|
|
||||||
|
with job.start():
|
||||||
|
coresys.jobs.remove_job(job)
|
||||||
|
assert job not in coresys.jobs.jobs
|
||||||
|
assert f"Removing incomplete job {job.name}" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_job_done(coresys: CoreSys):
|
async def test_job_done(coresys: CoreSys):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user