Login | Register
My pages Projects Community openCollabNet

Discussions > Commits > svn commit: r135 - trunk/repoguard: src/repoguard/modules test/repoguard_test/modules

repoguard
Discussion topic

Back to topic list

svn commit: r135 - trunk/repoguard: src/repoguard/modules test/repoguard_test/modules

Author schlauch
Full name Tobias Schlauch
Date 2012-09-19 14:03:02 PDT
Message Author: schlauch
Date: 2012-09-19 14:03:01-0700
New Revision: 135

Modified:
   trunk/repoguard/src/​repoguard/modules/sm​tp_client.py
   trunk/repoguard/test​/repoguard_test/modu​les/test_smtp_client​.py

Log:
Fixes ISSUE #49:
Added the following header: MIME-Version, Content-Type, and Content-Transfer-Encoding.

Modified: trunk/repoguard/src/​repoguard/modules/sm​tp_client.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/src/repoguar​d/modules/smtp_clien​t.py?view=diff&p​athrev=135&r1=13​4&r2=135
====================​====================​====================​==================
--- trunk/repoguard/src/​repoguard/modules/sm​tp_client.py (original)
+++ trunk/repoguard/src/​repoguard/modules/sm​tp_client.py 2012-09-19 14:03:01-0700
@@ -12,7 +12,14 @@
     It supports anonymous and simple user name/password authentication. """
     
     _ENCODING = "UTF-8"
-
+ _MAIL_TEMPLATE = (
+ "From: %s\n"
+ "To: %s\n"
+ "Subject: %s\n"
+ "MIME-Version: 1.0\n"
+ "Content-Type: text/plain; charset=%s\n"
+ "Content-Transfer-Encoding: 8bit\n%s")
+
     def __init__(self, server_name="localhost", port=0, credentials=None, debug_level=0):
         self._server_name = server_name
         self._port = port
@@ -44,6 +51,5 @@
         return smtp_client
     
     def _create_mail(self, from_address, to_address, subject, content):
- message = u"From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s"
- message = message % (from_address, to_address, subject, content)
+ message = self._MAIL_TEMPLATE % (from_address, to_address, subject, self._ENCODING, content)
         return message.encode(self._ENCODING)

Modified: trunk/repoguard/test​/repoguard_test/modu​les/test_smtp_client​.py
Url: http://repoguard.tig​ris.org/source/brows​e/repoguard/trunk/re​poguard/test/repogua​rd_test/modules/test​_smtp_client.py?view​=diff&pathrev=13​5&r1=134&r2=​135
====================​====================​====================​==================
--- trunk/repoguard/test​/repoguard_test/modu​les/test_smtp_client​.py (original)
+++ trunk/repoguard/test​/repoguard_test/modu​les/test_smtp_client​.py 2012-09-19 14:03:01-0700
@@ -15,6 +15,16 @@
 from repoguard.modules import smtp_client
 
 
+_MAIL = (
+ "From: me at here dot com\n"
+ "To: to at there dot com\n"
+ "Subject: subject\n"
+ "MIME-Version: 1.0\n"
+ "Content-Type: text/plain; charset=UTF-8\n"
+ "Content-Transfer-Encoding: 8bit\n"
+ "unicöde messäge")
+
+
 class TestMail(object):
     
     def setup_method(self, _):
@@ -22,16 +32,16 @@
         smtp_client.smtplib.SMTP = mock.Mock(return_val​ue=self._smtp_client​)
        
     def test_with_login(self):
- smtp_client_helper = smtp_client.SmtpClie​ntHelper("servername​", "25", ("username", "pwassword"), 0)
+ smtp_client_helper = smtp_client.SmtpClie​ntHelper("servername​", "25", ("username", "password"), 0)
         smtp_client_helper.s​end_mail("me at here dot co​m", ["to at there dot com"], "subject", unicode("unicöde messäge", "utf-8"))
         
         assert self._smtp_client.login.called
- assert self._smtp_client.se​ndmail.called
+ assert self._smtp_client.se​ndmail.call_args[0][​2] == _MAIL
         assert self._smtp_client.quit.called
         
     def test_without_login(self):
         for smtp_client_helper in [
- smtp_client.SmtpClientHelper(), smtp_client.SmtpClie​ntHelper(credentials​=(None, None))]:
+ smtp_client.SmtpClientHelper(), smtp_client.SmtpClie​ntHelper(credentials​=(None, None))]:
         
             smtp_client_helper.s​end_mail("me at here dot co​m", ["to at there dot com"], "subject", "message with test")

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

svn commit: r135 - trunk/repoguard: src/repoguard/modules test/repoguard_test/modules schlauch Tobias Schlauch 2012-09-19 14:03:02 PDT
Messages per page: