Skip to content

Commit 0061106

Browse files
author
Martin Davidsson
committed
Update tests to check for Content-ID header.
Change string formatting syntax for style purposes.
1 parent 011628b commit 0061106

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

sendgrid/transport/smtp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,6 @@ def _getFileMIME(self, attach):
183183
msg.add_header('Content-Disposition', 'attachment', filename=filename)
184184

185185
if attach['cid']:
186-
msg.add_header('Content-ID', '<{0}>'.format(attach['cid']))
186+
msg.add_header('Content-ID', '<%s>' % attach['cid'])
187187

188188
return msg

test/test_smtp_transport.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ def test_smtp_transport_valid_password(self):
4343
smtp_quit.restore()
4444

4545

46+
def test_smtp_transport_content_id_header(self):
47+
smtp_transport = smtp.Smtp('username', 'password', tls=False)
48+
49+
f = smtp_transport._getFileMIME({'file': 'img.png', 'name': 'contents', 'cid': None})
50+
self.assertEqual(None, f.get('Content-ID'))
51+
52+
f = smtp_transport._getFileMIME({'file': 'img.png', 'name': 'contents', 'cid': 'cid'})
53+
self.assertEqual('<cid>', f.get('Content-ID'))
54+
55+
4656
class FakeException(IOError):
4757
def __init__(self, msg):
4858
self.msg = msg

0 commit comments

Comments
 (0)