當前位置: 首頁>>代碼示例>>Python>>正文


Python Trace.get_all方法代碼示例

本文整理匯總了Python中st2common.persistence.trace.Trace.get_all方法的典型用法代碼示例。如果您正苦於以下問題:Python Trace.get_all方法的具體用法?Python Trace.get_all怎麽用?Python Trace.get_all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在st2common.persistence.trace.Trace的用法示例。


在下文中一共展示了Trace.get_all方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_add_or_update_given_trace_context_new

# 需要導入模塊: from st2common.persistence.trace import Trace [as 別名]
# 或者: from st2common.persistence.trace.Trace import get_all [as 別名]
    def test_add_or_update_given_trace_context_new(self):
        trace_context = {'trace_tag': 'awesome_test_trace'}
        action_execution_id = 'action_execution_1'
        rule_id = 'rule_1'
        trigger_instance_id = 'trigger_instance_1'

        pre_add_or_update_traces = len(Trace.get_all())
        trace_db = trace_service.add_or_update_given_trace_context(
            trace_context,
            action_executions=[action_execution_id],
            rules=[rule_id],
            trigger_instances=[trigger_instance_id])
        post_add_or_update_traces = len(Trace.get_all())

        self.assertTrue(post_add_or_update_traces > pre_add_or_update_traces,
                        'Expected new Trace to be created.')

        retrieved_trace_db = Trace.get_by_id(trace_db.id)
        self.assertEqual(len(retrieved_trace_db.action_executions), 1,
                         'Expected updated action_executions.')
        self.assertEqual(retrieved_trace_db.action_executions[0].object_id, action_execution_id,
                         'Expected updated action_executions.')

        self.assertEqual(len(retrieved_trace_db.rules), 1, 'Expected updated rules.')
        self.assertEqual(retrieved_trace_db.rules[0].object_id, rule_id, 'Expected updated rules.')

        self.assertEqual(len(retrieved_trace_db.trigger_instances), 1,
                         'Expected updated trigger_instances.')
        self.assertEqual(retrieved_trace_db.trigger_instances[0].object_id, trigger_instance_id,
                         'Expected updated trigger_instances.')

        Trace.delete(retrieved_trace_db)
開發者ID:lyandut,項目名稱:st2,代碼行數:34,代碼來源:test_trace.py

示例2: test_trace_provided

# 需要導入模塊: from st2common.persistence.trace import Trace [as 別名]
# 或者: from st2common.persistence.trace.Trace import get_all [as 別名]
    def test_trace_provided(self):
        self.traceable_liveaction['context']['trace_context'] = {'trace_tag': 'OohLaLaLa'}
        action_services.request(self.traceable_liveaction)
        traces = Trace.get_all()
        self.assertEqual(len(traces), 1)
        self.assertEqual(len(traces[0]['action_executions']), 1)

        # Let's use existing trace id in trace context.
        # We shouldn't create new trace object.
        trace_id = str(traces[0].id)
        self.traceable_liveaction['context']['trace_context'] = {'id_': trace_id}
        action_services.request(self.traceable_liveaction)
        traces = Trace.get_all()
        self.assertEqual(len(traces), 1)
        self.assertEqual(len(traces[0]['action_executions']), 2)
開發者ID:StackStorm,項目名稱:st2,代碼行數:17,代碼來源:test_trace_injection_action_services.py

示例3: test_add_or_update_given_trace_context_new_with_causals

# 需要導入模塊: from st2common.persistence.trace import Trace [as 別名]
# 或者: from st2common.persistence.trace.Trace import get_all [as 別名]
    def test_add_or_update_given_trace_context_new_with_causals(self):
        trace_context = {'trace_tag': 'causal_test_trace'}
        action_execution_id = 'action_execution_1'
        rule_id = 'rule_1'
        trigger_instance_id = 'trigger_instance_1'

        pre_add_or_update_traces = len(Trace.get_all())
        trace_db = trace_service.add_or_update_given_trace_context(
            trace_context,
            action_executions=[{'id': action_execution_id,
                                'caused_by': {'id': '%s:%s' % (rule_id, trigger_instance_id),
                                              'type': 'rule'}}],
            rules=[{'id': rule_id,
                    'caused_by': {'id': trigger_instance_id, 'type': 'trigger-instance'}}],
            trigger_instances=[trigger_instance_id])
        post_add_or_update_traces = len(Trace.get_all())

        self.assertTrue(post_add_or_update_traces > pre_add_or_update_traces,
                        'Expected new Trace to be created.')

        retrieved_trace_db = Trace.get_by_id(trace_db.id)
        self.assertEqual(len(retrieved_trace_db.action_executions), 1,
                         'Expected updated action_executions.')
        self.assertEqual(retrieved_trace_db.action_executions[0].object_id, action_execution_id,
                         'Expected updated action_executions.')
        self.assertEqual(retrieved_trace_db.action_executions[0].caused_by,
                         {'id': '%s:%s' % (rule_id, trigger_instance_id),
                          'type': 'rule'},
                         'Expected updated action_executions.')

        self.assertEqual(len(retrieved_trace_db.rules), 1, 'Expected updated rules.')
        self.assertEqual(retrieved_trace_db.rules[0].object_id, rule_id, 'Expected updated rules.')
        self.assertEqual(retrieved_trace_db.rules[0].caused_by,
                         {'id': trigger_instance_id, 'type': 'trigger-instance'},
                         'Expected updated rules.')

        self.assertEqual(len(retrieved_trace_db.trigger_instances), 1,
                         'Expected updated trigger_instances.')
        self.assertEqual(retrieved_trace_db.trigger_instances[0].object_id, trigger_instance_id,
                         'Expected updated trigger_instances.')
        self.assertEqual(retrieved_trace_db.trigger_instances[0].caused_by, {},
                         'Expected updated rules.')

        Trace.delete(retrieved_trace_db)
開發者ID:lyandut,項目名稱:st2,代碼行數:46,代碼來源:test_trace.py

示例4: test_post_delete_trace

# 需要導入模塊: from st2common.persistence.trace import Trace [as 別名]
# 或者: from st2common.persistence.trace.Trace import get_all [as 別名]
 def test_post_delete_trace(self):
     LIVE_ACTION_TRACE = copy.copy(LIVE_ACTION_1)
     LIVE_ACTION_TRACE['context'] = {'trace_context': {'trace_tag': 'balleilaka'}}
     post_resp = self._do_post(LIVE_ACTION_TRACE)
     self.assertEqual(post_resp.status_int, 201)
     delete_resp = self._do_delete(self._get_actionexecution_id(post_resp))
     self.assertEqual(delete_resp.status_int, 200)
     self.assertEqual(delete_resp.json['status'], 'canceled')
     trace_id = str(Trace.get_all()[0].id)
     LIVE_ACTION_TRACE['context'] = {'trace_context': {'id_': trace_id}}
     post_resp = self._do_post(LIVE_ACTION_TRACE)
     self.assertEqual(post_resp.status_int, 201)
     delete_resp = self._do_delete(self._get_actionexecution_id(post_resp))
     self.assertEqual(delete_resp.status_int, 200)
     self.assertEqual(delete_resp.json['status'], 'canceled')
開發者ID:transformersprimeabcxyz,項目名稱:st2-devop,代碼行數:17,代碼來源:test_executions_simple.py

示例5: test_post_delete_trace

# 需要導入模塊: from st2common.persistence.trace import Trace [as 別名]
# 或者: from st2common.persistence.trace.Trace import get_all [as 別名]
 def test_post_delete_trace(self):
     """
     Validate that the API controller doesn't blow up on specifying
     trace_context.
     """
     LIVE_ACTION_TRACE = copy.copy(LIVE_ACTION_1)
     LIVE_ACTION_TRACE['context'] = {'trace_context': {'trace_tag': 'balleilaka'}}
     post_resp = self._do_post(LIVE_ACTION_TRACE)
     self.assertEqual(post_resp.status_int, 201)
     delete_resp = self._do_delete(self._get_actionexecution_id(post_resp))
     self.assertEqual(delete_resp.status_int, 200)
     self.assertEqual(delete_resp.json['status'], 'canceled')
     trace_id = str(Trace.get_all()[0].id)
     LIVE_ACTION_TRACE['context'] = {'trace_context': {'id_': trace_id}}
     post_resp = self._do_post(LIVE_ACTION_TRACE)
     self.assertEqual(post_resp.status_int, 201)
     delete_resp = self._do_delete(self._get_actionexecution_id(post_resp))
     self.assertEqual(delete_resp.status_int, 200)
     self.assertEqual(delete_resp.json['status'], 'canceled')
開發者ID:jonico,項目名稱:st2,代碼行數:21,代碼來源:test_executions_simple.py


注:本文中的st2common.persistence.trace.Trace.get_all方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。