コード例 #1
0
    def test_model_complete(self):

        # Create API object.
        obj = ActionExecutionHistoryAPI(
            **copy.deepcopy(self.fake_history_workflow))
        self.assertDictEqual(obj.trigger,
                             self.fake_history_workflow['trigger'])
        self.assertDictEqual(obj.trigger_type,
                             self.fake_history_workflow['trigger_type'])
        self.assertDictEqual(obj.trigger_instance,
                             self.fake_history_workflow['trigger_instance'])
        self.assertDictEqual(obj.rule, self.fake_history_workflow['rule'])
        self.assertDictEqual(obj.action, self.fake_history_workflow['action'])
        self.assertDictEqual(obj.runner, self.fake_history_workflow['runner'])
        self.assertDictEqual(obj.execution,
                             self.fake_history_workflow['execution'])
        self.assertIsNone(getattr(obj, 'parent', None))
        self.assertListEqual(obj.children,
                             self.fake_history_workflow['children'])

        # Convert API object to DB model.
        model = ActionExecutionHistoryAPI.to_model(obj)
        self.assertEqual(str(model.id), obj.id)
        self.assertDictEqual(model.trigger,
                             self.fake_history_workflow['trigger'])
        self.assertDictEqual(model.trigger_type,
                             self.fake_history_workflow['trigger_type'])
        self.assertDictEqual(model.trigger_instance,
                             self.fake_history_workflow['trigger_instance'])
        self.assertDictEqual(model.rule, self.fake_history_workflow['rule'])
        self.assertDictEqual(model.action,
                             self.fake_history_workflow['action'])
        self.assertDictEqual(model.runner,
                             self.fake_history_workflow['runner'])
        doc = copy.deepcopy(self.fake_history_workflow['execution'])
        doc['start_timestamp'] = isotime.parse(doc['start_timestamp'])
        self.assertDictEqual(model.execution, doc)
        self.assertIsNone(getattr(model, 'parent', None))
        self.assertListEqual(model.children,
                             self.fake_history_workflow['children'])

        # Convert DB model to API object.
        obj = ActionExecutionHistoryAPI.from_model(model)
        self.assertEqual(str(model.id), obj.id)
        self.assertDictEqual(obj.trigger,
                             self.fake_history_workflow['trigger'])
        self.assertDictEqual(obj.trigger_type,
                             self.fake_history_workflow['trigger_type'])
        self.assertDictEqual(obj.trigger_instance,
                             self.fake_history_workflow['trigger_instance'])
        self.assertDictEqual(obj.rule, self.fake_history_workflow['rule'])
        self.assertDictEqual(obj.action, self.fake_history_workflow['action'])
        self.assertDictEqual(obj.runner, self.fake_history_workflow['runner'])
        self.assertDictEqual(obj.execution,
                             self.fake_history_workflow['execution'])
        self.assertIsNone(getattr(obj, 'parent', None))
        self.assertListEqual(obj.children,
                             self.fake_history_workflow['children'])
コード例 #2
0
ファイル: test_history.py プロジェクト: miqui/st2
 def test_get_one(self):
     obj_id = random.choice(self.refs.keys())
     response = self.app.get('/v1/history/executions/%s' % obj_id)
     self.assertEqual(response.status_int, 200)
     self.assertIsInstance(response.json, dict)
     record = response.json
     fake_record = ActionExecutionHistoryAPI.from_model(self.refs[obj_id])
     self.assertEqual(record['id'], obj_id)
     self.assertDictEqual(record['action'], fake_record.action)
     self.assertDictEqual(record['runner'], fake_record.runner)
     self.assertDictEqual(record['execution'], fake_record.execution)
コード例 #3
0
ファイル: test_history.py プロジェクト: bjoernbessert/st2
 def test_get_one(self):
     obj_id = random.choice(self.refs.keys())
     response = self.app.get('/history/executions/%s' % obj_id)
     self.assertEqual(response.status_int, 200)
     self.assertIsInstance(response.json, dict)
     record = response.json
     fake_record = ActionExecutionHistoryAPI.from_model(self.refs[obj_id])
     self.assertEqual(record['id'], obj_id)
     self.assertDictEqual(record['action'], fake_record.action)
     self.assertDictEqual(record['runner'], fake_record.runner)
     self.assertDictEqual(record['execution'], fake_record.execution)
コード例 #4
0
ファイル: test_history.py プロジェクト: miqui/st2
    def test_model_partial(self):
        # Create API object.
        obj = ActionExecutionHistoryAPI(**copy.deepcopy(self.fake_history_subtasks[0]))
        self.assertIsNone(getattr(obj, 'trigger', None))
        self.assertIsNone(getattr(obj, 'trigger_type', None))
        self.assertIsNone(getattr(obj, 'trigger_instance', None))
        self.assertIsNone(getattr(obj, 'rule', None))
        self.assertDictEqual(obj.action, self.fake_history_subtasks[0]['action'])
        self.assertDictEqual(obj.runner, self.fake_history_subtasks[0]['runner'])
        self.assertDictEqual(obj.execution, self.fake_history_subtasks[0]['execution'])
        self.assertEqual(obj.parent, self.fake_history_subtasks[0]['parent'])
        self.assertIsNone(getattr(obj, 'children', None))

        # Convert API object to DB model.
        model = ActionExecutionHistoryAPI.to_model(obj)
        self.assertEqual(str(model.id), obj.id)
        self.assertDictEqual(model.trigger, {})
        self.assertDictEqual(model.trigger_type, {})
        self.assertDictEqual(model.trigger_instance, {})
        self.assertDictEqual(model.rule, {})
        self.assertDictEqual(model.action, self.fake_history_subtasks[0]['action'])
        self.assertDictEqual(model.runner, self.fake_history_subtasks[0]['runner'])
        doc = copy.deepcopy(self.fake_history_subtasks[0]['execution'])
        doc['start_timestamp'] = isotime.parse(doc['start_timestamp'])
        doc['end_timestamp'] = isotime.parse(doc['end_timestamp'])
        self.assertDictEqual(model.execution, doc)
        self.assertEqual(model.parent, self.fake_history_subtasks[0]['parent'])
        self.assertListEqual(model.children, [])

        # Convert DB model to API object.
        obj = ActionExecutionHistoryAPI.from_model(model)
        self.assertEqual(str(model.id), obj.id)
        self.assertIsNone(getattr(obj, 'trigger', None))
        self.assertIsNone(getattr(obj, 'trigger_type', None))
        self.assertIsNone(getattr(obj, 'trigger_instance', None))
        self.assertIsNone(getattr(obj, 'rule', None))
        self.assertDictEqual(obj.action, self.fake_history_subtasks[0]['action'])
        self.assertDictEqual(obj.runner, self.fake_history_subtasks[0]['runner'])
        self.assertDictEqual(obj.execution, self.fake_history_subtasks[0]['execution'])
        self.assertEqual(obj.parent, self.fake_history_subtasks[0]['parent'])
        self.assertIsNone(getattr(obj, 'children', None))
コード例 #5
0
ファイル: test_history.py プロジェクト: bjoernbessert/st2
    def test_model_complete(self):

        # Create API object.
        obj = ActionExecutionHistoryAPI(**copy.deepcopy(self.fake_history_workflow))
        self.assertDictEqual(obj.trigger, self.fake_history_workflow['trigger'])
        self.assertDictEqual(obj.trigger_type, self.fake_history_workflow['trigger_type'])
        self.assertDictEqual(obj.trigger_instance, self.fake_history_workflow['trigger_instance'])
        self.assertDictEqual(obj.rule, self.fake_history_workflow['rule'])
        self.assertDictEqual(obj.action, self.fake_history_workflow['action'])
        self.assertDictEqual(obj.runner, self.fake_history_workflow['runner'])
        self.assertDictEqual(obj.execution, self.fake_history_workflow['execution'])
        self.assertIsNone(getattr(obj, 'parent', None))
        self.assertListEqual(obj.children, self.fake_history_workflow['children'])

        # Convert API object to DB model.
        model = ActionExecutionHistoryAPI.to_model(obj)
        self.assertEqual(str(model.id), obj.id)
        self.assertDictEqual(model.trigger, self.fake_history_workflow['trigger'])
        self.assertDictEqual(model.trigger_type, self.fake_history_workflow['trigger_type'])
        self.assertDictEqual(model.trigger_instance, self.fake_history_workflow['trigger_instance'])
        self.assertDictEqual(model.rule, self.fake_history_workflow['rule'])
        self.assertDictEqual(model.action, self.fake_history_workflow['action'])
        self.assertDictEqual(model.runner, self.fake_history_workflow['runner'])
        doc = copy.deepcopy(self.fake_history_workflow['execution'])
        doc['start_timestamp'] = isotime.parse(doc['start_timestamp'])
        self.assertDictEqual(model.execution, doc)
        self.assertIsNone(getattr(model, 'parent', None))
        self.assertListEqual(model.children, self.fake_history_workflow['children'])

        # Convert DB model to API object.
        obj = ActionExecutionHistoryAPI.from_model(model)
        self.assertEqual(str(model.id), obj.id)
        self.assertDictEqual(obj.trigger, self.fake_history_workflow['trigger'])
        self.assertDictEqual(obj.trigger_type, self.fake_history_workflow['trigger_type'])
        self.assertDictEqual(obj.trigger_instance, self.fake_history_workflow['trigger_instance'])
        self.assertDictEqual(obj.rule, self.fake_history_workflow['rule'])
        self.assertDictEqual(obj.action, self.fake_history_workflow['action'])
        self.assertDictEqual(obj.runner, self.fake_history_workflow['runner'])
        self.assertDictEqual(obj.execution, self.fake_history_workflow['execution'])
        self.assertIsNone(getattr(obj, 'parent', None))
        self.assertListEqual(obj.children, self.fake_history_workflow['children'])