示例#1
0
def test_invalid_email():
    try:
        parse_user('John 5 <john5.>', True)
    except ValueError:
        assert True
    else:
        assert False, "invalid email should raise validation exception"
示例#2
0
def check_user(ustring, data_typ):
    """
    Check user string is valid or not.
    ERROR: The email of user is blank or invalid.
    """
    try:
        parse_user(ustring, True)
    except ValueError as err:
        error("(%s): %s" % (data_typ, err))
        return 1
    return 0
示例#3
0
文件: check.py 项目: 01org/iris-panel
def check_user(ustring, data_typ):
    """
    Check user string is valid or not.
    ERROR: The email of user is blank or invalid.
    """
    try:
        parse_user(ustring, True)
    except ValueError as err:
        error("(%s): %s" % (data_typ, err))
        return 1
    return 0
示例#4
0
def test_only_first():
    assert parse_user('John') == (
        '', 'John', '')
示例#5
0
def test_no_email():
    assert parse_user('John 5') == (
        '', 'John', '5')
示例#6
0
def test_only_email2():
    assert parse_user(' <*****@*****.**>') == (
        '*****@*****.**', '', '')
示例#7
0
def test_full_user():
    assert parse_user('John 5 <*****@*****.**>') == (
        '*****@*****.**', 'John', '5')
示例#8
0
def test_name_with_bracket():
    assert parse_user('Dmitriy Korba(surc)') == ('', 'Dmitriy', 'Korba(surc)')
示例#9
0
def test_first_middle_last_email():
    assert parse_user('John William Lowery <*****@*****.**>') == (
        '*****@*****.**', 'John', 'William Lowery')
示例#10
0
def test_first_middle_last():
    assert parse_user('John William Lowery') == (
        '', 'John', 'William Lowery')