InRange

checks if left side is in range of right side (from,to anotation) e.g. - InRange left=4right=1,8 will return true.

python · Filters And Transformers

Details

IDInRange
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagsfilter number

README

Checks if the left side is in range of the right side (from,to anotation).

Example - InRange left=4right=1,8 will return true

Script Data


Name Description
Script Type python3
Tags filter, number

Inputs


Argument Name Description
left The value to check, if it is in range. For example, 4.
right The range to check against with the form of from,to. For example, 2,8.

Outputs


There are no outputs for this script.

import demistomock as demisto
import pytest
from InRange import main


@pytest.mark.parametrize(
    "left,right,expected",
    [
        ("4", "1,8", True),
        ("7", "-1,3", False),
    ],
)
def test_in_range(mocker, left, right, expected):
    """
    Given:
        - Case A: Range of 1-8 and value 4
        - Case A: Range of -1-3 and value 7

    When:
        - Running InRange

    Then:
        - Case A: True is returned
        - Case B: False is returned
    """
    mocker.patch.object(
        demisto,
        "args",
        return_value={
            "left": left,
            "right": right,
        },
    )
    mocker.patch.object(demisto, "results")
    main()
    demisto.results.assert_called_with(expected)