~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')
338 by Aaron Bentley
Fixed shelf test case
27
        self.runbzr('shelve -r 1 -m foo --all', retcode=3)
28
        file('foo', 'wb').write('foo')
325.1.2 by Aaron Bentley
Merge shelf v2
29
        self.runbzr('add foo')
30
        self.runbzr('commit -m foo')
338 by Aaron Bentley
Fixed shelf test case
31
        self.runbzr('shelve -r 1 -m foo --all', 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
345 by Aaron Bentley
Added zap command
73
    def test_zap(self):
74
        self.runbzr('init source')
75
        self.runbzr('checkout --lightweight source checkout')
76
        self.runbzr('zap checkout')
355.1.1 by Aaron Bentley
Provided --branch option to for zapping branches
77
        self.assertIs(False, os.path.exists('checkout'))
78
        self.assertIs(True, os.path.exists('source'))
79
80
    def test_zap_branch(self):
81
        self.runbzr('init source')
82
        self.runbzr('checkout --lightweight source checkout')
83
        self.runbzr('zap --branch checkout')
84
        self.assertIs(False, os.path.exists('checkout'))
85
        self.assertIs(False, os.path.exists('source'))
345 by Aaron Bentley
Added zap command
86
352 by Aaron Bentley
Added branches subcommand
87
    def test_branches(self):
88
        self.runbzr('init source')
89
        self.runbzr('init source/subsource')
90
        self.runbzr('checkout --lightweight source checkout')
91
        self.runbzr('init checkout/subcheckout')
92
        self.runbzr('init checkout/.bzr/subcheckout')
93
        out = self.capture('branches')
94
        lines = out.split('\n')
95
        self.assertIs(True, 'source' in lines)
96
        self.assertIs(True, 'source/subsource' in lines)
97
        self.assertIs(True, 'checkout/subcheckout' in lines)
98
        self.assertIs(True, 'checkout' not in lines)
99
        self.assertIs(True, 'checkout/.bzr/subcheckout' not in lines)
345 by Aaron Bentley
Added zap command
100
241 by Aaron Bentley
Added blackbox tests for bzrtools
101
def test_suite():
102
    return makeSuite(TestBzrTools)