@@ -27,7 +27,18 @@ def mock_http_request(method, url_suffix, params=None, headers=None, data=None,
27
27
def client ():
28
28
# Create a mock client
29
29
client = MagicMock ()
30
- client .get_alert = mock_http_request
30
+ client .get_alerts .return_value = ALERTS_RESPONSE
31
+
32
+ # Mocking fetch single alert (Used in update_remote_system_command)
33
+ client .get_alert .return_value = {
34
+ "id" : "123" ,
35
+ "queue_state" : "open" ,
36
+ "entity_state" : "active"
37
+ }
38
+
39
+ # Mocking update alert (Used in update_remote_system_command)
40
+ client .update_alert .return_value = None # Assume update succeeds
41
+
31
42
client .create_abuse_alert = MagicMock (side_effect = mock_http_request )
32
43
return client
33
44
@@ -81,7 +92,7 @@ def test_fetch_incidents_command(client, mocker):
81
92
"""Test fetch_incidents_command function."""
82
93
83
94
# Mocking demisto functions using mocker.patch.object
84
- mocker .patch .object (demisto , "params" , return_value = {"max_fetch" : 2 , "fetch_timeout" : "10 " })
95
+ mocker .patch .object (demisto , "params" , return_value = {"max_fetch" : 2 , "fetch_timeout" : "20 " })
85
96
mocker .patch .object (demisto , "getLastRun" , return_value = {"last_run" : "2025-02-01T11:50:00Z" , "incidents_queue" : []})
86
97
mock_setLastRun = mocker .patch .object (demisto , "setLastRun" )
87
98
mock_incidents = mocker .patch .object (demisto , "incidents" )
@@ -147,7 +158,7 @@ def test_get_remote_data_command(mocker, requests_mock):
147
158
demisto .debug .assert_called ()
148
159
149
160
150
- def test_update_remote_system_command (mock_client , mocker ):
161
+ def test_update_remote_system_command (client , mocker ):
151
162
"""Test update_remote_system_command function."""
152
163
153
164
# Mocking demisto functions using mocker.patch.object
@@ -161,21 +172,21 @@ def test_update_remote_system_command(mock_client, mocker):
161
172
}
162
173
163
174
# Run the function
164
- result = update_remote_system_command (mock_client , args )
175
+ result = update_remote_system_command (client , args )
165
176
166
177
# Assertions
167
178
assert result == "123" , "Returned remoteId should match input"
168
179
mock_debug .assert_called () # Ensure debug logs are being generated
169
180
mock_error .assert_not_called () # Ensure no errors were logged
170
181
171
- def test_get_mapping_fields_command (mock_client , mocker ):
182
+ def test_get_mapping_fields_command (client , mocker ):
172
183
"""Test get_mapping_fields_command function."""
173
184
174
185
# Mocking demisto functions using mocker.patch.object
175
186
mock_debug = mocker .patch .object (demisto , "debug" )
176
187
177
188
# Run the function
178
- result = get_mapping_fields_command (mock_client , {})
189
+ result = get_mapping_fields_command (client , {})
179
190
180
191
# Assertions
181
192
assert result is not None , "Result should not be None"
@@ -228,7 +239,7 @@ def test_doppel_update_alert_command(mocker):
228
239
mock_debug = mocker .patch .object (demisto , "debug" )
229
240
230
241
# Mocking the Client instance
231
- mock_client = MagicMock (spec = client )
242
+ mock_client = MagicMock ()
232
243
mock_client .update_alert .return_value = {"id" : "123" , "queue_state" : "archived" , "entity_state" : "closed" }
233
244
234
245
# Sample arguments
0 commit comments