ConvertToSingleElementArray
Converts a single string to an array of that string.
python · Filters And Transformers
Details
| ID | ConvertToSingleElementArray |
|---|---|
| Language | python |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10404775 |
| Tags | transformer entirelist |
README
Converts a single string to an array of that string.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | transformer, entirelist |
| Cortex XSOAR Version | 5.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| value | The string to convert to an array of that string. |
Outputs
There are no outputs for this script.
import demistomock as demisto import pytest from ConvertToSingleElementArray import main @pytest.mark.parametrize( "args,expected_result", [ ({"value": ""}, []), ({"value": ["1", "2"]}, ["1", "2"]), ({"value": "1"}, ["1"]), ], ) def test_main(mocker, args, expected_result): """ Given: Case 1: value is ''. Case 2: value is a list ['1','2']. Case 3: value not empty. When: Running ConvertToSingleElementArray script. Then: Case 1: Ensure [] is returned Case 2: Ensure ['1', '2'] is returned Case 3: Ensure ['1'] is returned """ mocker.patch.object(demisto, "args", return_value=args) mocker.patch.object(demisto, "results") main() results = demisto.results.call_args[0][0] assert demisto.results.call_count == 1 assert results == expected_result