Jobs: fix return value of remove_by_uid

And add a test for said return value.
This commit is contained in:
Houkime 2022-11-30 17:06:43 +00:00
parent 5c86706f4b
commit 063dfafc19
2 changed files with 12 additions and 1 deletions

View file

@ -115,7 +115,9 @@ class Jobs:
"""
r = RedisPool().get_connection()
key = _redis_key_from_uuid(job_uuid)
r.delete(key)
if (r.exists(key)):
r.delete(key)
return True
return False
@staticmethod

View file

@ -20,6 +20,15 @@ def test_minimal_update(jobs_with_one_job):
assert jobs.get_jobs() == [test_job]
def test_remove_by_uid(jobs_with_one_job):
test_job = jobs_with_one_job.get_jobs()[0]
uid_str = str(test_job.uid)
assert jobs_with_one_job.remove_by_uid(uid_str)
assert jobs_with_one_job.get_jobs() == []
assert not jobs_with_one_job.remove_by_uid(uid_str)
def test_remove_update_nonexistent(jobs_with_one_job):
test_job = jobs_with_one_job.get_jobs()[0]