~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Andrew Bennetts
  • Date: 2008-08-07 00:25:38 UTC
  • mfrom: (3612 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3613.
  • Revision ID: andrew.bennetts@canonical.com-20080807002538-mtl1fcgy2fdabha4
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import bzrlib
28
28
from bzrlib import (
 
29
    branchbuilder,
29
30
    bzrdir,
30
31
    errors,
31
32
    memorytree,
547
548
        self.assertEqual(format.repository_format.__class__,
548
549
            tree.branch.repository._format.__class__)
549
550
 
 
551
    def test_make_branch_builder(self):
 
552
        builder = self.make_branch_builder('dir')
 
553
        self.assertIsInstance(builder, branchbuilder.BranchBuilder)
 
554
        # Guard against regression into MemoryTransport leaking
 
555
        # files to disk instead of keeping them in memory.
 
556
        self.failIf(osutils.lexists('dir'))
 
557
 
 
558
    def test_make_branch_builder_with_format(self):
 
559
        # Use a repo layout that doesn't conform to a 'named' layout, to ensure
 
560
        # that the format objects are used.
 
561
        format = bzrdir.BzrDirMetaFormat1()
 
562
        repo_format = weaverepo.RepositoryFormat7()
 
563
        format.repository_format = repo_format
 
564
        builder = self.make_branch_builder('dir', format=format)
 
565
        the_branch = builder.get_branch()
 
566
        # Guard against regression into MemoryTransport leaking
 
567
        # files to disk instead of keeping them in memory.
 
568
        self.failIf(osutils.lexists('dir'))
 
569
        self.assertEqual(format.repository_format.__class__,
 
570
                         the_branch.repository._format.__class__)
 
571
        self.assertEqual(repo_format.get_format_string(),
 
572
                         self.get_transport().get_bytes(
 
573
                            'dir/.bzr/repository/format'))
 
574
 
 
575
    def test_make_branch_builder_with_format_name(self):
 
576
        builder = self.make_branch_builder('dir', format='knit')
 
577
        the_branch = builder.get_branch()
 
578
        # Guard against regression into MemoryTransport leaking
 
579
        # files to disk instead of keeping them in memory.
 
580
        self.failIf(osutils.lexists('dir'))
 
581
        dir_format = bzrdir.format_registry.make_bzrdir('knit')
 
582
        self.assertEqual(dir_format.repository_format.__class__,
 
583
                         the_branch.repository._format.__class__)
 
584
        self.assertEqual('Bazaar-NG Knit Repository Format 1',
 
585
                         self.get_transport().get_bytes(
 
586
                            'dir/.bzr/repository/format'))
 
587
 
550
588
    def test_safety_net(self):
551
589
        """No test should modify the safety .bzr directory.
552
590
 
605
643
        self.assertRaises(AssertionError, self.assertIsDirectory, 'a_file', t)
606
644
        self.assertRaises(AssertionError, self.assertIsDirectory, 'not_here', t)
607
645
 
 
646
    def test_make_branch_builder(self):
 
647
        builder = self.make_branch_builder('dir')
 
648
        rev_id = builder.build_commit()
 
649
        self.failUnlessExists('dir')
 
650
        a_dir = bzrdir.BzrDir.open('dir')
 
651
        self.assertRaises(errors.NoWorkingTree, a_dir.open_workingtree)
 
652
        a_branch = a_dir.open_branch()
 
653
        builder_branch = builder.get_branch()
 
654
        self.assertEqual(a_branch.base, builder_branch.base)
 
655
        self.assertEqual((1, rev_id), builder_branch.last_revision_info())
 
656
        self.assertEqual((1, rev_id), a_branch.last_revision_info())
 
657
 
608
658
 
609
659
class TestTestCaseTransports(TestCaseWithTransport):
610
660