Esempio n. 1
0
 def Router(self, queues=None, create_missing=None):
     """Return the current task router."""
     return _routes.Router(self.routes,
                           queues or self.queues,
                           self.app.either('task_create_missing_queues',
                                           create_missing),
                           app=self.app)
Esempio n. 2
0
 def test_lookup_paths_traversed(self):
     R = routes.prepare(({"celery.xaza": {"queue": "bar"}},
                         {mytask.name: {"queue": "foo"}}))
     router = routes.Router(R, current_app.amqp.queues)
     self.assertAnswer(router.route({}, mytask.name,
                       args=[1, 2], kwargs={}), a_queue)
     self.assertAnswer(router.route({}, "celery.poza"),
             dict(d_queue, queue=current_app.conf.CELERY_DEFAULT_QUEUE))
Esempio n. 3
0
 def test_lookup_takes_first(self):
     R = routes.prepare(({
         mytask.name: {
             "queue": "bar"
         }
     }, {
         mytask.name: {
             "queue": "foo"
         }
     }))
     router = routes.Router(R, current_app.conf.CELERY_QUEUES)
     self.assertDictContainsSubset(
         b_queue, router.route({}, mytask.name, args=[1, 2], kwargs={}))
Esempio n. 4
0
 def test_lookup_takes_first(self):
     R = routes.prepare(({
         mytask.name: {
             "queue": "bar"
         }
     }, {
         mytask.name: {
             "queue": "foo"
         }
     }))
     router = routes.Router(R, current_app.amqp.queues)
     self.assertAnswer(
         router.route({}, mytask.name, args=[1, 2], kwargs={}), b_queue)
Esempio n. 5
0
 def test_expands_queue_in_options(self):
     R = routes.prepare(())
     router = routes.Router(R, current_app.amqp.queues,
                            create_missing=True)
     # apply_async forwards all arguments, even exchange=None etc,
     # so need to make sure it's merged correctly.
     route = router.route({"queue": "testq",
                           "exchange": None,
                           "routing_key": None,
                           "immediate": False},
                          mytask.name,
                          args=[1, 2], kwargs={})
     self.assertDictContainsSubset({"routing_key": "testq",
                                    "immediate": False},
                                    route)
     self.assertEqual(route["exchange"].name, "testq")
     self.assertIn("queue", route)
Esempio n. 6
0
def Router(app, *args, **kwargs):
    return routes.Router(*args, app=app, **kwargs)
Esempio n. 7
0
def Router(*args, **kwargs):
    return routes.Router(*args, **dict(kwargs, app=current_app))
Esempio n. 8
0
 def test_init_queues(self):
     router = routes.Router(queues=None)
     self.assertDictEqual(router.queues, {})
Esempio n. 9
0
 def expand(answer):
     return routes.Router([], queues).expand_destination(answer)
Esempio n. 10
0
 def test_expand_destination_string(self):
     x = routes.Router({}, current_app.amqp.queues)
     dest = x.expand_destination("foo")
     self.assertEqual(dest["exchange"].name, "fooexchange")
Esempio n. 11
0
 def test_expand_destaintion_string(self):
     x = routes.Router({}, current_app.conf.CELERY_QUEUES)
     dest = x.expand_destination("foo")
     self.assertEqual(dest["exchange"], "fooexchange")
Esempio n. 12
0
 def test_expand_destination_string(self):
     x = routes.Router({}, current_app.amqp.queues)
     dest = x.expand_destination('foo')
     self.assertEqual(dest['exchange'].name, 'fooexchange')