def test_job_properties_set_data_property(): """Data property gets derived from the job tuple.""" job = Job() job.func_name = 'foo' fname, instance, args, kwargs = loads(job.data) assert fname == job.func_name assert not instance assert args == () assert kwargs == {}
def test_custom_meta_is_persisted(redis): """Additional meta data on jobs are stored persisted correctly.""" job = Job.create(func=say_hello, args=('Lionel',)) job.meta['foo'] = 'bar' yield from job.save() raw_data = yield from redis.hget(job.key, 'meta') assert loads(raw_data)['foo'] == 'bar' job2 = yield from Job.fetch(job.id) assert job2.meta['foo'] == 'bar'
def test_save(redis): """Storing jobs.""" job = Job.create(func=some_calculation, args=(3, 4), kwargs=dict(z=2)) # Saving creates a Redis hash assert not (yield from redis.exists(job.key)) yield from job.save() assert (yield from redis.type(job.key)) == b'hash' # Saving writes pickled job data unpickled_data = loads((yield from redis.hget(job.key, 'data'))) assert unpickled_data[0] == 'fixtures.some_calculation'