Ejemplo n.º 1
0
def test_address_str():
    """
    tests for a correctly formatted email address
    Returns:
        boolean
    """
    address = "Sam Gibson <*****@*****.**>"
    result = str(Address(address))
    assert result == address
Ejemplo n.º 2
0
def test_address_repr():
    """
        tests for a correctly formatted email address
        Returns:
            boolean
        """
    address = "Sam Gibson <*****@*****.**>"
    result = Address(address).__repr__()
    assert result == f"address.Address(\"{address}\")"
Ejemplo n.º 3
0
def create_address(email: str, name: str) -> Address:
    """

    Args:
        email: email address string
        name: name of email recipient

    Returns:
        addr: Address object
    """
    addr = Address.__new__(Address)
    addr.email = email
    addr.name = name
    return addr
Ejemplo n.º 4
0
def test_address_create(addr, expected, raises):
    """

    Args:
        addr: email address
        expected: Address object
        raises: error type

    Returns:
        boolean in response to the object being created or not (True or False)
    """
    with raises:
        result = Address(addr)
        assert result == expected
Ejemplo n.º 5
0
    Args:
        addr: email address
        expected: Address object
        raises: error type

    Returns:
        boolean in response to the object being created or not (True or False)
    """
    with raises:
        result = Address(addr)
        assert result == expected


@pytest.mark.parametrize(
    "addr_a, addr_b, expected",
    [(Address("Sam Gibson <*****@*****.**>"),
      Address("Sam Gibson <*****@*****.**>"), True),
     (Address("Sam Gibson <*****@*****.**>"),
      Address("*****@*****.**"), True),
     (Address("Sam Gibson <*****@*****.**>"),
      Address("*****@*****.**"), False),
     (Address("Sam Gibson <*****@*****.**>"), "not an address",
      False)])
def test_address_eq(addr_a, addr_b, expected):
    """

    Args:
        addr_a: email address
        addr_b: email address
        expected: boolean
Ejemplo n.º 6
0
def create_address(email: str, name: str) -> Address:
    addr = Address.__new__(Address)
    addr.email = email
    addr.name = name
    return addr
Ejemplo n.º 7
0
def test_address_repr():
    address = "Sam Gibson <*****@*****.**>"
    result = Address(address).__repr__()
    assert result == f"address.Address(\"{address}\")"
Ejemplo n.º 8
0
def test_address_str():
    address = "Sam Gibson <*****@*****.**>"
    result = str(Address(address))
    assert result == address
Ejemplo n.º 9
0
def test_address_create(addr, expected, raises):
    with raises:
        result = Address(addr)
        assert result == expected