~abentley/bzrtools/bzrtools.dev

291 by Aaron Bentley
Adjusted to selftest -> tests change
1
from bzrlib.tests.blackbox import ExternalBase
241 by Aaron Bentley
Added blackbox tests for bzrtools
2
from unittest import makeSuite
3
import os.path
4
class TestBzrTools(ExternalBase):
5
    @staticmethod
6
    def touch(filename):
7
        file(filename, 'wb').write('')
8
9
    def test_clean_tree(self):
10
        self.runbzr('init')
11
        self.touch('name')
12
        self.touch('name~')
13
        assert os.path.lexists('name~')
14
        self.touch('name.pyc')
15
        self.runbzr('clean-tree')
16
        assert os.path.lexists('name~')
17
        assert not os.path.lexists('name')
265 by Aaron Bentley
Fixed spelling of detritus
18
        self.runbzr('clean-tree --detritus')
241 by Aaron Bentley
Added blackbox tests for bzrtools
19
        assert not os.path.lexists('name~')
20
        assert os.path.lexists('name.pyc')
21
        self.runbzr('clean-tree --ignored')
22
        assert not os.path.lexists('name.pyc')
23
24
    def test_shelve(self):
25
        self.runbzr('init')
26
        self.runbzr('commit -m uc --unchanged')
283 by Aaron Bentley
Handled status code again
27
        self.runbzr('shelve -r 1 -m foo', retcode=0)
241 by Aaron Bentley
Added blackbox tests for bzrtools
28
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
29
    def test_fetch_ghosts(self):
30
        self.runbzr('init')
286.1.1 by Aaron Bentley
Updates to match API changes
31
        self.runbzr('fetch-ghosts .')
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
32
33
    def test_patch(self):
34
        self.runbzr('init')
35
        file('myfile', 'wb').write('hello')
36
        self.runbzr('add')
37
        self.runbzr('commit -m hello')
38
        file('myfile', 'wb').write('goodbye')
271 by Aaron Bentley
Cherry-picked Robert's diff and push fixes
39
        file('mypatch', 'wb').write(self.runbzr('diff', retcode=1, backtick=1))
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
40
        self.runbzr('revert')
41
        assert file('myfile', 'rb').read() == 'hello'
42
        self.runbzr('patch mypatch')
43
        assert file('myfile', 'rb').read() == 'goodbye'
44
308 by Aaron Bentley
got branch-history under test
45
    def test_branch_history(self):
46
        self.runbzr('init')
47
        file('myfile', 'wb').write('hello')
48
        self.runbzr('add')
49
        self.runbzr('commit -m hello')
50
        self.runbzr('branch-history')
51
309 by Aaron Bentley
Fixed graph-ancestry
52
    def test_branch_history(self):
53
        self.runbzr('init')
54
        file('myfile', 'wb').write('hello')
55
        self.runbzr('add')
56
        self.runbzr('commit -m hello')
57
        self.runbzr('graph-ancestry . graph.dot')
58
        self.runbzr('branch . my_branch')
59
        self.runbzr('graph-ancestry . graph.dot --merge-branch my_branch')
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
60
310 by Aaron Bentley
Fixed fetch-ghosts
61
    def test_fetch_ghosts(self):
62
        self.runbzr('init')
63
        file('myfile', 'wb').write('hello')
64
        self.runbzr('add')
65
        self.runbzr('commit -m hello')
66
        self.runbzr('branch . my_branch')
67
        self.runbzr('fetch-ghosts my_branch')
68
241 by Aaron Bentley
Added blackbox tests for bzrtools
69
def test_suite():
70
    return makeSuite(TestBzrTools)