~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_directive.py

  • Committer: Aaron Bentley
  • Date: 2009-05-11 18:35:20 UTC
  • mto: This revision was merged to the branch mainline in revision 4351.
  • Revision ID: aaron@aaronbentley.com-20090511183520-xtvepoauy7zjtb7x
Move hook to MergeDirective, implement MergeDirective.compose_merge_request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    mail_client,
23
23
    merge_directive,
24
24
    tests,
25
 
    trace,
26
25
    )
27
26
 
28
27
 
727
726
 
728
727
class TestBodyHook(tests.TestCaseWithTransport):
729
728
 
730
 
    def compose_with_hooks(self, test_hooks, supports_body=True):
 
729
    def compose_with_hooks(self, test_hooks):
731
730
        client = HookMailClient({})
732
 
        client.supports_body = supports_body
733
731
        for test_hook in test_hooks:
734
732
            merge_directive.MergeDirective.hooks.install_named_hook(
735
733
                'merge_request_body', test_hook, 'test')
744
742
            None, tree.branch)
745
743
        return client, directive
746
744
 
747
 
    def test_no_supports_body(self):
748
 
        test_hook = TestHook('foo')
749
 
        old_warn = trace.warning
750
 
        warnings = []
751
 
        def warn(*args):
752
 
            warnings.append(args)
753
 
        trace.warning = warn
754
 
        try:
755
 
            client, directive = self.compose_with_hooks([test_hook],
756
 
                supports_body=False)
757
 
        finally:
758
 
            trace.warning = old_warn
759
 
        self.assertEqual(0, len(test_hook.calls))
760
 
        self.assertEqual(('Cannot run merge_request_body hooks because mail'
761
 
                          ' client %s does not support message bodies.',
762
 
                          'HookMailClient'), warnings[0])
763
 
 
764
745
    def test_body_hook(self):
765
746
        test_hook = TestHook('foo')
766
747
        client, directive = self.compose_with_hooks([test_hook])