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

encode / decode _process_results option #170

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions furious/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,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 @@ -619,6 +623,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 @@ -961,6 +961,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