Skip to content

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuaikang committed Sep 7, 2023
1 parent 724e1e4 commit a28c471
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
8 changes: 2 additions & 6 deletions gcloud/taskflow3/domains/dispatchers/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,14 +778,10 @@ def get_node_detail_v2(
format_pipeline_status(hist)
# 节点未执行
else:
pipeline_instance = kwargs["pipeline_instance"]
node = self._get_node_info(
node_id=self.node_id, pipeline=pipeline_instance.execution_data, subprocess_stack=subprocess_stack
)
detail.update(
{
"name": node["name"],
"error_ignorable": node.get("error_ignorable", False),
"name": node_info["name"],
"error_ignorable": node_info.get("error_ignorable", False),
"state": bamboo_engine_states.READY,
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
specific language governing permissions and limitations under the License.
"""

from bamboo_engine import states as bamboo_engine_states
from django.test import TestCase

from gcloud import err_code
from gcloud.taskflow3.domains.dispatchers.node import NodeCommandDispatcher
from bamboo_engine import states as bamboo_engine_states

from gcloud.tests.mock import * # noqa
from gcloud.tests.mock_settings import * # noqa

Expand Down Expand Up @@ -87,7 +86,7 @@ def test_node_started_loop_is_none(self):
bamboo_api.get_node_histories = MagicMock(return_value=get_node_histories_return)
dispatcher = NodeCommandDispatcher(engine_ver=2, node_id="node_id")

dispatcher._get_node_info = MagicMock()
dispatcher._get_node_info = MagicMock(return_value={"type": "ServiceActivity"})
format_pipeline_status = MagicMock()

with patch(TASKFLOW_DISPATCHERS_NODE_BAMBOO_RUNTIME, runtime_init):
Expand All @@ -103,7 +102,9 @@ def test_node_started_loop_is_none(self):

bamboo_api.get_children_states.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id)
bamboo_api.get_node_histories.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id, loop=1)
dispatcher._get_node_info.assert_not_called()
dispatcher._get_node_info.assert_called_once_with(
node_id=dispatcher.node_id, pipeline=pipeline_instance.execution_data, subprocess_stack=subprocess_stack
)

self.assertEqual(
node_detail,
Expand Down Expand Up @@ -149,7 +150,7 @@ def test_node_started_loop_is_latest(self):
bamboo_api.get_node_histories = MagicMock(return_value=get_node_histories_return)

dispatcher = NodeCommandDispatcher(engine_ver=2, node_id="node_id")
dispatcher._get_node_info = MagicMock()
dispatcher._get_node_info = MagicMock(return_value={"type": "ServiceActivity"})
format_pipeline_status = MagicMock()

with patch(TASKFLOW_DISPATCHERS_NODE_BAMBOO_RUNTIME, runtime_init):
Expand All @@ -165,7 +166,9 @@ def test_node_started_loop_is_latest(self):

bamboo_api.get_children_states.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id)
bamboo_api.get_node_histories.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id, loop=1)
dispatcher._get_node_info.assert_not_called()
dispatcher._get_node_info.assert_called_once_with(
node_id=dispatcher.node_id, pipeline=pipeline_instance.execution_data, subprocess_stack=subprocess_stack
)

self.assertEqual(
node_detail,
Expand Down Expand Up @@ -213,7 +216,7 @@ def test_node_started_loop_is_not_latest(self):
bamboo_api.get_node_histories = MagicMock(return_value=get_node_histories_return)

dispatcher = NodeCommandDispatcher(engine_ver=2, node_id="node_id")
dispatcher._get_node_info = MagicMock()
dispatcher._get_node_info = MagicMock(return_value={"type": "ServiceActivity"})
dispatcher._assemble_histroy_detail = MagicMock()
format_pipeline_status = MagicMock()

Expand All @@ -230,7 +233,9 @@ def test_node_started_loop_is_not_latest(self):

bamboo_api.get_children_states.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id)
bamboo_api.get_node_histories.assert_called_once_with(runtime=runtime, node_id=dispatcher.node_id, loop=1)
dispatcher._get_node_info.assert_not_called()
dispatcher._get_node_info.assert_called_once_with(
node_id=dispatcher.node_id, pipeline=pipeline_instance.execution_data, subprocess_stack=subprocess_stack
)
dispatcher._assemble_histroy_detail.assert_called_once()

self.assertEqual(
Expand Down

0 comments on commit a28c471

Please sign in to comment.