예제 #1
0
class TestDecorator(TestCase):
    def setUp(self):
        self.job = FunctionJob(fetch_on_miss=False)

    def test_wrapping_argless_function(self):
        self.assertIsNone(self.job.get(fetch))
        self.assertEqual((1, 2, 3), self.job.get(fetch))

    def test_wrapping_function(self):
        self.assertIsNone(self.job.get(fetch_with_args, 'testing'))
        self.assertEqual(('testing', ), self.job.get(fetch_with_args,
                                                     'testing'))
예제 #2
0
class TestDecorator(TestCase):

    def setUp(self):
        self.job = FunctionJob(fetch_on_miss=False)

    def test_wrapping_argless_function(self):
        self.assertIsNone(self.job.get(fetch))
        self.assertEqual((1, 2, 3), self.job.get(fetch))

    def test_wrapping_function(self):
        self.assertIsNone(self.job.get(fetch_with_args, 'testing'))
        self.assertEqual(('testing',),
                         self.job.get(fetch_with_args, 'testing'))
예제 #3
0
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})
예제 #4
0
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})