Esempio n. 1
0
def test_trim_spaces():
    parts = mailchecker.split_email(" postbox@com")
    expected = {
        "address": "postbox",
        "domain": "com",
        "top_level_domain": "com",
        "second_level_domain": "",
    }

    assert parts == expected
    parts = mailchecker.split_email("postbox@com ")

    assert parts == expected
Esempio n. 2
0
def test_contains_numbers():
    parts = mailchecker.split_email("*****@*****.**")
    expected = {
        "address": "containsnumbers1234567890",
        "domain": "example.com",
        "top_level_domain": "com",
        "second_level_domain": "example",
    }
    assert parts == expected
Esempio n. 3
0
def test_rfc_compliant():
    parts = mailchecker.split_email('"foo@bar"@example.com')
    expected = {
        "address": '"foo@bar"',
        "domain": "example.com",
        "top_level_domain": "com",
        "second_level_domain": "example",
    }
    assert parts == expected
Esempio n. 4
0
def test_four_level_domain():
    parts = mailchecker.split_email("*****@*****.**")
    expected = {
        "address": "test",
        "domain": "mail.randomsmallcompany.co.uk",
        "top_level_domain": "randomsmallcompany.co.uk",
        "second_level_domain": "mail",
    }
    assert parts == expected
Esempio n. 5
0
def test_three_level_domain():
    parts = mailchecker.split_email("*****@*****.**")
    expected = {
        "address": "test",
        "domain": "example.co.uk",
        "top_level_domain": "co.uk",
        "second_level_domain": "example",
    }
    assert parts == expected
Esempio n. 6
0
def test_contains_periods():
    parts = mailchecker.split_email("*****@*****.**")
    expected = {
        "address": "contains.symbol",
        "domain": "domain.contains.symbol",
        "top_level_domain": "contains.symbol",
        "second_level_domain": "domain",
    }
    assert parts == expected
Esempio n. 7
0
def test_contains_hyphen():
    parts = mailchecker.split_email("*****@*****.**")
    expected = {
        "address": "contains-symbol",
        "domain": "example.com",
        "top_level_domain": "com",
        "second_level_domain": "example",
    }
    assert parts == expected
Esempio n. 8
0
def test_contains_period_at_sign():
    parts = mailchecker.split_email('"*****@*****.**"@example.com')
    expected = {
        "address": '"*****@*****.**"',
        "domain": "example.com",
        "top_level_domain": "com",
        "second_level_domain": "example",
    }

    assert parts == expected
Esempio n. 9
0
def test_contains_period_backslash():
    parts = mailchecker.split_email(
        '"contains.and\ symbols"@example.com')  # noqa: W605
    expected = {
        "address": '"contains.and\ symbols"',  # noqa: W605
        "domain": "example.com",
        "top_level_domain": "com",
        "second_level_domain": "example",
    }

    assert parts == expected
Esempio n. 10
0
def test_contains_all_symbols():
    parts = mailchecker.split_email(
        '"()<>[]:;@,\\\"!#$%&\'*+-/=?^_`{}|\ \ \ \ \ ~\ \ \ \ \ \ \ ?\ \ \ \ \ \ \ \ \ \ \ \ ^_`{}|~.a"'  # noqa: W605
        '@allthesymbols.com')
    expected = {
        "address":
        '"()<>[]:;@,\\\"!#$%&\'*+-/=?^_`{}|\ \ \ \ \ ~\ \ \ \ \ \ \ ?\ \ \ \ \ \ \ '  # noqa: W605
        '\ \ \ \ \ ^_`{}|~.a"',  # noqa: W605
        "domain":
        "allthesymbols.com",
        "top_level_domain":
        "com",
        "second_level_domain":
        "allthesymbols",
    }

    assert parts == expected
Esempio n. 11
0
def test_not_rfc_compliant():
    assert mailchecker.split_email("example.com") is False
    assert mailchecker.split_email("abc.example.com") is False
    assert mailchecker.split_email("@example.com") is False
    assert mailchecker.split_email("test@") is False