Skip to content

Commit

Permalink
transaction: add a test for insert_header
Browse files Browse the repository at this point in the history
The insert_header method wasn't being tested at all, so
add tested ensuring that it is working as expected.
  • Loading branch information
damoxc committed Feb 1, 2012
1 parent cd85a96 commit 62f9202
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions vsmtpd/tests/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,21 @@ def test_body_filename_flush(self):
def test_connection_property(self):
self.assertEqual(self.tnx.connection, self.tnx._connection)

def test_body_insert_header(self):
self.tnx.body.write('Subject: blah blah\r\n')
self.tnx.body.write('From: John Smith <john@example.com>\r\n')
self.tnx.body.write('To: Joe Bloggs <joe@example.com>\r\n')
self.tnx.body.write('Date: Fri, 25 Mar 2011 13:35:33 -0000\r\n')
self.tnx.body.write('\r\n')
self.tnx.end_headers()

self.tnx.headers.insert_header(0, 'Received', 'By me')
self.assertTrue(self.tnx.headers.has_key('Received'))
self.assertEqual(self.tnx.headers.keys()[0], 'Received')

self.tnx.headers.insert_header(5, 'X-Test', 'vsmtpd')
self.assertTrue(self.tnx.headers.has_key('X-Test'))
self.assertEqual(self.tnx.headers.keys()[5], 'X-Test')

def tearDown(self):
self.tnx.close()

0 comments on commit 62f9202

Please sign in to comment.