当前位置: 首页>>代码示例>>Python>>正文


Python Shove.parse_order方法代码示例

本文整理汇总了Python中shove.Shove.parse_order方法的典型用法代码示例。如果您正苦于以下问题:Python Shove.parse_order方法的具体用法?Python Shove.parse_order怎么用?Python Shove.parse_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shove.Shove的用法示例。


在下文中一共展示了Shove.parse_order方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_parse_order_valid

# 需要导入模块: from shove import Shove [as 别名]
# 或者: from shove.Shove import parse_order [as 别名]
 def test_parse_order_valid(self):
     """If the given order is valid, return an Order namedtuple with the correct values."""
     shove = Shove({}, Mock())
     order = shove.parse_order('{"project": "asdf", "command": "qwer", "log_key": 77, ' '"log_queue": "zxcv"}')
     eq_(order.project, "asdf")
     eq_(order.command, "qwer")
     eq_(order.log_key, 77)
     eq_(order.log_queue, "zxcv")
开发者ID:uberj,项目名称:shove,代码行数:10,代码来源:test_base.py

示例2: test_process_order_invalid

# 需要导入模块: from shove import Shove [as 别名]
# 或者: from shove.Shove import parse_order [as 别名]
    def test_process_order_invalid(self):
        """If parse_order returns None, do not execute the order."""
        shove = Shove({})
        shove.parse_order = Mock(return_value=None)
        shove.execute = Mock()

        eq_(shove.process_order('{"project": "asdf"}'), None)
        ok_(not shove.execute.called)
开发者ID:mozilla,项目名称:shove,代码行数:10,代码来源:test_base.py

示例3: test_process_order_valid

# 需要导入模块: from shove import Shove [as 别名]
# 或者: from shove.Shove import parse_order [as 别名]
    def test_process_order_valid(self):
        """If parse_order returns a valid order, execute it and send logs back to Captain."""
        shove = Shove({}, Mock())
        order = Order(project="asdf", command="qwer", log_key=23, log_queue="zxcv")
        shove.parse_order = Mock(return_value=order)
        shove.execute = Mock(return_value=(0, "output"))

        shove.process_order('{"project": "asdf"}')
        shove.execute.assert_called_with(order)
        shove.adapter.send_log.assert_called_with(
            "zxcv", JSON({"version": "1.0", "log_key": 23, "return_code": 0, "output": "output"})
        )
开发者ID:uberj,项目名称:shove,代码行数:14,代码来源:test_base.py

示例4: test_process_order_valid

# 需要导入模块: from shove import Shove [as 别名]
# 或者: from shove.Shove import parse_order [as 别名]
    def test_process_order_valid(self):
        """If parse_order returns a valid order, execute it and send logs back to Captain."""
        shove = Shove({})
        order = Order(project='asdf', command='qwer', log_key=23, log_queue='zxcv')
        shove.parse_order = Mock(return_value=order)
        shove.execute = Mock(return_value=(0, 'output'))

        eq_(shove.process_order('{"project": "asdf"}'), ('zxcv', JSON({
            'version': '1.0',
            'log_key': 23,
            'return_code': 0,
            'output': 'output'
        })))
        shove.execute.assert_called_with(order)
开发者ID:mozilla,项目名称:shove,代码行数:16,代码来源:test_base.py

示例5: test_parse_order_missing_key

# 需要导入模块: from shove import Shove [as 别名]
# 或者: from shove.Shove import parse_order [as 别名]
 def test_parse_order_missing_key(self):
     """If the given order is missing a required key, return None."""
     shove = Shove({}, Mock())
     eq_(shove.parse_order('{"project": "asdf"}'), None)
开发者ID:uberj,项目名称:shove,代码行数:6,代码来源:test_base.py

示例6: test_parse_order_heartbeat

# 需要导入模块: from shove import Shove [as 别名]
# 或者: from shove.Shove import parse_order [as 别名]
 def test_parse_order_heartbeat(self):
     """If the given order is a heartbeat command, return None."""
     shove = Shove({}, Mock())
     eq_(shove.parse_order('{"heartbeat": true}'), None)
开发者ID:uberj,项目名称:shove,代码行数:6,代码来源:test_base.py

示例7: test_parse_order_invalid_json

# 需要导入模块: from shove import Shove [as 别名]
# 或者: from shove.Shove import parse_order [as 别名]
 def test_parse_order_invalid_json(self):
     """If the given order isn't valid JSON, return None."""
     shove = Shove({}, Mock())
     eq_(shove.parse_order("{dfinval=3523}}}}]"), None)
开发者ID:uberj,项目名称:shove,代码行数:6,代码来源:test_base.py


注:本文中的shove.Shove.parse_order方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。