~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Robert Collins
  • Date: 2009-03-27 04:10:25 UTC
  • mfrom: (4208 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4216.
  • Revision ID: robertc@robertcollins.net-20090327041025-rgutx4q03xo4pq6l
Resolve NEWS conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for the smart wire/domain protocol.
18
18
 
177
177
        self.assertEqual(expected, request.execute('', 'False'))
178
178
 
179
179
    def test_cloning_metadir_reference(self):
180
 
        """The request works when bzrdir contains a branch reference."""
 
180
        """The request fails when bzrdir contains a branch reference."""
181
181
        backing = self.get_transport()
182
182
        referenced_branch = self.make_branch('referenced')
183
183
        dir = self.make_bzrdir('.')
189
189
        backing.rename('referenced', 'moved')
190
190
        request_class = smart_dir.SmartServerBzrDirRequestCloningMetaDir
191
191
        request = request_class(backing)
192
 
        expected = SuccessfulSmartServerResponse(
193
 
            (local_result.network_name(),
194
 
            local_result.repository_format.network_name(),
195
 
            ('ref', reference_url)))
 
192
        expected = FailedSmartServerResponse(('BranchReference',))
196
193
        self.assertEqual(expected, request.execute('', 'False'))
197
194
 
198
195
 
389
386
        self.assertEqual(SuccessfulSmartServerResponse(('ref', reference_url)),
390
387
            request.execute('reference'))
391
388
 
 
389
    def test_stacked_branch(self):
 
390
        """Opening a stacked branch does not open the stacked-on branch."""
 
391
        trunk = self.make_branch('trunk')
 
392
        feature = self.make_branch('feature', format='1.9')
 
393
        feature.set_stacked_on_url(trunk.base)
 
394
        opened_branches = []
 
395
        Branch.hooks.install_named_hook('open', opened_branches.append, None)
 
396
        backing = self.get_transport()
 
397
        request = smart.bzrdir.SmartServerRequestOpenBranchV2(backing)
 
398
        request.setup_jail()
 
399
        try:
 
400
            response = request.execute('feature')
 
401
        finally:
 
402
            request.teardown_jail()
 
403
        expected_format = feature._format.network_name()
 
404
        self.assertEqual(
 
405
            SuccessfulSmartServerResponse(('branch', expected_format)),
 
406
            response)
 
407
        self.assertLength(1, opened_branches)
 
408
 
392
409
 
393
410
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithMemoryTransport):
394
411
 
914
931
 
915
932
        self.assertEqual(None,
916
933
            request.execute('', 'missing-id'))
917
 
        # Note that it returns a body (of '' bzipped).
 
934
        # Note that it returns a body that is bzipped.
918
935
        self.assertEqual(
919
936
            SuccessfulSmartServerResponse(('ok', ), bz2.compress('')),
920
937
            request.do_body('\n\n0\n'))
921
938
 
 
939
    def test_trivial_include_missing(self):
 
940
        backing = self.get_transport()
 
941
        request = smart.repository.SmartServerRepositoryGetParentMap(backing)
 
942
        tree = self.make_branch_and_memory_tree('.')
 
943
 
 
944
        self.assertEqual(None,
 
945
            request.execute('', 'missing-id', 'include-missing:'))
 
946
        self.assertEqual(
 
947
            SuccessfulSmartServerResponse(('ok', ),
 
948
                bz2.compress('missing:missing-id')),
 
949
            request.do_body('\n\n0\n'))
 
950
 
922
951
 
923
952
class TestSmartServerRepositoryGetRevisionGraph(tests.TestCaseWithMemoryTransport):
924
953