本文整理汇总了Python中dart.client.python.dart_client.Dart.get_action方法的典型用法代码示例。如果您正苦于以下问题:Python Dart.get_action方法的具体用法?Python Dart.get_action怎么用?Python Dart.get_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dart.client.python.dart_client.Dart
的用法示例。
在下文中一共展示了Dart.get_action方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Dart
# 需要导入模块: from dart.client.python.dart_client import Dart [as 别名]
# 或者: from dart.client.python.dart_client.Dart import get_action [as 别名]
from dart.client.python.dart_client import Dart
if __name__ == '__main__':
dart = Dart('localhost', 5000)
assert isinstance(dart, Dart)
action = dart.get_action('8U7H6OLHC5')
action = dart.patch_action(action, order_idx=5)
print 'patched action: %s' % action.id
示例2: TestActionCrud
# 需要导入模块: from dart.client.python.dart_client import Dart [as 别名]
# 或者: from dart.client.python.dart_client.Dart import get_action [as 别名]
class TestActionCrud(unittest.TestCase):
def setUp(self):
self.dart = Dart(host='localhost', port=5000)
args = {'action_sleep_time_in_seconds': 0}
dst = Datastore(data=DatastoreData(name='test-datastore', engine_name='no_op_engine', args=args, state=DatastoreState.TEMPLATE))
self.datastore = self.dart.save_datastore(dst)
wf = Workflow(data=WorkflowData(name='test-workflow', datastore_id=self.datastore.id))
self.workflow = self.dart.save_workflow(workflow=wf, datastore_id=self.datastore.id)
self.maxDiff = 99999
def tearDown(self):
self.dart.delete_datastore(self.datastore.id)
self.dart.delete_workflow(self.workflow.id)
def test_crud_datastore(self):
action0 = Action(data=ActionData(name=NoOpActionTypes.action_that_succeeds.name,
action_type_name=NoOpActionTypes.action_that_succeeds.name,
engine_name='no_op_engine'))
action1 = Action(data=ActionData(name=NoOpActionTypes.action_that_succeeds.name,
action_type_name=NoOpActionTypes.action_that_succeeds.name,
engine_name='no_op_engine'))
posted_actions = self.dart.save_actions(actions=[action0, action1], datastore_id=self.datastore.id)
# copy fields that are populated at creation time
action0.data.datastore_id = posted_actions[0].data.datastore_id
action1.data.datastore_id = posted_actions[1].data.datastore_id
action0.data.args = {}
action1.data.args = {}
action0.data.order_idx = posted_actions[0].data.order_idx
action1.data.order_idx = posted_actions[1].data.order_idx
action0.data.user_id = posted_actions[0].data.user_id
action1.data.user_id = posted_actions[1].data.user_id
self.assertEqual(posted_actions[0].data.to_dict(), action0.data.to_dict())
self.assertEqual(posted_actions[1].data.to_dict(), action1.data.to_dict())
# When retrieving an action, its queue time and state
# differs from the action default values created by action0 and action1
a0 = self.dart.get_action(posted_actions[0].id)
a1 = self.dart.get_action(posted_actions[1].id)
action0.data.state = a0.data.state
action1.data.state = a1.data.state
action0.data.queued_time = a0.data.queued_time
action1.data.queued_time = a1.data.queued_time
self.assertEqual(a0.data.to_dict(), action0.data.to_dict())
self.assertEqual(a1.data.to_dict(), action1.data.to_dict())
self.dart.delete_action(a0.id)
self.dart.delete_action(a1.id)
try:
self.dart.get_action(a0.id)
except DartRequestException as e0:
self.assertEqual(e0.response.status_code, 404)
try:
self.dart.get_action(a1.id)
except DartRequestException as e1:
self.assertEqual(e1.response.status_code, 404)
return
self.fail('action should have been missing after delete!')
def test_crud_workflow(self):
action0 = Action(data=ActionData(name=NoOpActionTypes.action_that_succeeds.name, action_type_name=NoOpActionTypes.action_that_succeeds.name, state=ActionState.TEMPLATE, engine_name='no_op_engine'))
action1 = Action(data=ActionData(name=NoOpActionTypes.action_that_succeeds.name, action_type_name=NoOpActionTypes.action_that_succeeds.name, state=ActionState.TEMPLATE, engine_name='no_op_engine'))
posted_actions = self.dart.save_actions([action0, action1], workflow_id=self.workflow.id)
# copy fields that are populated at creation time
action0.data.workflow_id = posted_actions[0].data.workflow_id
action1.data.workflow_id = posted_actions[1].data.workflow_id
action0.data.order_idx = posted_actions[0].data.order_idx
action1.data.order_idx = posted_actions[1].data.order_idx
action0.data.args = {}
action1.data.args = {}
action0.data.user_id = posted_actions[0].data.user_id
action1.data.user_id = posted_actions[1].data.user_id
self.assertEqual(posted_actions[0].data.to_dict(), action0.data.to_dict())
self.assertEqual(posted_actions[1].data.to_dict(), action1.data.to_dict())
a0 = self.dart.get_action(posted_actions[0].id)
a1 = self.dart.get_action(posted_actions[1].id)
self.assertEqual(a0.data.to_dict(), action0.data.to_dict())
self.assertEqual(a1.data.to_dict(), action1.data.to_dict())
self.dart.delete_action(a0.id)
self.dart.delete_action(a1.id)
try:
self.dart.get_action(a0.id)
except DartRequestException as e0:
self.assertEqual(e0.response.status_code, 404)
try:
self.dart.get_action(a1.id)
except DartRequestException as e1:
self.assertEqual(e1.response.status_code, 404)
return
#.........这里部分代码省略.........