~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_branch.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-26 05:11:52 UTC
  • mto: This revision was merged to the branch mainline in revision 2376.
  • Revision ID: andrew.bennetts@canonical.com-20070326051152-1q3ntmsj2b4dv9k5
Remote Branch.get_transaction and friends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
566
566
        self.assertEqual(['lw', 'ul'], branch._calls)
567
567
 
568
568
 
569
 
class TestBranchTransaction(TestCaseWithBranch):
570
 
 
571
 
    def setUp(self):
572
 
        super(TestBranchTransaction, self).setUp()
573
 
        self.branch = None
574
 
        
575
 
    def test_default_get_transaction(self):
576
 
        """branch.get_transaction on a new branch should give a PassThrough."""
577
 
        self.failUnless(isinstance(self.get_branch().get_transaction(),
578
 
                                   transactions.PassThroughTransaction))
579
 
 
580
 
    def test__set_new_transaction(self):
581
 
        self.get_branch()._set_transaction(transactions.ReadOnlyTransaction())
582
 
 
583
 
    def test__set_over_existing_transaction_raises(self):
584
 
        self.get_branch()._set_transaction(transactions.ReadOnlyTransaction())
585
 
        self.assertRaises(errors.LockError,
586
 
                          self.get_branch()._set_transaction,
587
 
                          transactions.ReadOnlyTransaction())
588
 
 
589
 
    def test_finish_no_transaction_raises(self):
590
 
        self.assertRaises(errors.LockError, self.get_branch()._finish_transaction)
591
 
 
592
 
    def test_finish_readonly_transaction_works(self):
593
 
        self.get_branch()._set_transaction(transactions.ReadOnlyTransaction())
594
 
        self.get_branch()._finish_transaction()
595
 
        self.assertEqual(None, self.get_branch().control_files._transaction)
596
 
 
597
 
    def test_unlock_calls_finish(self):
598
 
        self.get_branch().lock_read()
599
 
        transaction = InstrumentedTransaction()
600
 
        self.get_branch().control_files._transaction = transaction
601
 
        self.get_branch().unlock()
602
 
        self.assertEqual(['finish'], transaction.calls)
603
 
 
604
 
    def test_lock_read_acquires_ro_transaction(self):
605
 
        self.get_branch().lock_read()
606
 
        self.failUnless(isinstance(self.get_branch().get_transaction(),
607
 
                                   transactions.ReadOnlyTransaction))
608
 
        self.get_branch().unlock()
609
 
        
610
 
    def test_lock_write_acquires_write_transaction(self):
611
 
        self.get_branch().lock_write()
612
 
        # cannot use get_transaction as its magic
613
 
        self.failUnless(isinstance(self.get_branch().control_files._transaction,
614
 
                                   transactions.WriteTransaction))
615
 
        self.get_branch().unlock()
616
 
 
617
 
 
618
569
class TestRevisionHistoryCaching(TestCaseWithBranch):
619
570
    """Tests for the caching of branch revision_history.
620
571