Пример #1
0
 def test_locked(self):
     # break_lock when locked should unlock the branch and repo
     self.branch.lock_write()
     ui.ui_factory = ui.CannedInputUIFactory([True, True])
     try:
         self.unused_branch.break_lock()
     except NotImplementedError:
         # branch does not support break_lock
         self.branch.unlock()
         return
     self.assertRaises(errors.LockBroken, self.branch.unlock)
Пример #2
0
    def test_smtp_password_from_user(self):
        user = '******'
        password = '******'
        factory = WideOpenSMTPFactory()
        conn = self.get_connection(b'[DEFAULT]\nsmtp_username=%s\n' %
                                   user.encode('ascii'),
                                   smtp_factory=factory)
        self.assertIs(None, conn._smtp_password)

        ui.ui_factory = ui.CannedInputUIFactory([password])
        conn._connect()
        self.assertEqual(password, conn._smtp_password)
Пример #3
0
 def test_locked(self):
     # break_lock when locked should
     self.workingtree.lock_write()
     ui.ui_factory = ui.CannedInputUIFactory([True, True, True])
     try:
         self.unused_workingtree.break_lock()
     except (NotImplementedError, errors.LockActive):
         # workingtree does not support break_lock,
         # or does not support breaking a lock held by an alive
         # object/process.
         self.workingtree.unlock()
         return
     self.assertRaises(errors.LockBroken, self.workingtree.unlock)
Пример #4
0
 def test_unlocked_repo_locked(self):
     # break lock on the workingtree should try on the branch even
     # if the workingtree isn't locked - and the easiest way
     # to see if that happened is to lock the repo.
     self.workingtree.branch.repository.lock_write()
     ui.ui_factory = ui.CannedInputUIFactory([True])
     try:
         self.unused_workingtree.break_lock()
     except NotImplementedError:
         # workingtree does not support break_lock
         self.workingtree.branch.repository.unlock()
         return
     if ui.ui_factory.responses == [True]:
         raise TestNotApplicable("repository does not physically lock.")
     self.assertRaises(errors.LockBroken,
                       self.workingtree.branch.repository.unlock)
Пример #5
0
 def test_break_lock(self):
     base = self.make_repository('base')
     repo = self.make_referring('referring', base)
     unused_repo = repo.controldir.open_repository()
     base.lock_write()
     self.addCleanup(base.unlock)
     # break_lock when locked should
     repo.lock_write()
     self.assertEqual(repo.get_physical_lock_status(),
                      unused_repo.get_physical_lock_status())
     if not unused_repo.get_physical_lock_status():
         # 'lock_write' has not taken a physical mutex out.
         repo.unlock()
         return
     ui.ui_factory = ui.CannedInputUIFactory([True])
     unused_repo.break_lock()
     self.assertRaises(errors.LockBroken, repo.unlock)
Пример #6
0
 def test_unlocks_master_branch(self):
     # break_lock when the master branch is locked should offer to
     # unlock it.
     master = self.make_branch('master')
     try:
         self.branch.bind(master)
     except _mod_branch.BindingUnsupported:
         # this branch does not support binding.
         return
     master.lock_write()
     ui.ui_factory = ui.CannedInputUIFactory([True, True])
     try:
         fresh = _mod_branch.Branch.open(self.unused_branch.base)
         fresh.break_lock()
     except NotImplementedError:
         # branch does not support break_lock
         master.unlock()
         return
     self.assertRaises(errors.LockBroken, master.unlock)
     # can we lock it now ?
     master.lock_write()
     master.unlock()
Пример #7
0
 def test_unlocked_repo_locked(self):
     # break lock on the branch should try on the repository even
     # if the branch isn't locked
     token = self.branch.repository.lock_write().repository_token
     if token is None:
         self.branch.repository.unlock()
         raise tests.TestNotApplicable(
             'Repository does not use physical locks.')
     self.branch.repository.leave_lock_in_place()
     self.branch.repository.unlock()
     other_instance = self.branch.repository.controldir.open_repository()
     if not other_instance.get_physical_lock_status():
         raise tests.TestNotApplicable(
             'Repository does not lock persistently.')
     ui.ui_factory = ui.CannedInputUIFactory([True])
     try:
         self.unused_branch.break_lock()
     except NotImplementedError:
         # branch does not support break_lock
         self.branch.repository.unlock()
         return
     self.assertRaises(errors.LockBroken, self.branch.repository.unlock)
Пример #8
0
 def setUp(self):
     super(TestBreakLock, self).setUp()
     self.unused_repo = self.make_repository('.')
     self.repo = self.unused_repo.controldir.open_repository()
     ui.ui_factory = ui.CannedInputUIFactory([True])