コード例 #1
0
def test_request_timeout_success(mocker):
    """
        When provided valid request timeout then test should be passed.
    """
    from PassiveTotal_v2 import get_request_timeout
    request_timeout = 5
    params = {'request_timeout': str(request_timeout)}

    mocker.patch.object(demisto, 'params', return_value=params)
    get_request_timeout()
    assert int(request_timeout) == request_timeout
コード例 #2
0
def test_request_timeout_large_value_failure(mocker):
    """
        When too large value provided for request timeout then raised value error and
        appropriate error message should display.
    """
    from PassiveTotal_v2 import get_request_timeout
    request_timeout = 990000000000000000

    params = {'request_timeout': str(request_timeout)}
    mocker.patch.object(demisto, 'params', return_value=params)

    # Execute
    with pytest.raises(ValueError) as e:
        get_request_timeout()

    assert 'Value is too large for HTTP(S) Request Timeout.' == str(e.value)
コード例 #3
0
def test_request_timeout_failure(mocker):
    """
        When invalid input provided for request timeout then appropriate error message should display.
    """
    from PassiveTotal_v2 import get_request_timeout
    request_timeout = -5

    params = {'request_timeout': str(request_timeout)}
    mocker.patch.object(demisto, 'params', return_value=params)

    # Execute
    with pytest.raises(ValueError) as e:
        get_request_timeout()

    assert 'HTTP(S) Request timeout parameter must be a positive integer.' == str(
        e.value)
コード例 #4
0
def test_request_timeout_invalid_value(mocker):
    """
        When provided invalid request timeout then display error message.
    """
    from PassiveTotal_v2 import get_request_timeout

    # Configure
    request_timeout = 'invalid_str_value'
    params = {'request_timeout': str(request_timeout)}
    mocker.patch.object(demisto, 'params', return_value=params)

    # Execute
    with pytest.raises(ValueError) as e:
        get_request_timeout()

    # Assert
    assert 'HTTP(S) Request timeout parameter must be a positive integer.' == str(
        e.value)