def test_invalid_email(): try: parse_user('John 5 <john5.>', True) except ValueError: assert True else: assert False, "invalid email should raise validation exception"
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
def test_only_first(): assert parse_user('John') == ( '', 'John', '')
def test_no_email(): assert parse_user('John 5') == ( '', 'John', '5')
def test_only_email2(): assert parse_user(' <*****@*****.**>') == ( '*****@*****.**', '', '')
def test_full_user(): assert parse_user('John 5 <*****@*****.**>') == ( '*****@*****.**', 'John', '5')
def test_name_with_bracket(): assert parse_user('Dmitriy Korba(surc)') == ('', 'Dmitriy', 'Korba(surc)')
def test_first_middle_last_email(): assert parse_user('John William Lowery <*****@*****.**>') == ( '*****@*****.**', 'John', 'William Lowery')
def test_first_middle_last(): assert parse_user('John William Lowery') == ( '', 'John', 'William Lowery')