~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Patch Queue Manager
  • Date: 2014-10-06 16:32:42 UTC
  • mfrom: (6597.2.4 split-diff-tests)
  • Revision ID: pqm@pqm.ubuntu.com-20141006163242-c2cll01cwc24grkk
(vila) Split some tests to be able to get finer grained failures (Vincent
 Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2011 Canonical Ltd
 
1
# Copyright (C) 2006-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
30
30
from bzrlib import (
31
31
    bencode,
32
32
    branch as _mod_branch,
33
 
    bzrdir,
 
33
    controldir,
34
34
    errors,
35
35
    gpg,
36
36
    inventory_delta,
82
82
 
83
83
    def setUp(self):
84
84
        self.vfs_transport_factory = memory.MemoryServer
85
 
        tests.TestCaseWithTransport.setUp(self)
 
85
        super(TestCaseWithChrootedTransport, self).setUp()
86
86
        self._chroot_server = None
87
87
 
88
88
    def get_transport(self, relpath=None):
121
121
        stream = [('text', [versionedfile.FulltextContentFactory(('k1',), None,
122
122
            None, 'foo')]),('text', [
123
123
            versionedfile.FulltextContentFactory(('k2',), None, None, 'bar')])]
124
 
        fmt = bzrdir.format_registry.get('pack-0.92')().repository_format
 
124
        fmt = controldir.format_registry.get('pack-0.92')().repository_format
125
125
        bytes = smart_repo._stream_to_byte_stream(stream, fmt)
126
126
        streams = []
127
127
        # Iterate the resulting iterable; checking that we get only one stream
333
333
        self.make_bzrdir('.')
334
334
        request_class = smart_dir.SmartServerRequestCreateRepository
335
335
        request = request_class(backing)
336
 
        reference_bzrdir_format = bzrdir.format_registry.get('pack-0.92')()
 
336
        reference_bzrdir_format = controldir.format_registry.get('pack-0.92')()
337
337
        reference_format = reference_bzrdir_format.repository_format
338
338
        network_name = reference_format.network_name()
339
339
        expected = smart_req.SuccessfulSmartServerResponse(
419
419
        backing = self.get_transport()
420
420
        request = self._request_class(backing)
421
421
        result = self._make_repository_and_result(
422
 
            format='dirstate-with-subtree')
 
422
            format='development-subtree')
423
423
        # check the test will be valid
424
424
        self.assertEqual('yes', result.args[2])
425
425
        self.assertEqual('yes', result.args[3])
430
430
        backing = self.get_transport()
431
431
        request = self._request_class(backing)
432
432
        result = self._make_repository_and_result(
433
 
            format='dirstate-with-subtree')
 
433
            format='development-subtree')
434
434
        # check the test will be valid
435
 
        self.assertEqual('no', result.args[4])
 
435
        self.assertEqual('yes', result.args[4])
436
436
        self.assertEqual(result, request.execute(''))
437
437
 
438
438
 
493
493
        request = smart_dir.SmartServerRequestInitializeBzrDir(backing)
494
494
        self.assertEqual(smart_req.SmartServerResponse(('ok', )),
495
495
            request.execute(''))
496
 
        made_dir = bzrdir.BzrDir.open_from_transport(backing)
 
496
        made_dir = controldir.ControlDir.open_from_transport(backing)
497
497
        # no branch, tree or repository is expected with the current
498
498
        # default formart.
499
499
        self.assertRaises(errors.NoWorkingTree, made_dir.open_workingtree)
533
533
                                           'False', '', '', '')),
534
534
            request.execute(name, '', 'True', 'False', 'False', '', '', '', '',
535
535
                            'False'))
536
 
        made_dir = bzrdir.BzrDir.open_from_transport(backing)
 
536
        made_dir = controldir.ControlDir.open_from_transport(backing)
537
537
        # no branch, tree or repository is expected with the current
538
538
        # default format.
539
539
        self.assertRaises(errors.NoWorkingTree, made_dir.open_workingtree)
1058
1058
    """Base test case for verbs that implement set_last_revision."""
1059
1059
 
1060
1060
    def setUp(self):
1061
 
        tests.TestCaseWithMemoryTransport.setUp(self)
 
1061
        super(SetLastRevisionTestBase, self).setUp()
1062
1062
        backing_transport = self.get_transport()
1063
1063
        self.request = self.request_class(backing_transport)
1064
1064
        self.tree = self.make_branch_and_memory_tree('.')
1323
1323
        finally:
1324
1324
            branch.unlock()
1325
1325
        self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), response)
 
1326
        # Refresh branch as SetParentLocation modified it
 
1327
        branch = branch.bzrdir.open_branch()
1326
1328
        self.assertEqual(None, branch.get_parent())
1327
1329
 
1328
1330
    def test_set_parent_something(self):
1332
1334
        branch_token, repo_token = self.get_lock_tokens(branch)
1333
1335
        try:
1334
1336
            response = request.execute('base', branch_token, repo_token,
1335
 
            'http://bar/')
 
1337
                                       'http://bar/')
1336
1338
        finally:
1337
1339
            branch.unlock()
1338
1340
        self.assertEqual(smart_req.SuccessfulSmartServerResponse(()), response)
1339
 
        self.assertEqual('http://bar/', branch.get_parent())
 
1341
        refreshed = _mod_branch.Branch.open(branch.base)
 
1342
        self.assertEqual('http://bar/', refreshed.get_parent())
1340
1343
 
1341
1344
 
1342
1345
class TestSmartServerBranchRequestGetTagsBytes(
1370
1373
 
1371
1374
class TestSmartServerBranchRequestLockWrite(TestLockedBranch):
1372
1375
 
1373
 
    def setUp(self):
1374
 
        tests.TestCaseWithMemoryTransport.setUp(self)
1375
 
 
1376
1376
    def test_lock_write_on_unlocked_branch(self):
1377
1377
        backing = self.get_transport()
1378
1378
        request = smart_branch.SmartServerBranchRequestLockWrite(backing)
1478
1478
 
1479
1479
class TestSmartServerBranchRequestGetPhysicalLockStatus(TestLockedBranch):
1480
1480
 
1481
 
    def setUp(self):
1482
 
        tests.TestCaseWithMemoryTransport.setUp(self)
1483
 
 
1484
1481
    def test_true(self):
1485
1482
        backing = self.get_transport()
1486
1483
        request = smart_branch.SmartServerBranchRequestGetPhysicalLockStatus(
1506
1503
 
1507
1504
class TestSmartServerBranchRequestUnlock(TestLockedBranch):
1508
1505
 
1509
 
    def setUp(self):
1510
 
        tests.TestCaseWithMemoryTransport.setUp(self)
1511
 
 
1512
1506
    def test_unlock_on_locked_branch_and_repo(self):
1513
1507
        backing = self.get_transport()
1514
1508
        request = smart_branch.SmartServerBranchRequestUnlock(backing)
2198
2192
 
2199
2193
class TestSmartServerRepositoryUnlock(tests.TestCaseWithMemoryTransport):
2200
2194
 
2201
 
    def setUp(self):
2202
 
        tests.TestCaseWithMemoryTransport.setUp(self)
2203
 
 
2204
2195
    def test_unlock_on_locked_repo(self):
2205
2196
        backing = self.get_transport()
2206
2197
        request = smart_repo.SmartServerRepositoryUnlock(backing)
2666
2657
class TestSmartServerRepositoryGetInventories(tests.TestCaseWithTransport):
2667
2658
 
2668
2659
    def _get_serialized_inventory_delta(self, repository, base_revid, revid):
2669
 
        base_inv = repository.revision_tree(base_revid).inventory
2670
 
        inv = repository.revision_tree(revid).inventory
 
2660
        base_inv = repository.revision_tree(base_revid).root_inventory
 
2661
        inv = repository.revision_tree(revid).root_inventory
2671
2662
        inv_delta = inv._make_delta(base_inv)
2672
2663
        serializer = inventory_delta.InventoryDeltaSerializer(True, False)
2673
2664
        return "".join(serializer.delta_to_lines(base_revid, revid, inv_delta))
2688
2679
            versionedfile.FulltextContentFactory('somerev', None, None,
2689
2680
                self._get_serialized_inventory_delta(
2690
2681
                    t.branch.repository, 'null:', 'somerev'))])]
2691
 
        fmt = bzrdir.format_registry.get('2a')().repository_format
 
2682
        fmt = controldir.format_registry.get('2a')().repository_format
2692
2683
        self.assertEquals(
2693
2684
            "".join(response.body_stream),
2694
2685
            "".join(smart_repo._stream_to_byte_stream(stream, fmt)))