def test_pull_one(self):
     pizza = Pizza.objects.create(name="Vegetarian")
     pull('slumber://pizza/slumber_examples/Pizza/', 'pubsubpull.tests.test_pull.job')
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 4)
     self.check_pizzas([pizza])
 def test_pull_priority(self):
     pizza = Pizza.objects.create(name="Vegetarian")
     pull('slumber://pizza/slumber_examples/Pizza/', 'pubsubpull.tests.test_pull.job',
         pull_priority=7, job_priority=6)
     self.assertEquals(Job.objects.filter(priority=7).count(), 1, Job.objects.all())
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.filter(priority=6).count(), 1, Job.objects.all())
     self.assertEquals(Job.objects.filter(priority=7).count(), 3, Job.objects.all())
Beispiel #3
0
 def test_pull_one(self):
     pizza = Pizza.objects.create(name="Vegetarian")
     pull('slumber://pizza/slumber_examples/Pizza/',
          'pubsubpull.tests.test_pull.job')
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 4)
     self.check_pizzas([pizza])
 def test_pull_eleven(self):
     pizzas = []
     for p in range(1, 12):
         pizzas.append(Pizza.objects.create(name="Pizza %s" % p))
     pull('slumber://pizza/slumber_examples/Pizza/', 'pubsubpull.tests.test_pull.job')
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 15)
     self.check_pizzas(pizzas)
     return pizzas
Beispiel #5
0
 def test_pull_eleven(self):
     pizzas = []
     for p in range(1, 12):
         pizzas.append(Pizza.objects.create(name="Pizza %s" % p))
     pull('slumber://pizza/slumber_examples/Pizza/',
          'pubsubpull.tests.test_pull.job')
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 15)
     self.check_pizzas(pizzas)
     return pizzas
Beispiel #6
0
 def test_api_pull_add_new_job_with_callback_kwargs(self):
     callback_kwargs = dict(param1=10, param2='python')
     pull('slumber://pizza/slumber_examples/Pizza/',
          'pubsubpull.tests.test_pull.callback_with_kwargs',
          callback_kwargs=callback_kwargs)
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 2)
     job_with_callback_kwargs = Job.objects.all()[1]
     self.assertDictEqual(
         callback_kwargs,
         json.loads(job_with_callback_kwargs.kwargs)['callback_kwargs'])
Beispiel #7
0
 def test_api_pull_add_new_job_with_callback_kwargs(self):
     callback_kwargs = dict(param1=10,
                            param2='python')
     pull('slumber://pizza/slumber_examples/Pizza/',
          'pubsubpull.tests.test_pull.callback_with_kwargs',
          callback_kwargs=callback_kwargs)
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 2)
     job_with_callback_kwargs = Job.objects.all()[1]
     self.assertDictEqual(callback_kwargs,
                          json.loads(job_with_callback_kwargs.kwargs)['callback_kwargs'])
Beispiel #8
0
 def test_pull_priority(self):
     pizza = Pizza.objects.create(name="Vegetarian")
     pull('slumber://pizza/slumber_examples/Pizza/',
          'pubsubpull.tests.test_pull.job',
          pull_priority=7,
          job_priority=6)
     self.assertEquals(
         Job.objects.filter(priority=7).count(), 1, Job.objects.all())
     management.call_command('flush_queue')
     self.assertEquals(
         Job.objects.filter(priority=6).count(), 1, Job.objects.all())
     self.assertEquals(
         Job.objects.filter(priority=7).count(), 3, Job.objects.all())
Beispiel #9
0
 def test_pull_eleven(self):
     pizzas = [Pizza.objects.create(name="Pizza {}".format(i)) for i in range(1, 12)]
     callback_kwargs = dict(param1=10,
                            param2='python')
     pull('slumber://pizza/slumber_examples/Pizza/',
          'pubsubpull.tests.test_pull.callback_with_kwargs',
          callback_kwargs=callback_kwargs)
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 15)
     # every jobs added by pull should call callback with kwargs
     jobs_with_callback_kwargs = Job.objects.filter(name='pubsubpull.tests.test_pull.callback_with_kwargs')
     for _job in jobs_with_callback_kwargs:
         self.assertDictEqual(callback_kwargs,
                              json.loads(_job.kwargs))
Beispiel #10
0
 def test_pull_eleven(self):
     pizzas = [
         Pizza.objects.create(name="Pizza {}".format(i))
         for i in range(1, 12)
     ]
     callback_kwargs = dict(param1=10, param2='python')
     pull('slumber://pizza/slumber_examples/Pizza/',
          'pubsubpull.tests.test_pull.callback_with_kwargs',
          callback_kwargs=callback_kwargs)
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 15)
     # every jobs added by pull should call callback with kwargs
     jobs_with_callback_kwargs = Job.objects.filter(
         name='pubsubpull.tests.test_pull.callback_with_kwargs')
     for _job in jobs_with_callback_kwargs:
         self.assertDictEqual(callback_kwargs, json.loads(_job.kwargs))
 def test_empty_pull(self):
     pull('slumber://pizza/slumber_examples/Pizza/', 'pubsubpull.tests.test_pull.job')
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 2)
Beispiel #12
0
 def test_empty_pull(self):
     pull('slumber://pizza/slumber_examples/Pizza/',
          'pubsubpull.tests.test_pull.job')
     self.assertEquals(Job.objects.count(), 1)
     management.call_command('flush_queue')
     self.assertEquals(Job.objects.count(), 2)