Esempio n. 1
0
 def test_success(self):
     with mock.patch(MOCK_COMP_TOTAL,
                     MagicMock(return_value=TEST_TOTAL)) as mock_total:
         with mock.patch(
                 MOCK_COMP_VALUES_LIST,
                 MagicMock(return_value=TEST_COMP_NAME)) as mock_dict:
             with mock.patch(TASKFLOWEXECUTEDNODE_STATISTICS_VALUES,
                             MagicMock(return_value=MockCompoentData())
                             ) as mock_comp_data:
                 total, groups = TaskFlowInstance.objects.group_by_atom_execute_fail_times(
                     MockTaskFlow())
                 mock_total.assert_called_once_with()
                 mock_dict.assert_called_once_with("code", "name")
                 mock_comp_data.assert_called_once_with(
                     "component_code", "version", "is_remote")
                 self.assertEqual(total, TEST_TOTAL)
                 self.assertEqual(groups, TEST_GROUPS)
 def test_success(self):
     with mock.patch(
             GET_REMOTE_PLUGIN_NAME,
             MagicMock(return_value=TEST_REMOTE_PLUGIN_DICT)) as mocked:
         groups = format_component_name_with_remote(TEST_COMPONENTS,
                                                    TEST_COMP_NAME_DICT)
         mocked.assert_called_once_with()
         self.assertEqual(groups, TEST_GROUPS)
Esempio n. 3
0
 def test_success(self):
     with mock.patch(MOCK_COMP_TOTAL,
                     MagicMock(return_value=TEST_TOTAL)) as mock_total:
         with mock.patch(
                 MOCK_COMP_VALUES_LIST,
                 MagicMock(return_value=TEST_COMP_NAME)) as mock_dict:
             with mock.patch(TEMPLATENODE_STATISTICS,
                             MagicMock(return_value=MockCompoentData())
                             ) as mock_comp_data:
                 total, groups = TaskTemplate.objects.group_by_atom_cite(
                     MockTaskTmpl())
                 mock_total.assert_called_once_with()
                 mock_dict.assert_called_once_with("code", "name")
                 mock_comp_data.assert_called_once_with(
                     "component_code", "version", "is_remote")
                 self.assertEqual(total, TEST_TOTAL)
                 self.assertEqual(groups, TEST_GROUPS)
Esempio n. 4
0
 def test_group_by_instance_node(self):
     with mock.patch(TASKFLOW_STATISTICS_FILTER,
                     MockTaskflowStatistics()) as mock_statistics_filter:
         with mock.patch(PIPELINE_INSTANCE_FILTER,
                         MockInstanceDict()) as mock_instance_dict:
             with mock.patch(PROJECT_FILTER,
                             MockProjectDict()) as mock_project_dict:
                 total, groups = TaskFlowInstance.objects.group_by_instance_node(
                     taskflow=TEST_TASKFLOW,
                     filters=None,
                     page=TEST_PAGE,
                     limit=TEST_LIMIT)
                 mock_statistics_filter.assert_called_once_with(
                     task_instance_id__in=TEST_TASK_INSTANCE_ID_LIST)
                 mock_instance_dict.assert_called_once_with(
                     id__in=TEST_TASK_INSTANCE_ID_LIST[0:TEST_LIMIT])
                 mock_project_dict.assert_called_once_with(
                     id__in=[TEST_PROJ_ID for i in range(TEST_LIMIT)])
                 self.assertEqual(total, TEST_TOTAL)
                 self.assertEqual(groups, TEST_GROUPS)
Esempio n. 5
0
 def test_success(self):
     with mock.patch(MOCK_GET_COMPONENTS):
         response = self.client.get(path=self.url)
         get_all_components.assert_called_once_with()
         data = json.loads(response.content)
         self.assertEqual(data, {"result": True, "data": TEST_COMPS})