Skip to content

Commit

Permalink
add tests to test proper usage of dots in email addresses , email_val…
Browse files Browse the repository at this point in the history
…idator
  • Loading branch information
Sivan Grünberg committed Apr 8, 2019
1 parent 7092ef1 commit c9aaf45
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ckan/tests/logic/test_validators.py
Expand Up @@ -193,6 +193,35 @@ def call_validator(*args, **kwargs):
return validators.name_validator(*args, **kwargs)
call_validator(invalid_value, context={})

def test_email_validator_with_invalid_value(selfs):
invalid_values = [
'..test...test..@example.com',
'test @example.com',
'test@ example.com',
'test..test@example.com',
'test.test...@example.com',
'...test@example.com',
]

for invalid_value in invalid_values:
@raises_Invalid
def call_validator(*args, **kwargs):
return validators.email_validator(*args, **kwargs)
call_validator(invalid_value, context={})

def test_email_validator_with_valid_value(self):
valid_values = [
'text@example.com',
'test.this@example.com',
'test.this@server.example.com',
]

for valid_value in valid_values:
@returns_arg
def call_validator(*args, **kwargs):
return validators.email_validator(*args, **kwargs)
call_validator(valid_value)

def test_name_validator_with_valid_value(self):
'''If given a valid string name_validator() should do nothing and
return the string.
Expand Down

0 comments on commit c9aaf45

Please sign in to comment.