From f1884a09fd6bb5aea42c33a5ef43a6eb05158fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Palancher?= Date: Wed, 8 Feb 2017 11:15:13 +0100 Subject: [PATCH] Fix PySLURM job find_id() returns a list of job PySLURM >= 16.05 job find_id() method returns a list. The expected job dict is the 1st element of the job. The commit also updates testing mock to reproduce the same behaviour as real PySLURM. Fix #140 --- rest/slurmrestapi.py | 5 +++-- tests/mocks/pyslurm.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rest/slurmrestapi.py b/rest/slurmrestapi.py index 68e89041..9eb1a0fd 100644 --- a/rest/slurmrestapi.py +++ b/rest/slurmrestapi.py @@ -140,8 +140,9 @@ def get_jobs(): @authentication_verify() def show_job(job_id): - # pyslurm >= 16.05 expects a string in parameter of job.find_id() - job = get_from_cache(pyslurm.job.find_id, 'show_job', str(job_id)) + # PySLURM >= 16.05 expects a string in parameter of job.find_id() and + # returns a list. The expected job dict is the 1st element of this list. + job = get_from_cache(pyslurm.job.find_id, 'show_job', str(job_id))[0] onlyUsersJobs = False fill_job_user(job) if auth_enabled: diff --git a/tests/mocks/pyslurm.py b/tests/mocks/pyslurm.py index 826006d3..129b663c 100644 --- a/tests/mocks/pyslurm.py +++ b/tests/mocks/pyslurm.py @@ -875,7 +875,7 @@ def get(self): def find_id(self, jobid): for job in context.CTLD.jobs: if job.jobid == jobid: - return job.todict()[jobid] + return [job.todict()[jobid]] return None class MockPySlurmReservation(object):