~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_link_tree.py

  • Committer: Aaron Bentley
  • Date: 2008-03-01 04:27:02 UTC
  • Revision ID: aaron@aaronbentley.com-20080301042702-h3foyp8n9k68y3pv
Add link-tree command

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from bzrlib.plugins.bzrtools.link_tree import link_tree
23
23
 
24
 
class TestLinkTree(TestCaseWithTransport):
 
24
 
 
25
class TestLinkTreeBase(object):
25
26
 
26
27
    def setUp(self):
27
28
        TestCaseWithTransport.setUp(self)
39
40
        child_stat = os.lstat(self.child_tree.abspath('foo'))
40
41
        return parent_stat.st_ino == child_stat.st_ino
41
42
 
 
43
 
 
44
class TestLinkTree(TestLinkTreeBase, TestCaseWithTransport):
 
45
 
42
46
    def test_link_fails_if_modified(self):
43
47
        """If the file to be linked has modified text, don't link."""
44
48
        self.build_tree_contents([('child/foo', 'baz')])
61
65
        """If the file to be linked is unmodified, link"""
62
66
        link_tree(self.child_tree, self.parent_tree)
63
67
        self.assertTrue(self.hardlinked())
 
68
 
 
69
 
 
70
class TestLinkTreeCommand(TestLinkTreeBase, TestCaseWithTransport):
 
71
 
 
72
    def test_link_tree(self):
 
73
        """Ensure the command works as intended"""
 
74
        os.chdir('child')
 
75
        self.parent_tree.unlock()
 
76
        self.run_bzr('link-tree ../parent')
 
77
        self.assertTrue(self.hardlinked())
 
78
        # want teh addCleanup to work properly
 
79
        self.parent_tree.lock_write()