~jteh/bzr-email/pushPullEnhancements

« back to all changes in this revision

Viewing changes to tests/testemail.py

  • Committer: James Teh
  • Date: 2011-06-08 07:08:58 UTC
  • mfrom: (40.2.9 trunk)
  • Revision ID: jamie@jantrid.net-20110608070858-mmmg2in7iobmzp28
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
 
1
# Copyright (C) 2005-2008, 2010 by Canonical Ltd
2
2
#   Authors: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
34
34
 
35
35
sample_config=("[DEFAULT]\n"
36
36
               "post_commit_to=demo@example.com\n"
37
 
               "post_commit_sender=Sample <foo@example.com>\n")
 
37
               "post_commit_sender=Sample <foo@example.com>\n"
 
38
               "revision_mail_headers=X-Cheese: to the rescue!\n")
38
39
 
39
40
unconfigured_config=("[DEFAULT]\n"
40
41
                     "email=Robert <foo@example.com>\n")
150
151
        sender = self.get_sender()
151
152
        self.assertEqual('patch-1.diff', sender.diff_filename())
152
153
 
 
154
    def test_headers(self):
 
155
        sender = self.get_sender()
 
156
        self.assertEqual({'X-Cheese': 'to the rescue!'}, sender.extra_headers())
 
157
 
153
158
    def get_sender(self, text=sample_config):
 
159
        config.GlobalConfig.from_string(text, save=True)
154
160
        self.branch = BzrDir.create_branch_convenience('.')
155
161
        tree = self.branch.bzrdir.open_workingtree()
156
162
        tree.commit('foo bar baz\nfuzzy\nwuzzy', rev_id='A',
160
166
            committer="Sample <john@example.com>",
161
167
            )
162
168
        my_config = self.branch.get_config()
163
 
        config_file = StringIO(text)
164
 
        (my_config._get_global_config()._get_parser(config_file))
165
169
        sender = EmailSender(self.branch, 'A', my_config)
166
170
        # This is usually only done after the EmailSender has locked the branch
167
171
        # and repository during send(), however, for testing, we need to do it