~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')
325.1.2 by Aaron Bentley
Merge shelf v2
27
        self.runbzr('shelve -r 1 -m foo', retcode=3)
28
        file('foo').write('foo')
29
        self.runbzr('add foo')
30
        self.runbzr('commit -m foo')
283 by Aaron Bentley
Handled status code again
31
        self.runbzr('shelve -r 1 -m foo', retcode=0)
241 by Aaron Bentley
Added blackbox tests for bzrtools
32
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
33
    def test_fetch_ghosts(self):
34
        self.runbzr('init')
286.1.1 by Aaron Bentley
Updates to match API changes
35
        self.runbzr('fetch-ghosts .')
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
36
37
    def test_patch(self):
38
        self.runbzr('init')
39
        file('myfile', 'wb').write('hello')
40
        self.runbzr('add')
41
        self.runbzr('commit -m hello')
42
        file('myfile', 'wb').write('goodbye')
271 by Aaron Bentley
Cherry-picked Robert's diff and push fixes
43
        file('mypatch', 'wb').write(self.runbzr('diff', retcode=1, backtick=1))
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
44
        self.runbzr('revert')
45
        assert file('myfile', 'rb').read() == 'hello'
46
        self.runbzr('patch mypatch')
47
        assert file('myfile', 'rb').read() == 'goodbye'
48
308 by Aaron Bentley
got branch-history under test
49
    def test_branch_history(self):
50
        self.runbzr('init')
51
        file('myfile', 'wb').write('hello')
52
        self.runbzr('add')
53
        self.runbzr('commit -m hello')
54
        self.runbzr('branch-history')
55
309 by Aaron Bentley
Fixed graph-ancestry
56
    def test_branch_history(self):
57
        self.runbzr('init')
58
        file('myfile', 'wb').write('hello')
59
        self.runbzr('add')
60
        self.runbzr('commit -m hello')
61
        self.runbzr('graph-ancestry . graph.dot')
62
        self.runbzr('branch . my_branch')
63
        self.runbzr('graph-ancestry . graph.dot --merge-branch my_branch')
242 by Aaron Bentley
Added tests for patch and fetch-ghosts
64
310 by Aaron Bentley
Fixed fetch-ghosts
65
    def test_fetch_ghosts(self):
66
        self.runbzr('init')
67
        file('myfile', 'wb').write('hello')
68
        self.runbzr('add')
69
        self.runbzr('commit -m hello')
70
        self.runbzr('branch . my_branch')
71
        self.runbzr('fetch-ghosts my_branch')
72
241 by Aaron Bentley
Added blackbox tests for bzrtools
73
def test_suite():
74
    return makeSuite(TestBzrTools)