Esempio n. 1
0
def test_asAddresses():
    assert asAddresses(None) is None
    assert asAddresses('') is None
    assert asAddresses(' ') in (None, [])
    assert asAddresses('*****@*****.**') == [{
        'name': None,
        'email': '*****@*****.**'
    }]
    assert asAddresses('<*****@*****.**>') == [{
        'name': None,
        'email': '*****@*****.**'
    }]
    assert asAddresses('"Joe Doe" <*****@*****.**>') == [{
        'name':
        'Joe Doe',
        'email':
        '*****@*****.**'
    }]
    assert asAddresses('  Joe   Doe   <*****@*****.**>') == [{
        'name':
        'Joe Doe',
        'email':
        '*****@*****.**'
    }]
    assert asAddresses('"Joe Doe"   <*****@*****.**>') == [{
        'name':
        'Joe Doe',
        'email':
        '*****@*****.**'
    }]
    assert asAddresses('杨孝宇 <*****@*****.**>') == [{
        'name':
        '杨孝宇',
        'email':
        '*****@*****.**'
    }]
    assert asAddresses('=?utf-8?q?Joe_Doe?= <*****@*****.**>') == [{
        'name':
        'Joe Doe',
        'email':
        '*****@*****.**'
    }]
    assert asAddresses('"A B C" < [email protected]> , d@e') == [
        {
            'name': 'A B C',
            'email': '[email protected]'
        },
        {
            'name': None,
            'email': 'd@e'
        },
    ]
    assert asAddresses('Brothers: [email protected], [email protected];') == [
        {
            'name': None,
            'email': '*****@*****.**'
        },
        {
            'name': None,
            'email': '*****@*****.**'
        },
    ]
    assert asAddresses('''"  James Smythe" <*****@*****.**>, Friends:
  [email protected], =?UTF-8?Q?John_Sm=C3=AEth?=
  <*****@*****.**>;''') == [{
        "name": "James Smythe",
        "email": "*****@*****.**"
    }, {
        "name": None,
        "email": "*****@*****.**"
    }, {
        "name": "John Smîth",
        "email": "*****@*****.**"
    }]
Esempio n. 2
0
 def replyTo(self):
     return asAddresses(self.get_header('reply-to'))
Esempio n. 3
0
 def get(self):
     return asAddresses(self.get_header(field)) or []
Esempio n. 4
0
 def get(self):
     self[field] = asAddresses(self.get_header(field))
     return self[field]