~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

Create new post_connect hook for transports

Show diffs side-by-side

added added

removed removed

Lines of Context:
464
464
            server.stop_server()
465
465
 
466
466
 
 
467
class TestHooks(tests.TestCase):
 
468
    """Basic tests for transport hooks"""
 
469
 
 
470
    def _get_connected_transport(self):
 
471
        return transport.ConnectedTransport("bogus:nowhere")
 
472
 
 
473
    def test_transporthooks_initialisation(self):
 
474
        """Check all expected transport hook points are set up"""
 
475
        hookpoint = transport.TransportHooks()
 
476
        self.assertTrue("post_connect" in hookpoint,
 
477
            "post_connect not in %s" % (hookpoint,))
 
478
 
 
479
    def test_post_connect(self):
 
480
        """Ensure the post_connect hook is called when _set_transport is"""
 
481
        calls = []
 
482
        transport.Transport.hooks.install_named_hook("post_connect",
 
483
            calls.append, None)
 
484
        t = self._get_connected_transport()
 
485
        self.assertLength(0, calls)
 
486
        t._set_connection("connection", "auth")
 
487
        self.assertEqual(calls, [t])
 
488
 
 
489
 
467
490
class PathFilteringDecoratorTransportTest(tests.TestCase):
468
491
    """Pathfilter decoration specific tests."""
469
492