bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
16 |
|
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
17 |
"""Black-box tests for 'brz inventory'."""
|
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
18 |
|
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
19 |
import os |
20 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
21 |
from breezy.tests import TestCaseWithTransport |
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
22 |
|
23 |
||
24 |
class TestInventory(TestCaseWithTransport): |
|
25 |
||
26 |
def setUp(self): |
|
|
6552.1.4
by Vincent Ladeuil
Remaining tests matching setup(self) that can be rewritten with super(). |
27 |
super(TestInventory, self).setUp() |
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
28 |
|
29 |
tree = self.make_branch_and_tree('.') |
|
30 |
self.build_tree(['a', 'b/', 'b/c']) |
|
31 |
||
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
32 |
tree.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id']) |
33 |
tree.commit('init', rev_id=b'one') |
|
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
34 |
self.tree = tree |
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
35 |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
36 |
def assertInventoryEqual(self, expected, args=None, **kwargs): |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
37 |
"""Test that the output of 'brz inventory' is as expected. |
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
38 |
|
39 |
Any arguments supplied will be passed to run_bzr.
|
|
40 |
"""
|
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
41 |
command = 'inventory' |
42 |
if args is not None: |
|
43 |
command += ' ' + args |
|
44 |
out, err = self.run_bzr(command, **kwargs) |
|
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
45 |
self.assertEqual(expected, out) |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
46 |
self.assertEqual('', err) |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
47 |
|
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
48 |
def test_inventory(self): |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
49 |
self.assertInventoryEqual('a\nb\nb/c\n') |
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
50 |
|
|
7358.1.1
by Jelmer Vernooij
Add a --include-root flag to 'brz inventory'. |
51 |
def test_inventory_include_root(self): |
52 |
self.assertInventoryEqual('\na\nb\nb/c\n', '--include-root') |
|
53 |
self.assertInventoryEqual('b\nb/c\n', '--include-root b') |
|
54 |
||
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
55 |
def test_inventory_kind(self): |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
56 |
self.assertInventoryEqual('a\nb/c\n', '--kind file') |
57 |
self.assertInventoryEqual('b\n', '--kind directory') |
|
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
58 |
|
59 |
def test_inventory_show_ids(self): |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
60 |
expected = ''.join(('%-50s %s\n' % (path, file_id)) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
61 |
for path, file_id in |
62 |
[('a', 'a-id'), |
|
63 |
('b', 'b-id'), |
|
64 |
('b/c', 'c-id') |
|
65 |
]
|
|
66 |
)
|
|
|
2027.4.1
by John Arbash Meinel
Factor the 'bzr inventory' tests out of tests_too_much |
67 |
self.assertInventoryEqual(expected, '--show-ids') |
|
2027.4.2
by John Arbash Meinel
Fix bug #3631, allow 'bzr inventory filename' |
68 |
|
69 |
def test_inventory_specific_files(self): |
|
70 |
self.assertInventoryEqual('a\n', 'a') |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
71 |
self.assertInventoryEqual('b\nb/c\n', 'b b/c') |
|
6622.1.29
by Jelmer Vernooij
Fix some more tests. |
72 |
# 'brz inventory' recurses into subdirectories
|
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
73 |
self.assertInventoryEqual('b\nb/c\n', 'b') |
|
2027.4.2
by John Arbash Meinel
Fix bug #3631, allow 'bzr inventory filename' |
74 |
|
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
75 |
def test_inventory_mixed(self): |
|
2027.4.2
by John Arbash Meinel
Fix bug #3631, allow 'bzr inventory filename' |
76 |
"""Test that we get expected results when mixing parameters""" |
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
77 |
a_line = '%-50s %s\n' % ('a', 'a-id') |
78 |
b_line = '%-50s %s\n' % ('b', 'b-id') |
|
79 |
c_line = '%-50s %s\n' % ('b/c', 'c-id') |
|
|
2027.4.2
by John Arbash Meinel
Fix bug #3631, allow 'bzr inventory filename' |
80 |
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
81 |
self.assertInventoryEqual('', '--kind directory a') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
82 |
self.assertInventoryEqual(a_line + c_line, '--kind file --show-ids') |
83 |
self.assertInventoryEqual(c_line, '--kind file --show-ids b b/c') |
|
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
84 |
|
85 |
def test_in_subdir(self): |
|
86 |
os.chdir('b') |
|
87 |
# TODO: jam 20060922 Maybe inventory should return the paths as
|
|
88 |
# relative to '.', rather than relative to root
|
|
89 |
||
90 |
# a plain 'inventory' returns all files
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
91 |
self.assertInventoryEqual('a\nb\nb/c\n') |
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
92 |
# But passing '.' will only return paths underneath here
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
93 |
self.assertInventoryEqual('b\nb/c\n', '.') |
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
94 |
|
95 |
def test_inventory_revision(self): |
|
96 |
self.build_tree(['b/d', 'e']) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
97 |
self.tree.add(['b/d', 'e'], [b'd-id', b'e-id']) |
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
98 |
self.tree.commit('add files') |
99 |
||
100 |
self.tree.rename_one('b/d', 'd') |
|
101 |
self.tree.commit('rename b/d => d') |
|
102 |
||
103 |
# Passing just -r returns the inventory of that revision
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
104 |
self.assertInventoryEqual('a\nb\nb/c\n', '-r 1') |
105 |
self.assertInventoryEqual('a\nb\nb/c\nb/d\ne\n', '-r 2') |
|
|
2027.4.3
by John Arbash Meinel
Change how 'bzr inventory' finds paths |
106 |
|
107 |
# Passing a path will lookup the path in the old and current locations
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
108 |
self.assertInventoryEqual('b/d\n', '-r 2 b/d') |
109 |
self.assertInventoryEqual('b/d\n', '-r 2 d') |
|
|
2027.4.4
by John Arbash Meinel
more tests for 'bzr inventory' including errors and nesting |
110 |
|
111 |
self.tree.rename_one('e', 'b/e') |
|
112 |
self.tree.commit('rename e => b/e') |
|
113 |
||
114 |
# When supplying just a directory paths that are now,
|
|
115 |
# or used to be, in that directory are shown
|
|
|
7027.4.1
by Jelmer Vernooij
Use StringIOWithEncoding on Python3. |
116 |
self.assertInventoryEqual('b\nb/c\nb/d\ne\n', '-r 2 b') |
|
2027.4.4
by John Arbash Meinel
more tests for 'bzr inventory' including errors and nesting |
117 |
|
118 |
def test_missing_file(self): |
|
119 |
self.run_bzr_error([r'Path\(s\) are not versioned: no-such-file'], |
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
120 |
'inventory no-such-file') |