Rev 4012: Add ratchet style blackbox effort tests for push over bzr+ssh. (Andrew Bennetts, Robert Collins) in http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips

Robert Collins robertc at robertcollins.net
Wed Feb 18 00:02:48 GMT 2009


At http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips

------------------------------------------------------------
revno: 4012
revision-id: robertc at robertcollins.net-20090218000242-8lj7ewn31dmwh5q3
parent: pqm at pqm.ubuntu.com-20090216172448-vj35mjoe463c3bk2
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Wed 2009-02-18 11:02:42 +1100
message:
  Add ratchet style blackbox effort tests for push over bzr+ssh. (Andrew Bennetts, Robert Collins)
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-01-02 01:58:48 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-02-18 00:02:42 +0000
@@ -29,6 +29,7 @@
 from bzrlib.bzrdir import BzrDirMetaFormat1
 from bzrlib.osutils import abspath
 from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
+from bzrlib.smart import client, server
 from bzrlib.tests.blackbox import ExternalBase
 from bzrlib.tests.http_server import HttpServer
 from bzrlib.transport.memory import MemoryServer, MemoryTransport
@@ -179,6 +180,40 @@
             % tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
         self.failUnlessExists('to-two')
 
+    def _reset_smart_call_log(self):
+        self.hpss_calls = []
+
+    def _setup_smart_call_log(self):
+        self.transport_server = server.SmartTCPServer_for_testing
+        self.hpss_calls = []
+        def capture_hpss_call(params):
+            self.hpss_calls.append(params.method)
+        client._SmartClient.hooks.install_named_hook(
+            'call', capture_hpss_call, None)
+
+    def test_push_smart_non_stacked_streaming_acceptance(self):
+        self._setup_smart_call_log()
+        t = self.make_branch_and_tree('from')
+        t.commit(allow_pointless=True, message='first commit')
+        self._reset_smart_call_log()
+        self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
+        rpc_count = len(self.hpss_calls)
+        self.assertEqual(99, rpc_count)
+
+    def test_push_smart_stacked_streaming_acceptance(self):
+        self._setup_smart_call_log()
+        parent = self.make_branch_and_tree('parent', format='1.9')
+        parent.commit(message='first commit')
+        local = parent.bzrdir.sprout('local').open_workingtree()
+        local.commit(message='local commit')
+        self._reset_smart_call_log()
+        self.run_bzr(['push', '--stacked', '--stacked-on', '../parent',
+            self.get_url('public')], working_dir='local')
+        rpc_count = len(self.hpss_calls)
+        self.assertEqual(123, rpc_count)
+        remote = Branch.open('public')
+        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
+
     def create_simple_tree(self):
         tree = self.make_branch_and_tree('tree')
         self.build_tree(['tree/a'])




More information about the bazaar-commits mailing list