forked from tornadoweb/tornado
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
language: python | ||
python: | ||
- "2.6" | ||
- "2.7" | ||
- "pypy" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# | ||
# Copyright 2014 David Novakovic | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
from twisted.trial import unittest | ||
from cyclone.mail import ContextFactory, ClientContextFactory, Message | ||
from cyclone.mail import sendmail | ||
from mock import Mock, patch | ||
import types | ||
|
||
|
||
class ContextFactoryTest(unittest.TestCase): | ||
def test_no_sslv3(self): | ||
"""We must disable ssl v3.""" | ||
ClientContextFactory.getContext = Mock() | ||
cf = ContextFactory() | ||
ctx = cf.getContext() | ||
ctx.set_options.assert_called_with(33554432) | ||
|
||
|
||
class MessageTest(unittest.TestCase): | ||
def setUp(self): | ||
self.message = Message( | ||
"foo@example.com", | ||
["bar@example.com"], | ||
"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( | ||
"foo@example.com", | ||
"bar@example.com", | ||
"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("foo@example.com" 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
mock | ||
twisted>=12.0 | ||
twisted>=12.0 | ||
pyopenssl |