Esempio n. 1
0
    def test_post_generic_trigger_with_emit_condition(self, dispatch):
        for status in LIVEACTION_STATUSES:
            liveaction_db = LiveActionDB(action='core.local')
            liveaction_db.status = status
            execution = MOCK_EXECUTION
            execution.liveaction = vars(
                LiveActionAPI.from_model(liveaction_db))
            execution.status = liveaction_db.status

            notifier = Notifier(connection=None, queues=[])
            notifier._post_generic_trigger(liveaction_db, execution)

            if status in ['scheduled', 'pending', 'abandoned']:
                exp = {
                    'status': status,
                    'start_timestamp': str(liveaction_db.start_timestamp),
                    'result': {},
                    'parameters': {},
                    'action_ref': u'core.local',
                    'runner_ref': 'local-shell-cmd',
                    'execution_id': str(MOCK_EXECUTION.id),
                    'action_name': u'core.local'
                }
                dispatch.assert_called_with('core.st2.generic.actiontrigger',
                                            payload=exp,
                                            trace_context={})

        self.assertEqual(dispatch.call_count, 3)
Esempio n. 2
0
    def test_post_generic_trigger_with_emit_condition(self, dispatch):
        for status in LIVEACTION_STATUSES:
            liveaction_db = LiveActionDB(action="core.local")
            liveaction_db.status = status
            execution = MOCK_EXECUTION
            execution.liveaction = vars(
                LiveActionAPI.from_model(liveaction_db))
            execution.status = liveaction_db.status

            notifier = Notifier(connection=None, queues=[])
            notifier._post_generic_trigger(liveaction_db, execution)

            if status in ["scheduled", "pending", "abandoned"]:
                exp = {
                    "status": status,
                    "start_timestamp": str(liveaction_db.start_timestamp),
                    "result": {},
                    "parameters": {},
                    "action_ref": "core.local",
                    "runner_ref": "local-shell-cmd",
                    "execution_id": str(MOCK_EXECUTION.id),
                    "action_name": "core.local",
                }
                dispatch.assert_called_with("core.st2.generic.actiontrigger",
                                            payload=exp,
                                            trace_context={})

        self.assertEqual(dispatch.call_count, 3)
Esempio n. 3
0
    def test_post_generic_trigger_with_emit_condition(self, dispatch):
        for status in LIVEACTION_STATUSES:
            liveaction_db = LiveActionDB(action='core.local')
            liveaction_db.status = status
            execution = MOCK_EXECUTION
            execution.liveaction = vars(LiveActionAPI.from_model(liveaction_db))
            execution.status = liveaction_db.status

            notifier = Notifier(connection=None, queues=[])
            notifier._post_generic_trigger(liveaction_db, execution)

            if status in ['scheduled', 'pending', 'abandoned']:
                exp = {'status': status,
                       'start_timestamp': str(liveaction_db.start_timestamp),
                       'result': {}, 'parameters': {},
                       'action_ref': u'core.local',
                       'runner_ref': 'local-shell-cmd',
                       'execution_id': str(MOCK_EXECUTION.id),
                       'action_name': u'core.local'}
                dispatch.assert_called_with('core.st2.generic.actiontrigger',
                                            payload=exp, trace_context={})

        self.assertEqual(dispatch.call_count, 3)