Don't warn for removing unstarted jobs (#4632)

This commit is contained in:
Mike Degatano 2023-10-19 11:35:16 -04:00 committed by GitHub
parent b1010c3c61
commit 010043f116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -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]

View File

@ -22,9 +22,16 @@ 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)
assert job not in coresys.jobs.jobs
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) 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}" in caplog.text