Ejemplo n.º 1
0
def test_to_json():
    validator = InternalValidator()
    validator.add_parameter_message('login', 'login is empty')
    validator.add_parameter_message('password', 'is too short')
    validator.add_parameter_message('password', 'has no special symbol')
    print(validator.to_json())
    assert '{"parameters_messages": [{"messages": ["login is empty"], "parameter": "login"}, {"messages": ["is too short", "has no special symbol"], "parameter": "password"}]}' == validator.to_json(
    )
Ejemplo n.º 2
0
def test_to_json():
    validator = InternalValidator()
    validator.add_parameter_message('login', 'login is empty')
    validator.add_parameter_message('password', 'is too short')
    validator.add_parameter_message('password', 'has no special symbol')
    actual = validator.to_json()
    print(actual)
    expected = '{"parameters_messages": [{"parameter": "login", "messages": ["login is empty"]}, {"parameter": "password", "messages": ["is too short", "has no special symbol"]}]}'
    print(expected)
    assert expected == actual