本文整理汇总了Python中recore.fsm.FSM.update_state方法的典型用法代码示例。如果您正苦于以下问题:Python FSM.update_state方法的具体用法?Python FSM.update_state怎么用?Python FSM.update_state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类recore.fsm.FSM
的用法示例。
在下文中一共展示了FSM.update_state方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_missing_state
# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import update_state [as 别名]
def test_update_missing_state(self):
"""We notice if no document was found to update"""
f = FSM(state_id)
f.state_coll = mock.MagicMock(spec=pymongo.collection.Collection,
return_value=True)
f.state_coll.update.return_value = None
_update_state = {
'$set': {
'ended': UTCNOW
}
}
with self.assertRaises(Exception):
f.update_state(_update_state)
示例2: test_update_state_mongo_failed
# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import update_state [as 别名]
def test_update_state_mongo_failed(self):
"""We notice if mongo failed while updating state"""
f = FSM(state_id)
f.state_coll = mock.MagicMock(spec=pymongo.collection.Collection,
return_value=True)
mocked_update = mock.MagicMock(side_effect=pymongo.errors.PyMongoError)
f.state_coll.update = mocked_update
_update_state = {
'$set': {
'ended': UTCNOW
}
}
with self.assertRaises(pymongo.errors.PyMongoError):
f.update_state(_update_state)
示例3: test_update_state
# 需要导入模块: from recore.fsm import FSM [as 别名]
# 或者: from recore.fsm.FSM import update_state [as 别名]
def test_update_state(self):
"""State updating does the needful"""
f = FSM(state_id)
f.state_coll = mock.MagicMock(spec=pymongo.collection.Collection,
return_value=True)
_update_state = {
'$set': {
'ended': UTCNOW
}
}
# FSM Sets its state document ID attr properly
self.assertEqual(f._id, fsm__id)
f.update_state(_update_state)
# FSM passes the needful to the update method
f.state_coll.update.assert_called_once_with(fsm__id,
_update_state)