def testEmptyAddress(self): """ mail.sendmail: encode address with empty address: 'Phrase <>' Let the smtp server handle this. We may raise error in such case, but we don't do error checking for mail addresses. """ address = u'Phrase <>' expected = str(address) assert sendmail.encodeAddress(address, self.charset) == expected
def testInvalidAddress(self): """ mail.sendmail: encode invalid address 'Phrase <blah' Assume that this is a simple address. This address will probably cause an error when trying to send mail. Junk in, junk out. """ address = u'Phrase <blah' expected = str(address) assert sendmail.encodeAddress(address, self.charset) == expected
def testCompositeUnicode(self): """ mail.sendmail: encode Uncode address: 'ויקי <local@domain>' """ address = u'ויקי <local@domain>' phrase = str(Header(u'ויקי'.encode('utf-8'), self.charset)) expected = phrase + ' ' + '<local@domain>' assert sendmail.encodeAddress(address, self.charset) == expected
def testComposite(self): """ mail.sendmail: encode address: 'Phrase <local@domain>' """ address = u'Phrase <local@domain>' expected = str(address) assert sendmail.encodeAddress(address, self.charset) == expected
def testSimpleAddress(self): """ mail.sendmail: encode simple address: local@domain """ address = u'local@domain' expected = address.encode(CHARSET) assert sendmail.encodeAddress(address, self.charset) == expected
def testEmptyPhrase(self): """ mail.sendmail: encode address with empty phrase: '<local@domain>' """ address = u'<local@domain>' expected = 'local@domain' assert sendmail.encodeAddress(address, self.charset) == expected