Beispiel #1
0
def test_User():
    from did.base import User
    assert User

    # No email provided
    try:
        user = User("")
    except ConfigError:
        pass
    else:
        raise RuntimeError("No exception for missing email")

    # Invalid email address
    try:
        user = User("bad-email")
    except ConfigError:
        pass
    else:
        raise RuntimeError("No exception for invalid email")

    # Short email format
    user = User("*****@*****.**")
    assert user.email == "*****@*****.**"
    assert user.login == "some"
    assert user.name == None
    assert unicode(user) == "*****@*****.**"

    # Full email format
    user = User("Some Body <*****@*****.**>")
    assert user.email == "*****@*****.**"
    assert user.login == "some"
    assert user.name == "Some Body"
    assert unicode(user) == "Some Body <*****@*****.**>"

    # Invalid alias definition
    try:
        user = User("[email protected]; bad-alias", stats="bz")
    except ConfigError:
        pass
    else:
        raise RuntimeError("No exception for invalid alias definition")

    # Custom email alias
    user = User("[email protected]; bz: [email protected]", stats="bz")
    assert user.email == "*****@*****.**"
    assert user.login == "bugzilla"

    # Custom login alias
    user = User("[email protected]; bz: bzlogin", stats="bz")
    assert user.login == "bzlogin"

    # Custom email alias in config section
    Config(config="[bz]\ntype = bugzilla\nemail = [email protected]")
    user = User("*****@*****.**", stats="bz")
    assert user.email == "*****@*****.**"
    assert user.login == "bugzilla"

    # Custom login alias in config section
    Config(config="[bz]\ntype = bugzilla\nlogin = bzlogin")
    user = User("*****@*****.**", stats="bz")
    assert user.login == "bzlogin"

    # User cloning
    user = User("[email protected]; bz: bzlogin")
    clone = user.clone("bz")
    assert clone.login == "bzlogin"
Beispiel #2
0
def test_User():
    from did.base import User
    assert User

    # No email provided
    try:
        user = User("")
    except ConfigError:
        pass
    else:
        raise RuntimeError("No exception for missing email")

    # Invalid email address
    try:
        user = User("bad-email")
    except ConfigError:
        pass
    else:
        raise RuntimeError("No exception for invalid email")

    # Short email format
    user = User("*****@*****.**")
    assert user.email == "*****@*****.**"
    assert user.login == "some"
    assert user.name == None
    assert str(user) == "*****@*****.**"

    # Full email format
    user = User("Some Body <*****@*****.**>")
    assert user.email == "*****@*****.**"
    assert user.login == "some"
    assert user.name == "Some Body"
    assert str(user) == "Some Body <*****@*****.**>"

    # Invalid alias definition
    try:
        user = User("[email protected]; bad-alias", stats="bz")
    except ConfigError:
        pass
    else:
        raise RuntimeError("No exception for invalid alias definition")

    # Custom email alias
    user = User("[email protected]; bz: [email protected]", stats="bz")
    assert user.email == "*****@*****.**"
    assert user.login == "bugzilla"

    # Custom login alias
    user = User("[email protected]; bz: bzlogin", stats="bz")
    assert user.login == "bzlogin"

    # Custom email alias in config section
    Config(config="[bz]\ntype = bugzilla\nemail = [email protected]")
    user = User("*****@*****.**", stats="bz")
    assert user.email == "*****@*****.**"
    assert user.login == "bugzilla"

    # Custom login alias in config section
    Config(config="[bz]\ntype = bugzilla\nlogin = bzlogin")
    user = User("*****@*****.**", stats="bz")
    assert user.login == "bzlogin"

    # User cloning
    user = User("[email protected]; bz: bzlogin")
    clone = user.clone("bz")
    assert clone.login == "bzlogin"