hideFieldsOnNewIncident

When you apply this script to an incident field, that incident field is hidden for new incidents, and it displays in edit mode.

python · Common Scripts

Details

IDhideFieldsOnNewIncident
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagsfield-display

README

Hides incident fields for new incidents (post application of the script), and displays it in edit mode.

Script Data


Name Description
Script Type python
Tags field-display
Cortex XSOAR Version 3.6.0+

Inputs


Argument Name Description
incident The incident object.
field The field definition object.

Outputs


There are no outputs for this script.

"""
Tests module for InfoArmor HideFieldsOnNewIncident script
"""

import demistomock as demisto
import pytest


@pytest.mark.parametrize(
    "incident, mock_demisto_get, expected_results",
    [
        ({"id": ""}, {}, {"hidden": True, "options": []}),
        ({"id": "test"}, {}, {"hidden": False, "options": []}),
        ({"id": "test"}, {"Select": "select_test"}, {"hidden": False, "options": {"Select": "select_test"}}),
    ],
)
def test_hide_fields_on_new_incident(mocker, incident, mock_demisto_get, expected_results):
    """
    Given:
            - A dictionary represent an XSOAR incident, and a mock response for the 'demisto.get' function.
    When:
            - Running the 'hide_fields_on_new_incident' function.
    Then:
            - Verify that the demisto.results are as expected.
    """
    from HideFieldsOnNewIncident import hide_fields_on_new_incident

    field = "test_field"

    mocker.patch.object(demisto, "results")
    mocker.patch.object(demisto, "get", return_value=mock_demisto_get)
    hide_fields_on_new_incident(incident, field)
    results = demisto.results.call_args[0][0]

    assert results == expected_results