|
1 | 1 | import json |
| 2 | +import logging |
2 | 3 |
|
3 | 4 | import py42.sdk.queries.alerts.filters as f |
4 | 5 | import pytest |
|
8 | 9 | from tests.cmds.conftest import get_mark_for_search_and_send_to |
9 | 10 | from tests.conftest import get_test_date_str |
10 | 11 |
|
| 12 | +from code42cli import errors |
11 | 13 | from code42cli import PRODUCT_NAME |
12 | 14 | from code42cli.cmds.search import extraction |
13 | 15 | from code42cli.cmds.search.cursor_store import AlertCursorStore |
@@ -703,6 +705,21 @@ def test_search_and_send_to_with_or_query_flag_produces_expected_query( |
703 | 705 | assert actual_query == expected_query |
704 | 706 |
|
705 | 707 |
|
| 708 | +@search_and_send_to_test |
| 709 | +def test_search_and_send_to_when_extraction_handles_error_expected_message_logged_and_printed_and_global_errored_flag_set( |
| 710 | + runner, cli_state, caplog, command |
| 711 | +): |
| 712 | + errors.ERRORED = False |
| 713 | + exception_msg = "Test Exception" |
| 714 | + cli_state.sdk.alerts.search.side_effect = Exception(exception_msg) |
| 715 | + with caplog.at_level(logging.ERROR): |
| 716 | + result = runner.invoke(cli, [*command, "--begin", "1d"], obj=cli_state) |
| 717 | + assert "Error:" in result.output |
| 718 | + assert exception_msg in result.output |
| 719 | + assert exception_msg in caplog.text |
| 720 | + assert errors.ERRORED |
| 721 | + |
| 722 | + |
706 | 723 | @pytest.mark.parametrize( |
707 | 724 | "protocol", (ServerProtocol.TLS_TCP, ServerProtocol.TLS_TCP, ServerProtocol.UDP) |
708 | 725 | ) |
|
0 commit comments