Skip to content

Commit

Permalink
[jobs] Add _repr_ method
Browse files Browse the repository at this point in the history
This code defines the `_repr_` method for the JobResult class in
order to improve the log messages generated by the redis class
rq.worker.
  • Loading branch information
valeriocos committed Jul 19, 2018
1 parent ecc4e1a commit d996314
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arthur/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ def __init__(self, job_id, task_id, backend, category, last_uuid,
self.offset = offset
self.nresumed = nresumed

def __repr__(self):
return "job id: %s, task id: %s, backend: %s, category: %s, nitems: %s" % \
(self.job_id, self.task_id, self.backend, self.category, self.nitems)


class PercevalJob:
"""Class for wrapping Perceval jobs.
Expand Down
2 changes: 2 additions & 0 deletions tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ def test_job_result_init(self):

self.assertEqual(result.offset, 128)
self.assertEqual(result.nresumed, 10)
self.assertEqual(str(result), 'job id: arthur-job-1234567890, task id: mytask, '
'backend: mock_backend, category: category, nitems: 58')


class TestPercevalJob(TestBaseRQ):
Expand Down

0 comments on commit d996314

Please sign in to comment.