def setUp(self): self.message = Message( "*****@*****.**", ["*****@*****.**"], "hi thar", "This is a message." )
class MessageTest(unittest.TestCase): def setUp(self): self.message = Message("*****@*****.**", ["*****@*****.**"], "hi thar", "This is a message.") def test_init(self): self.assertTrue(self.message.message) str(self.message) def test_init_single_addr(self): message = Message("*****@*****.**", "*****@*****.**", "hi thar", "This is a message.") self.assertTrue(isinstance(message.to_addrs, types.ListType)) def test_attach(self): open("foo.txt", "w").write("sometext") self.message.attach("foo.txt") self.assertTrue(self.message.msg) def test_render(self): self.message.add_header("X-MailTag", "foobar") sio = self.message.render() self.assertTrue("*****@*****.**" in sio.getvalue()) @patch("cyclone.mail.reactor.connectTCP") def test_sendmail(self, conn): sendmail({"host": "localhost", "tls": True}, self.message) self.assertTrue(conn.call_count)
def test_init_single_addr(self): message = Message( "*****@*****.**", "*****@*****.**", "hi thar", "This is a message." ) self.assertTrue(isinstance(message.to_addrs, types.ListType))
class MessageTest(unittest.TestCase): def setUp(self): self.message = Message( "*****@*****.**", ["*****@*****.**"], "hi thar", "This is a message." ) def test_init(self): self.assertTrue(self.message.message) str(self.message) def test_init_single_addr(self): message = Message( "*****@*****.**", "*****@*****.**", "hi thar", "This is a message." ) self.assertTrue(isinstance(message.to_addrs, types.ListType)) def test_attach(self): open("foo.txt", "w").write("sometext") self.message.attach("foo.txt") self.assertTrue(self.message.msg) def test_render(self): self.message.add_header("X-MailTag", "foobar") sio = self.message.render() self.assertTrue("*****@*****.**" in sio.getvalue()) @patch("cyclone.mail.reactor.connectTCP") def test_sendmail(self, conn): sendmail( {"host": "localhost", "tls": True}, self.message ) self.assertTrue(conn.call_count)