def testNoRecipient(self): info = { 'sender': '*****@*****.**', 'recipients': '', 'cc': ['*****@*****.**'], 'bcc': '[email protected],[email protected]', 'subject': 'Τεστ test', 'body': 'This is a τεστ on utf8' } with self.assertRaises(ValueError): message = Message(**info)
def testInvalidSender(self): invalid = ['a', 'a@', '@.', '@a.', '.@', 'a@@', 'a@@.'] for sender in invalid: info = { 'sender': sender, 'recipients': '*****@*****.**', 'subject': 'Τεστ test', 'body': 'This is a τεστ on utf8' } with self.assertRaises(ValueError): message = Message(**info)
def testValid(self): info = { 'sender': '*****@*****.**', 'recipients': '*****@*****.**', 'cc': ['*****@*****.**'], 'bcc': '[email protected],[email protected]', 'subject': 'Τεστ test', 'body': 'This is a τεστ on utf8' } message = Message(**info) self.assertTrue(message.subject == u'Τεστ test') self.assertTrue(message.body == u'This is a τεστ on utf8')
def testInvalidBCC(self): invalid = [ 'a', 'a@', '@.', '@a.', '.@', 'a@@', 'a@@.', '[email protected],a.', 'inv.domain.com,[email protected]' ] for bcc in invalid: info = { 'sender': '*****@*****.**', 'recipients': '*****@*****.**', 'bcc': bcc, 'subject': 'Τεστ test', 'body': 'This is a τεστ on utf8' } with self.assertRaises(ValueError): message = Message(**info)
def testRecipients(self): info = { 'sender': '*****@*****.**', 'recipients': '*****@*****.**', 'cc': ['*****@*****.**'], 'bcc': '[email protected],[email protected]', 'subject': 'Τεστ test', 'body': 'This is a τεστ on utf8', 'content': 'html' } message = Message(**info) self.assertTrue(message.recipients == [ '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**' ])