~abentley/bzrtools/bzrtools.dev

709 by Aaron Bentley
Add test_fetch_ghosts
1
from bzrlib.plugins.bzrtools.fetch_ghosts import GhostFetcher
2
from bzrlib.tests import TestCaseWithTransport
3
4
5
class TestFetchGhosts(TestCaseWithTransport):
6
7
    def prepare_with_ghosts(self):
8
        tree = self.make_branch_and_tree('.')
9
        tree.commit('rev1', rev_id='rev1-id')
10
        tree.set_parent_ids(['rev1-id', 'ghost-id'])
11
        tree.commit('rev2')
12
        return tree
13
14
    def test_fetch_ghosts_failure(self):
15
        tree = self.prepare_with_ghosts()
16
        branch = self.make_branch('branch')
17
        GhostFetcher(tree.branch, branch).run()
18
        self.assertFalse(tree.branch.repository.has_revision('ghost-id'))
19
20
    def test_fetch_ghosts_success(self):
21
        tree = self.prepare_with_ghosts()
22
        ghost_tree = self.make_branch_and_tree('ghost_tree')
23
        ghost_tree.commit('ghost', rev_id='ghost-id')
24
        GhostFetcher(tree.branch, ghost_tree.branch).run()
25
        self.assertTrue(tree.branch.repository.has_revision('ghost-id'))