Esempio n. 1
0
 def setUp(self):
     self.message = Message(
         "*****@*****.**",
         ["*****@*****.**"],
         "hi thar",
         "This is a message."
     )
Esempio n. 2
0
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)
Esempio n. 3
0
 def test_init_single_addr(self):
     message = Message(
         "*****@*****.**",
         "*****@*****.**",
         "hi thar",
         "This is a message."
     )
     self.assertTrue(isinstance(message.to_addrs, types.ListType))
Esempio n. 4
0
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)