ProductJoin
Returns the product of two lists, joined by a separator, as a list of strings.
python · Filters And Transformers
Details
| ID | ProductJoin |
|---|---|
| Language | python |
| From Version | 5.0.0 |
| Docker Image | demisto/python3:3.12.13.10404775 |
| Tags | transformer general entirelist |
README
Returns the product of two lists, joined by a separator, as a list of strings.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags | transformer, general, entirelist |
| Cortex XSOAR Version | 5.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| value | The first list (or CSV string). |
| list2 | The second list (or CSV string). |
| join | Separator |
Outputs
There are no outputs for this script.
from ProductJoin import product_join def test_when_list1_is_csv_and_list2_is_list(): list1 = "a,b,c" list2 = ["1", "2"] result = product_join({"value": list1, "list2": list2, "join": "="}) expectedOutput = ["a=1", "a=2", "b=1", "b=2", "c=1", "c=2"] assert expectedOutput == result def test_when_list1_is_list_and_list2_is_csv(): list1 = ["a", "b", "c"] list2 = "1,2" result = product_join({"value": list1, "list2": list2, "join": "="}) expectedOutput = ["a=1", "a=2", "b=1", "b=2", "c=1", "c=2"] assert expectedOutput == result def test_when_list1_is_list_and_list2_is_list(): list1 = ["a", "b", "c"] list2 = ["1", "2"] result = product_join({"value": list1, "list2": list2, "join": "="}) expectedOutput = ["a=1", "a=2", "b=1", "b=2", "c=1", "c=2"] assert expectedOutput == result def test_when_list1_is_csv_and_list2_is_csv(): list1 = "a,b,c" list2 = "1,2" result = product_join({"value": list1, "list2": list2, "join": "="}) expectedOutput = ["a=1", "a=2", "b=1", "b=2", "c=1", "c=2"] assert expectedOutput == result def test_when_list1_is_csv_and_list2_is_csv_with_spaces(): list1 = "a,b,c" list2 = "1, 2" result = product_join({"value": list1, "list2": list2, "join": "="}) expectedOutput = ["a=1", "a=2", "b=1", "b=2", "c=1", "c=2"] assert expectedOutput == result def test_when_list1_is_csv_and_list2_is_numbers(): list1 = "a, b, c" list2 = [1, 2] result = product_join({"value": list1, "list2": list2, "join": "="}) expectedOutput = ["a=1", "a=2", "b=1", "b=2", "c=1", "c=2"] assert expectedOutput == result def test_when_list1_is_csv_and_list2_is_number(): list1 = "a, b, c" list2 = 1 result = product_join({"value": list1, "list2": list2, "join": "="}) expectedOutput = ["a=1", "b=1", "c=1"] assert expectedOutput == result def test_when_list1_is_csv_and_list2_is_single_item(): list1 = "a, b, c" list2 = [1] result = product_join({"value": list1, "list2": list2, "join": "="}) expectedOutput = ["a=1", "b=1", "c=1"] assert expectedOutput == result