fixing unit tests

caldera_4
Thorsten Sick 2 years ago
parent 065badd0c3
commit f777ade193

@ -538,7 +538,7 @@ class CalderaAPI():
raise ValueError
payload = {"state": state}
return self.__contact_server__(payload, method="patch", rest_path=f"api/v2/operations/{operation_id}")
return self.__contact_server__(payload, method="patch", rest_path=f"api/v2/operations/{operation_id}")
def list_agents(self):
""" Return all agents """

@ -300,20 +300,17 @@ class TestExample(unittest.TestCase):
self.cc.add_adversary(name, ability)
mock_method.assert_called_once_with(exp_4, method="post", rest_path="api/v2/adversaries")
# execute_operation
def test_execute_operation(self):
# set_operation_state
def test_set_operation_state(self):
operation_id = "test_opid"
state = "paused"
exp = {"index": "operation",
"op_id": operation_id,
"state": state}
with patch.object(self.cc, "__contact_server__", return_value=None) as mock_method:
self.cc.set_operation_state(operation_id, state)
mock_method.assert_called_once_with(exp)
mock_method.assert_called_once_with({'state': 'paused'}, method='patch', rest_path='api/v2/operations/test_opid')
# not supported state
def test_execute_operation_not_supported(self):
def test_set_operation_state_not_supported(self):
operation_id = "test_opid"
state = "not supported"
@ -321,16 +318,12 @@ class TestExample(unittest.TestCase):
with patch.object(self.cc, "__contact_server__", return_value=None):
self.cc.set_operation_state(operation_id, state)
def test_execute_operation_default(self):
def test_set_operation_state_default(self):
operation_id = "test_opid"
exp = {"index": "operation",
"op_id": operation_id,
"state": "running" # default
}
with patch.object(self.cc, "__contact_server__", return_value=None) as mock_method:
self.cc.set_operation_state(operation_id)
mock_method.assert_called_once_with(exp)
mock_method.assert_called_once_with({'state': 'running'}, method='patch', rest_path='api/v2/operations/test_opid')
# delete_operation
def test_delete_operation(self):

Loading…
Cancel
Save