Ejemplo n.º 1
0
def test_invalid_email(raw):
    with pytest.raises(email.EmailValueError):
        email.Email(raw)
Ejemplo n.º 2
0
def test_is_ip():
    assert email.Email("[email protected]").info.is_ip
Ejemplo n.º 3
0
def test_is_internal(raw):
    assert email.Email(raw).info.is_internal
Ejemplo n.º 4
0
def test_is_private(raw):
    assert email.Email(raw).info.is_private
Ejemplo n.º 5
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import json
from urllib.parse import quote

import pytest

from typic.types import email

EMAIL_RAW = "o'*****@*****.**"
EMAIL = email.Email(EMAIL_RAW)
PRETTY_EMAIL_RAW = f"Foo Bar <{EMAIL_RAW}>"
PRETTY_EMAIL = email.Email(PRETTY_EMAIL_RAW)


@pytest.mark.parametrize(
    argnames=("name", "expected", "eml"),
    argvalues=[
        ("username", "o'foo.bar", EMAIL),
        ("host", "foobar.net", EMAIL),
        ("address", EMAIL_RAW, EMAIL),
        ("address_encoded", quote(EMAIL_RAW), EMAIL),
        ("username", "o'foo.bar", PRETTY_EMAIL),
        ("name", "Foo Bar", PRETTY_EMAIL),
        ("address", PRETTY_EMAIL_RAW, PRETTY_EMAIL),
        ("address_encoded", f"Foo Bar <{quote(EMAIL_RAW)}>", PRETTY_EMAIL),
    ],
)
def test_email_info_attrs(name, expected, eml):
    value = getattr(eml.info, name)
    assert value == expected