Exemplo n.º 1
0
 def test_lookup_takes_first(self):
     R = routes.prepare(({"celery.ping": {"queue": "bar"}},
                         {"celery.ping": {"queue": "foo"}}))
     router = routes.Router(R, conf.QUEUES)
     self.assertDictContainsSubset(b_queue,
             router.route({}, "celery.ping",
                 args=[1, 2], kwargs={}))
Exemplo n.º 2
0
 def Router(self, queues=None, create_missing=None):
     """Returns the current task router."""
     return _routes.Router(self.routes,
                           queues or self.queues,
                           self.app.either("CELERY_CREATE_MISSING_QUEUES",
                                           create_missing),
                           app=self.app)
Exemplo n.º 3
0
 def test_lookup_paths_traversed(self):
     R = routes.prepare(({"celery.xaza": {"queue": "bar"}},
                         {"celery.ping": {"queue": "foo"}}))
     router = routes.Router(R, conf.QUEUES)
     self.assertDictContainsSubset(a_queue,
             router.route({}, "celery.ping",
                 args=[1, 2], kwargs={}))
     self.assertEqual(router.route({}, "celery.poza"), {})
Exemplo 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.conf.CELERY_QUEUES)
     self.assertDictContainsSubset(
         b_queue, router.route({}, mytask.name, args=[1, 2], kwargs={}))
Exemplo n.º 5
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.assertDictContainsSubset(
         a_queue, router.route({}, mytask.name, args=[1, 2], kwargs={}))
     self.assertEqual(
         router.route({}, "celery.poza"),
         dict(d_queue, queue=current_app.conf.CELERY_DEFAULT_QUEUE))
Exemplo n.º 6
0
 def test_expands_queue_in_options(self):
     R = routes.prepare(())
     router = routes.Router(R, conf.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},
                          "celery.ping",
                          args=[1, 2], kwargs={})
     self.assertDictContainsSubset({"exchange": "testq",
                                    "routing_key": "testq",
                                    "immediate": False},
                                    route)
     self.assertNotIn("queue", route)
Exemplo n.º 7
0
 def test_init_queues(self):
     router = routes.Router(queues=None)
     self.assertDictEqual(router.queues, {})
Exemplo n.º 8
0
 def expand(answer):
     return routes.Router([], queues).expand_destination(answer)
Exemplo n.º 9
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")