Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
Fix validators.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe committed Aug 30, 2017
1 parent 99e6fd8 commit 4f59a39
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tests/test_prompts_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@

from ovmm.prompts import validators

CTX = None
PARAM = None
PASSWORD_LENGTH = os.environ.get('OVMM_PASSWORD_LENGTH')


@pytest.mark.parametrize('parse_func,input', [
(getattr(validators, 'validate_user_name'), 'usern'),
(getattr(validators, 'validate_user_name'), '_username'),
(getattr(validators, 'validate_user_name'), '1username'),
(getattr(validators, 'validate_user_name'), 'UserName'),
(getattr(validators, 'validate_user_name'), 'us-ername'),
(getattr(validators, 'validate_user_name'), 'user name'),
@pytest.mark.parametrize('val_func,input', [
(getattr(validators, 'validate_user_name'), [CTX, PARAM, 'usern']),
(getattr(validators, 'validate_user_name'), [CTX, PARAM, '_username']),
(getattr(validators, 'validate_user_name'), [CTX, PARAM, '1username']),
(getattr(validators, 'validate_user_name'), [CTX, PARAM, 'UserName']),
(getattr(validators, 'validate_user_name'), [CTX, PARAM, 'us-ername']),
(getattr(validators, 'validate_user_name'), [CTX, PARAM, 'user name']),
(getattr(validators, 'validate_email'), 'user@name'),
(getattr(validators, 'validate_email'), 'user@.de'),
(getattr(validators, 'validate_email'), 'user.de'),
Expand All @@ -27,12 +29,12 @@
(getattr(validators, 'validate_password'), 'AbCdEf G'),
(getattr(validators, 'validate_password'), 'password'),
])
def test_parser_error(parse_func, input):
def test_validator_error(val_func, input):
with pytest.raises(click.BadParameter):
parse_func(input)
val_func(input)


@pytest.mark.parametrize('parse_func,input', [
@pytest.mark.parametrize('val_func,input', [
(getattr(validators, 'validate_user_name'), 'username'),
(getattr(validators, 'validate_user_name'), 'user_name'),
(getattr(validators, 'validate_user_name'), 'user_1'),
Expand All @@ -45,5 +47,5 @@ def test_parser_error(parse_func, input):
(getattr(validators, 'validate_password'), 'UserName1'),
(getattr(validators, 'validate_telephone'), '67512635')
])
def test_parser_check(parse_func, input):
assert parse_func(input) == input
def test_validator_check(val_func, input):
assert val_func(input) == input

0 comments on commit 4f59a39

Please sign in to comment.