示例#1
0
def test_none_value():
    from python_moonutilities.security_functions import validate_data
    with pytest.raises(Exception) as exception_info:
        validate_data(object)

    assert 'Value is Not String or Container or Dictionary' in str(
        exception_info.value)
示例#2
0
def test_incorrect_string_within_dictionary():
    from python_moonutilities.security_functions import validate_data
    with pytest.raises(Exception) as exception_info:
        validate_data({"test_1": "forbidden<a>character"})

    assert str(exception_info.value) == 'Forbidden characters in string'
示例#3
0
def test_correct_dictionary():
    from python_moonutilities.security_functions import validate_data
    validate_data({"test_1": "test_2"})
示例#4
0
def test_valid_string():
    from python_moonutilities.security_functions import validate_data
    validate_data("CorrectString")
    validate_data("Correct String")
    validate_data("Correct String!")
    validate_data("Correct String@")
    validate_data(None)
    validate_data(True)
示例#5
0
def test_correct_tuple_of_tuple():
    from python_moonutilities.security_functions import validate_data
    validate_data(("test_1", ("test_2", "test_3"), (("test_4", "test_5"),
                                                    ("test_6", "test_7"))))
示例#6
0
def test_correct_tuples():
    from python_moonutilities.security_functions import validate_data
    validate_data(("test_1", "test_2"))
示例#7
0
def test_incorrect_string_inside_list():
    from python_moonutilities.security_functions import validate_data
    with pytest.raises(Exception) as exception_info:
        validate_data(["test_1", ["test_2", "forbidden<a>character"]])

    assert str(exception_info.value) == 'Forbidden characters in string'
示例#8
0
def test_correct_nested_list():
    from python_moonutilities.security_functions import validate_data
    validate_data([["test_1", "test_2"], [["test_3"], ["test_4"]],
                   ["test_5", "test_6"], ["test_7"]])
示例#9
0
def test_correct_list_multiple_element():
    from python_moonutilities.security_functions import validate_data
    validate_data(["test"])
示例#10
0
def test_correct_list_one_element():
    from python_moonutilities.security_functions import validate_data
    validate_data(["test_1", "test_2", "test_3"])
示例#11
0
def test_invalid_string():
    from python_moonutilities.security_functions import validate_data
    with pytest.raises(Exception) as exception_info:
        validate_data("Notcorrect<a>String")

    assert str(exception_info.value) == 'Forbidden characters in string'