def test_init_kwargs(self): assert FunctionJob().get_init_kwargs() == { 'lifetime': 600, 'cache_alias': 'default'} assert FunctionJob(lifetime=30).get_init_kwargs() == { 'lifetime': 30, 'cache_alias': 'default'} assert FunctionJob(cache_alias='secondary').get_init_kwargs() == { 'lifetime': 600, 'cache_alias': 'secondary'}
def test_init(self): job = FunctionJob(lifetime=30, fetch_on_miss=False, cache_alias='secondary', task_options={'foo': 'bar'}) assert job.lifetime == 30 assert job.fetch_on_miss is False assert job.cache_alias is 'secondary' assert job.task_options == {'foo': 'bar'}
def index(request): if 'name' in request.GET: name = request.GET['name'] if 'qs' in request.GET: items = QuerySetFilterJob(models.DummyModel, 10, False).get( name=name) else: items = jobs.KeyedJob().get(name=request.GET['name']) elif 'function' in request.GET: job = FunctionJob() job.fetch_on_miss = False if 'q' in request.GET: items = job.get(fetch_with_arg, request.GET['q']) else: items = job.get(fetch) elif 'decorator' in request.GET: items = decorated('3') else: items = jobs.VanillaJob().get() return render(request, 'index.html', {'items': items})
def test_fetch_decorated(self): assert FunctionJob().fetch('tests.test_jobs:decorated_dummy_function', 'foo') == ('JOB-EXECUTED:foo')
def test_prepare_args(self): job = FunctionJob() assert job.prepare_args(dummy_function, 'foo') == ( 'tests.test_jobs:dummy_function', 'foo', )
def test_init_defaults(self): job = FunctionJob() assert job.lifetime == 600 assert job.fetch_on_miss assert job.cache_alias == 'default' assert job.task_options == {}
def test_prepare_args(self): job = FunctionJob() assert job.prepare_args(dummy_function, 'foo') == ( 'tests.test_jobs:dummy_function', 'foo')