示例#1
0
 def test_parse_yaml(self):
     # this test is here to ensure the YAML one has to
     # type looks nice
     worker = object()
     config = yaml.safe_load(self.TEST_YAML)
     middlewares = create_middlewares_from_config(worker, config)
     self.assertEqual([type(mw) for mw in middlewares], [ToyMiddleware, ToyMiddleware])
     self.assertEqual([mw._setup_done for mw in middlewares], [False, False])
示例#2
0
文件: test_base.py 项目: areski/vumi
 def test_create_middleware_from_config(self):
     worker = object()
     middlewares = create_middlewares_from_config(worker,
                                                  self.TEST_CONFIG_1)
     self.assertEqual([type(mw) for mw in middlewares],
                      [ToyMiddleware, ToyMiddleware])
     self.assertEqual([mw._setup_done for mw in middlewares],
                      [False, False])
     self.assertEqual(middlewares[0].config,
                      {"param_foo": 1, "param_bar": 2})
     self.assertEqual(middlewares[1].config, {})
示例#3
0
 def test_create_middleware_from_config(self):
     worker = object()
     middlewares = create_middlewares_from_config(worker, self.TEST_CONFIG_1)
     self.assertEqual([type(mw) for mw in middlewares], [ToyMiddleware, ToyMiddleware])
     self.assertEqual([mw._setup_done for mw in middlewares], [False, False])
     self.assertEqual(middlewares[0].config.param_foo, 1)
     self.assertEqual(middlewares[0].config.param_bar, 2)
     self.assertEqual(middlewares[0].consume_priority, 0)
     self.assertEqual(middlewares[0].publish_priority, 0)
     self.assertEqual(middlewares[1].consume_priority, 1)
     self.assertEqual(middlewares[1].publish_priority, -1)