# Path: deliver/tests/test_base.py
# class BaseTest(unittest.TestCase):
# 
#     def setUp(self):
#         from test_data.test_config import py
#         self.config = py.copy()
# 
#     def tearDown(self):
#         super(BaseTest,self).tearDown()
#         if os.path.isfile(self.config['db_name']):
#             os.remove(self.config['db_name'])
# 
# def load_msg(fileName):
#     '''Loads the message contained in the given file and returns it as
#     an UnicodeMessage.'''
#     return UnicodeMessage(email.message_from_file(open_data(fileName)))
# 
# def load_all_msg():
#     '''Loads all the available sample messages and returns them as a list.'''
#     return [load_msg(fileName) for fileName in ['sample', 'sample2',
#                                                 'sample3',
#                                                 'sample4', # content base64
#                                                 'sample5', # content base64 utf-8
#                                                 'sample6', # empty content
#                                                 'sample7', # invalid sender
#                                                 'sample8', # whitelisted sender
#                                                 'sample9',  # blacklisted sender
#                                                 'sample10', # get www.google.com
#                                                 'sample11', # no header/body encoding
#                                                 'sample13' # msg without subject
#                                                 ]]


from deliver.tests.test_base import BaseTest, load_msg, load_all_msg
        self.msg = load_msg('sample')
        self.msg.get_payload(0).set_charset('utf-8')
        self._test_set(s, u'Con cien ca=C3=B1ones por banda, viento en popa a toda vela')

    def test_set_payload_base64(self):
        s = u'Con cien cañones por banda, viento en popa a toda vela'
        self.msg = load_msg('sample4')
        self._test_set(s, u'Con cien ca=F1ones por banda, viento en popa a toda vela')

    def test_set_payload_base64_utf8(self):
        s = u'Con cien cañones por banda, viento en popa a toda vela'
        self.msg = load_msg('sample5')
        self._test_set(s, u'Con cien ca=C3=B1ones por banda, viento en popa a toda vela')

    def test_set_payload_empty(self):
        s = u'Con cien cañones por banda, viento en popa a toda vela'
        self.msg = load_msg('sample6')
        self._test_set(s, u'Con cien ca=F1ones por banda, viento en popa a toda vela')

    def test_get_payload(self):
        self.msg = load_msg('sample')
        s = u'La direcci=F3n ha cambiado como pod=E9is comprobar en'
        self.assertTrue(s in self.get_text())

    def test_get_payload_decoded(self):
        self.msg = load_msg('sample')
        s = u'La dirección ha cambiado como podéis comprobar en el'
        self.assertTrue(s in self.get_text(decode=True))

    def test_get_payload_base64(self):

# Path: deliver/tests/test_base.py
# class BaseTest(unittest.TestCase):
# 
#     def setUp(self):
#         from test_data.test_config import py
#         self.config = py.copy()
# 
#     def tearDown(self):
#         super(BaseTest,self).tearDown()
#         if os.path.isfile(self.config['db_name']):
#             os.remove(self.config['db_name'])
# 
# def load_msg(fileName):
#     '''Loads the message contained in the given file and returns it as
#     an UnicodeMessage.'''
#     return UnicodeMessage(email.message_from_file(open_data(fileName)))
# 
# def load_all_msg():
#     '''Loads all the available sample messages and returns them as a list.'''
#     return [load_msg(fileName) for fileName in ['sample', 'sample2',
#                                                 'sample3',
#                                                 'sample4', # content base64
#                                                 'sample5', # content base64 utf-8
#                                                 'sample6', # empty content
#                                                 'sample7', # invalid sender
#                                                 'sample8', # whitelisted sender
#                                                 'sample9',  # blacklisted sender
#                                                 'sample10', # get www.google.com
#                                                 'sample11', # no header/body encoding
#                                                 'sample13' # msg without subject
#                                                 ]]


# Path: deliver/tests/converter/test_converter.py
from deliver.tests.test_base import BaseTest, load_msg, load_all_msg

        self.msg = load_msg('sample')
        self.msg.get_payload(0).set_charset('utf-8')
        self._test_set(s, u'Con cien ca=C3=B1ones por banda, viento en popa a toda vela')

    def test_set_payload_base64(self):
        s = u'Con cien cañones por banda, viento en popa a toda vela'
        self.msg = load_msg('sample4')
        self._test_set(s, u'Con cien ca=F1ones por banda, viento en popa a toda vela')

    def test_set_payload_base64_utf8(self):
        s = u'Con cien cañones por banda, viento en popa a toda vela'
        self.msg = load_msg('sample5')
        self._test_set(s, u'Con cien ca=C3=B1ones por banda, viento en popa a toda vela')

    def test_set_payload_empty(self):
        s = u'Con cien cañones por banda, viento en popa a toda vela'
        self.msg = load_msg('sample6')
        self._test_set(s, u'Con cien ca=F1ones por banda, viento en popa a toda vela')

    def test_get_payload(self):
        self.msg = load_msg('sample')
        s = u'La direcci=F3n ha cambiado como pod=E9is comprobar en'
        self.assertTrue(s in self.get_text())

    def test_get_payload_decoded(self):
        self.msg = load_msg('sample')
        s = u'La dirección ha cambiado como podéis comprobar en el'
        self.assertTrue(s in self.get_text(decode=True))

    def test_get_payload_base64(self):

        self.msg = load_msg('sample4')