# Path: deliver/send.py
# class Sender:
#     '''
#     Class that is responsible of sending emails. It uses a specified SMTP server.
#     '''
# 
#     def __init__(self, config):
#         self._cfg = config
# 
#     def send(self, msg, *recipients):
#         '''
#         Sends the given UnicodeMessage to each of the specified recipients.
#         '''
#         assert isinstance(msg, UnicodeMessage)
#         for recipient in recipients:
#             assert isinstance(recipient, unicode)
#         self._send(msg, *recipients)
# 
#     def _send(self, msg, *recipients):
#         '''
#         Sends the given UnicodeMessage to each of
#         the specified recipients.
# 
#         The emails are sent from the specified server, using the specified address. The subject
#         is modified to include a subject prefix if it is not already there.
#         '''
#         msg.replace_header('Subject', self._prepare_subject(msg['Subject']))
#         msg.replace_header('From', self.get_address())
#         msg.replace_header('Reply-To', self.get_address())
#         logging.debug('email ready to be sent: %s', msg['Message-Id'])
#         for recipient in recipients:
#             logger.debug('Sending message to %s', recipient)
#             s = smtplib.SMTP(self._cfg['smtp_server'])
#             msg.replace_header('To', recipient)
#             s.sendmail(self.get_address(), recipient, msg.as_string())
#             s.quit()
# 
#     def get_address(self):
#         '''Gets the address used by this sender'''
#         return self._cfg['sender']
# 
#     def _prepare_subject(self, subject):
#         '''Modifies the given subject to include a prefix if it is not already there'''
#         if self._cfg['subject_prefix'] in subject:
#             return subject
#         return self._cfg['subject_prefix'] + ' ' + subject


from test_base import BaseTest, load_msg
from mock import patch
from smtplib import SMTP
from deliver.send import Sender



class SendTest(BaseTest):

    def setUp(self):
        super(SendTest,self).setUp()

# Path: deliver/send.py
# class Sender:
#     '''
#     Class that is responsible of sending emails. It uses a specified SMTP server.
#     '''
# 
#     def __init__(self, config):
#         self._cfg = config
# 
#     def send(self, msg, *recipients):
#         '''
#         Sends the given UnicodeMessage to each of the specified recipients.
#         '''
#         assert isinstance(msg, UnicodeMessage)
#         for recipient in recipients:
#             assert isinstance(recipient, unicode)
#         self._send(msg, *recipients)
# 
#     def _send(self, msg, *recipients):
#         '''
#         Sends the given UnicodeMessage to each of
#         the specified recipients.
# 
#         The emails are sent from the specified server, using the specified address. The subject
#         is modified to include a subject prefix if it is not already there.
#         '''
#         msg.replace_header('Subject', self._prepare_subject(msg['Subject']))
#         msg.replace_header('From', self.get_address())
#         msg.replace_header('Reply-To', self.get_address())
#         logging.debug('email ready to be sent: %s', msg['Message-Id'])
#         for recipient in recipients:
#             logger.debug('Sending message to %s', recipient)
#             s = smtplib.SMTP(self._cfg['smtp_server'])
#             msg.replace_header('To', recipient)
#             s.sendmail(self.get_address(), recipient, msg.as_string())
#             s.quit()
# 
#     def get_address(self):
#         '''Gets the address used by this sender'''
#         return self._cfg['sender']
# 
#     def _prepare_subject(self, subject):
#         '''Modifies the given subject to include a prefix if it is not already there'''
#         if self._cfg['subject_prefix'] in subject:
#             return subject
#         return self._cfg['subject_prefix'] + ' ' + subject


# Path: deliver/tests/test_send.py
from test_base import BaseTest, load_msg
from mock import patch
from smtplib import SMTP
from deliver.send import Sender




class SendTest(BaseTest):

    def setUp(self):
        super(SendTest,self).setUp()

        self.sender = Sender(self.config)