Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #170 from andreleblanc-wf/encode-results-processor
Browse files Browse the repository at this point in the history
encode / decode _process_results option
  • Loading branch information
beaulyddon-wf committed Oct 8, 2015
2 parents 78ee1fa + 5792fb3 commit 10d749d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions furious/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ def encode_async_options(async):
_checker = options.pop('_context_checker')
options['__context_checker'] = reference_to_path(_checker)

if '_process_results' in options:
_processor = options.pop('_process_results')
options['__process_results'] = reference_to_path(_processor)

return options


Expand All @@ -628,6 +632,9 @@ def decode_async_options(options):
_checker = options['__context_checker']
async_options['_context_checker'] = path_to_reference(_checker)

if '__process_results' in options:
_processor = options['__process_results']
async_options['_process_results'] = path_to_reference(_processor)
return async_options


Expand Down
16 changes: 16 additions & 0 deletions furious/tests/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,22 @@ def test_context_checker_encoded_and_decoded(self):

self.assertEqual(async_job.to_dict(), new_async_job.to_dict())

def test_process_results_encoded_and_decoded(self):
"""Ensure _process_results is correctly encoded to and decoded from
an Async options dict.
"""
from furious.async import Async

async_job = Async("something", _process_results=locals)

encoded_async = async_job.to_dict()
self.assertEqual(encoded_async['__process_results'], 'locals')

new_async_job = Async.from_dict(encoded_async)
self.assertEqual(new_async_job.get_options()['_process_results'], locals)

self.assertEqual(async_job.to_dict(), new_async_job.to_dict())

def test_retry_value_is_decodable(self):
"""Ensure that from_dict is the inverse of to_dict when retry options
are given.
Expand Down

0 comments on commit 10d749d

Please sign in to comment.