示例#1
0
 def test_attach_binary(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     msg.attach_binary(data, name)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'application/pdf',
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
示例#2
0
 def test_attach_binary(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     msg.attach_binary(data, name)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'application/pdf',
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
示例#3
0
 def test_attach_binary_content_type_override(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     content_type = 'xcascasc'
     name = 'test.pdf'
     msg.attach_binary(data, name, content_type=content_type)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': content_type,
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
示例#4
0
 def test_attach_binary_default_content_type(self, mock_type):
     mock_type.return_value = 'application/octet-stream'
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.bin'
     msg.attach_binary(data, name)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'application/octet-stream',
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
示例#5
0
 def test_attach_binary_content_type_override(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     content_type = 'xcascasc'
     name = 'test.pdf'
     msg.attach_binary(data, name, content_type=content_type)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': content_type,
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
示例#6
0
 def test_attach_binary_default_content_type(self, mock_type):
     mock_type.return_value = 'application/octet-stream'
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.bin'
     msg.attach_binary(data, name)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'application/octet-stream',
         'Name': name
     }
     self.assertEqual(msg.attachments, [attachment])
示例#7
0
 def test_attach_binary_with_content_id(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     content_type = 'image/png'
     content_id = 'cid:{0}@example.com'.format(uuid.uuid4())
     msg.attach_binary(data, name, content_type=content_type,
                       content_id=content_id)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'image/png',
         'Name': name,
         'ContentID': content_id
     }
     self.assertEqual(msg.attachments, [attachment])
示例#8
0
 def test_attach_binary_with_content_id(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     content_type = 'image/png'
     content_id = 'cid:{0}@example.com'.format(uuid.uuid4())
     msg.attach_binary(data, name, content_type=content_type,
                       content_id=content_id)
     attachment = {
         'Content': b64encode(data).decode('utf-8'),
         'ContentType': 'image/png',
         'Name': name,
         'ContentID': content_id
     }
     self.assertEqual(msg.attachments, [attachment])
示例#9
0
 def test_attach_binary_no_content_id(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     msg.attach_binary(data, name)
     self.assertEqual('ContentID' in msg.attachments[0], False)
示例#10
0
 def test_attach_binary_no_content_id(self):
     msg = Message(to='me', text='hi')
     data = urandom(64)
     name = 'test.pdf'
     msg.attach_binary(data, name)
     self.assertEqual('ContentID' in msg.attachments[0], False)