Skip to content

Commit

Permalink
Fix PySLURM job find_id() returns a list of job
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rezib committed Feb 8, 2017
1 parent 26a93af commit f1884a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions rest/slurmrestapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/mocks/pyslurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit f1884a0

Please sign in to comment.