Skip to content

Commit

Permalink
test: action arguments order
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaZotov committed Nov 26, 2024
1 parent 40e9bf7 commit 0822437
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion tests/test_utils/test_action_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@
generate_action,
wait_agent,
)
from sc_kpm.utils.common_utils import check_connector, generate_connector, generate_node
from sc_kpm.utils.common_utils import (
check_connector,
generate_connector,
generate_node,
search_element_by_role_relation,
)
from tests.common_tests import BaseTestCase

test_node_idtf = "test_node"
Expand Down Expand Up @@ -113,6 +118,46 @@ def test_call_action(self):
self.assertTrue(result)
self.server.remove_modules(module)

def test_call_action_with_arguments(self):
module = ScModuleTest()
self.server.add_modules(module)
with self.server.register_modules():
action_node = generate_action()
node1 = generate_node(sc_type.CONST_NODE)
node2 = generate_node(sc_type.CONST_NODE)
add_action_arguments(action_node, {node1: False, node2: False})
call_action(action_node, test_node_idtf)
wait_agent(1, action_node, ScKeynodes[ActionStatus.ACTION_FINISHED])
self.assertEqual(search_element_by_role_relation(action_node, ScKeynodes.rrel_index(1)), node1)
self.assertEqual(search_element_by_role_relation(action_node, ScKeynodes.rrel_index(2)), node2)
result = check_connector(
sc_type.VAR_PERM_POS_ARC,
ScKeynodes[ActionStatus.ACTION_FINISHED_SUCCESSFULLY],
action_node,
)
self.assertTrue(result)
self.server.remove_modules(module)

def test_call_action_with_arguments_in_wrong_order(self):
module = ScModuleTest()
self.server.add_modules(module)
with self.server.register_modules():
action_node = generate_action()
node1 = generate_node(sc_type.CONST_NODE)
node2 = generate_node(sc_type.CONST_NODE)
add_action_arguments(action_node, {node2: False, node1: False})
call_action(action_node, test_node_idtf)
wait_agent(1, action_node, ScKeynodes[ActionStatus.ACTION_FINISHED])
self.assertEqual(search_element_by_role_relation(action_node, ScKeynodes.rrel_index(1)), node2)
self.assertEqual(search_element_by_role_relation(action_node, ScKeynodes.rrel_index(2)), node1)
result = check_connector(
sc_type.VAR_PERM_POS_ARC,
ScKeynodes[ActionStatus.ACTION_FINISHED_SUCCESSFULLY],
action_node,
)
self.assertTrue(result)
self.server.remove_modules(module)

def test_wrong_execute_action(self):
module = ScModuleTest()
self.server.add_modules(module)
Expand Down

0 comments on commit 0822437

Please sign in to comment.