Skip to content

Commit bfb3550

Browse files
committed
Fixed test_fetch_incidents_command
1 parent 2ab71d9 commit bfb3550

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Packs/Doppel/Integrations/Doppel/Doppel_test.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,18 @@ def mock_http_request(method, url_suffix, params=None, headers=None, data=None,
2727
def client():
2828
# Create a mock client
2929
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+
3142
client.create_abuse_alert = MagicMock(side_effect=mock_http_request)
3243
return client
3344

@@ -81,7 +92,7 @@ def test_fetch_incidents_command(client, mocker):
8192
"""Test fetch_incidents_command function."""
8293

8394
# 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"})
8596
mocker.patch.object(demisto, "getLastRun", return_value={"last_run": "2025-02-01T11:50:00Z", "incidents_queue": []})
8697
mock_setLastRun = mocker.patch.object(demisto, "setLastRun")
8798
mock_incidents = mocker.patch.object(demisto, "incidents")
@@ -147,7 +158,7 @@ def test_get_remote_data_command(mocker, requests_mock):
147158
demisto.debug.assert_called()
148159

149160

150-
def test_update_remote_system_command(mock_client, mocker):
161+
def test_update_remote_system_command(client, mocker):
151162
"""Test update_remote_system_command function."""
152163

153164
# Mocking demisto functions using mocker.patch.object
@@ -161,21 +172,21 @@ def test_update_remote_system_command(mock_client, mocker):
161172
}
162173

163174
# Run the function
164-
result = update_remote_system_command(mock_client, args)
175+
result = update_remote_system_command(client, args)
165176

166177
# Assertions
167178
assert result == "123", "Returned remoteId should match input"
168179
mock_debug.assert_called() # Ensure debug logs are being generated
169180
mock_error.assert_not_called() # Ensure no errors were logged
170181

171-
def test_get_mapping_fields_command(mock_client, mocker):
182+
def test_get_mapping_fields_command(client, mocker):
172183
"""Test get_mapping_fields_command function."""
173184

174185
# Mocking demisto functions using mocker.patch.object
175186
mock_debug = mocker.patch.object(demisto, "debug")
176187

177188
# Run the function
178-
result = get_mapping_fields_command(mock_client, {})
189+
result = get_mapping_fields_command(client, {})
179190

180191
# Assertions
181192
assert result is not None, "Result should not be None"
@@ -228,7 +239,7 @@ def test_doppel_update_alert_command(mocker):
228239
mock_debug = mocker.patch.object(demisto, "debug")
229240

230241
# Mocking the Client instance
231-
mock_client = MagicMock(spec=client)
242+
mock_client = MagicMock()
232243
mock_client.update_alert.return_value = {"id": "123", "queue_state": "archived", "entity_state": "closed"}
233244

234245
# Sample arguments

0 commit comments

Comments
 (0)