Example #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)
Example #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'
Example #3
0
def test_correct_dictionary():
    from python_moonutilities.security_functions import validate_data
    validate_data({"test_1": "test_2"})
Example #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)
Example #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"))))
Example #6
0
def test_correct_tuples():
    from python_moonutilities.security_functions import validate_data
    validate_data(("test_1", "test_2"))
Example #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'
Example #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"]])
Example #9
0
def test_correct_list_multiple_element():
    from python_moonutilities.security_functions import validate_data
    validate_data(["test"])
Example #10
0
def test_correct_list_one_element():
    from python_moonutilities.security_functions import validate_data
    validate_data(["test_1", "test_2", "test_3"])
Example #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'