JoinIfSingleElementOnly
Return the single element in case the array has only 1 element in it, otherwise return the whole array.
python · Filters And Transformers
Details
| ID | JoinIfSingleElementOnly |
|---|---|
| Language | python |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10404775 |
| Tags | entirelist transformer general |
README
Returns the single element in a situation where an array has only 1 element in it, otherwise return the whole array.
Script Data
| Name | Description |
|---|---|
| Script Type | python |
| Tags | entirelist, transformer, general |
Inputs
| Argument Name | Description |
|---|---|
| value | The array to join if it has a single element. |
Outputs
There are no outputs for this script.
import demistomock as demisto # noqa: F401 import pytest from CommonServerPython import * # noqa: F401 from JoinIfSingleElementOnly import return_first_element_if_single @pytest.mark.parametrize("value,expected_res", [(["1", "2", "3"], ["1", "2", "3"]), (["1"], "1"), ("test", "test")]) def test_join_if_single(value, expected_res): res = return_first_element_if_single(value) assert res == expected_res