diff --git a/supervisor/jobs/__init__.py b/supervisor/jobs/__init__.py index 48ab198f8..8ab8eb720 100644 --- a/supervisor/jobs/__init__.py +++ b/supervisor/jobs/__init__.py @@ -190,7 +190,7 @@ class JobManager(FileConfiguration, CoreSysAttributes): if job.uuid not in self._jobs: 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) del self._jobs[job.uuid] diff --git a/tests/jobs/test_job_manager.py b/tests/jobs/test_job_manager.py index b3c849214..b3d953737 100644 --- a/tests/jobs/test_job_manager.py +++ b/tests/jobs/test_job_manager.py @@ -22,12 +22,19 @@ async def test_add_job(coresys: CoreSys): async def test_remove_job_directly(coresys: CoreSys, caplog: pytest.LogCaptureFixture): """Test removing jobs from manager.""" job = coresys.jobs.new_job(TEST_JOB) - 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}" 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):