bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
1 |
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
|
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
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
16 |
|
17 |
"""Tests for different inventory implementations"""
|
|
18 |
||
19 |
# NOTE: Don't import Inventory here, to make sure that we don't accidentally
|
|
20 |
# hardcode that when we should be using self.make_inventory
|
|
21 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
22 |
from breezy import ( |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
23 |
errors, |
24 |
osutils, |
|
25 |
)
|
|
26 |
from breezy.bzr import ( |
|
27 |
inventory, |
|
28 |
)
|
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
29 |
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
30 |
from breezy.bzr.inventory import ( |
31 |
InventoryDirectory, |
|
32 |
InventoryEntry, |
|
33 |
InventoryFile, |
|
34 |
InventoryLink, |
|
35 |
TreeReference, |
|
36 |
)
|
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
37 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
38 |
from breezy.tests.per_inventory import TestCaseWithInventory |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
39 |
|
40 |
||
41 |
class TestInventory(TestCaseWithInventory): |
|
42 |
||
43 |
def make_init_inventory(self): |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
44 |
inv = inventory.Inventory(b'tree-root') |
45 |
inv.revision = b'initial-rev' |
|
46 |
inv.root.revision = b'initial-rev' |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
47 |
return self.inv_to_test_inv(inv) |
48 |
||
|
7045.1.19
by Jelmer Vernooij
Fix remaining inventory tests. |
49 |
def make_file(self, file_id, name, parent_id, content=b'content\n', |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
50 |
revision=b'new-test-rev'): |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
51 |
ie = InventoryFile(file_id, name, parent_id) |
52 |
ie.text_sha1 = osutils.sha_string(content) |
|
53 |
ie.text_size = len(content) |
|
54 |
ie.revision = revision |
|
55 |
return ie |
|
56 |
||
57 |
def make_link(self, file_id, name, parent_id, target='link-target\n'): |
|
58 |
ie = InventoryLink(file_id, name, parent_id) |
|
59 |
ie.symlink_target = target |
|
60 |
return ie |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
61 |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
62 |
def prepare_inv_with_nested_dirs(self): |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
63 |
inv = inventory.Inventory(b'tree-root') |
|
7045.1.19
by Jelmer Vernooij
Fix remaining inventory tests. |
64 |
inv.root.revision = b'revision' |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
65 |
for args in [('src', 'directory', b'src-id'), |
66 |
('doc', 'directory', b'doc-id'), |
|
67 |
('src/hello.c', 'file', b'hello-id'), |
|
68 |
('src/bye.c', 'file', b'bye-id'), |
|
69 |
('zz', 'file', b'zz-id'), |
|
70 |
('src/sub/', 'directory', b'sub-id'), |
|
71 |
('src/zz.c', 'file', b'zzc-id'), |
|
72 |
('src/sub/a', 'file', b'a-id'), |
|
73 |
('Makefile', 'file', b'makefile-id')]: |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
74 |
ie = inv.add_path(*args) |
|
7045.1.19
by Jelmer Vernooij
Fix remaining inventory tests. |
75 |
ie.revision = b'revision' |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
76 |
if args[1] == 'file': |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
77 |
ie.text_sha1 = osutils.sha_string(b'content\n') |
78 |
ie.text_size = len(b'content\n') |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
79 |
return self.inv_to_test_inv(inv) |
80 |
||
81 |
||
82 |
class TestInventoryCreateByApplyDelta(TestInventory): |
|
|
4505.5.8
by Robert Collins
Fix fallout from the delta checking work, don't error on deltas containing the root inventory item in CHK delta application, and clean up Inventory docs. |
83 |
"""A subset of the inventory delta application tests. |
84 |
||
85 |
See test_inv which has comprehensive delta application tests for
|
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
86 |
inventories, dirstate, and repository based inventories.
|
|
4505.5.8
by Robert Collins
Fix fallout from the delta checking work, don't error on deltas containing the root inventory item in CHK delta application, and clean up Inventory docs. |
87 |
"""
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
88 |
def test_add(self): |
89 |
inv = self.make_init_inventory() |
|
90 |
inv = inv.create_by_apply_delta([ |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
91 |
(None, "a", b"a-id", self.make_file(b'a-id', 'a', b'tree-root')), |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
92 |
], b'new-test-rev') |
93 |
self.assertEqual('a', inv.id2path(b'a-id')) |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
94 |
|
95 |
def test_delete(self): |
|
96 |
inv = self.make_init_inventory() |
|
97 |
inv = inv.create_by_apply_delta([ |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
98 |
(None, "a", b"a-id", self.make_file(b'a-id', 'a', b'tree-root')), |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
99 |
], b'new-rev-1') |
100 |
self.assertEqual('a', inv.id2path(b'a-id')) |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
101 |
inv = inv.create_by_apply_delta([ |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
102 |
("a", None, b"a-id", None), |
103 |
], b'new-rev-2') |
|
104 |
self.assertRaises(errors.NoSuchId, inv.id2path, b'a-id') |
|
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
105 |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
106 |
def test_rename(self): |
107 |
inv = self.make_init_inventory() |
|
108 |
inv = inv.create_by_apply_delta([ |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
109 |
(None, "a", b"a-id", self.make_file(b'a-id', 'a', b'tree-root')), |
110 |
], b'new-rev-1') |
|
111 |
self.assertEqual('a', inv.id2path(b'a-id')) |
|
|
6855.4.10
by Jelmer Vernooij
merge trunk |
112 |
a_ie = inv.get_entry(b'a-id') |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
113 |
b_ie = self.make_file(a_ie.file_id, "b", a_ie.parent_id) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
114 |
inv = inv.create_by_apply_delta([("a", "b", b"a-id", b_ie)], b'new-rev-2') |
115 |
self.assertEqual("b", inv.id2path(b'a-id')) |
|
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
116 |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
117 |
def test_illegal(self): |
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
118 |
# A file-id cannot appear in a delta more than once
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
119 |
inv = self.make_init_inventory() |
120 |
self.assertRaises(errors.InconsistentDelta, inv.create_by_apply_delta, [ |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
121 |
(None, "a", b"id-1", self.make_file(b'id-1', 'a', b'tree-root')), |
122 |
(None, "b", b"id-1", self.make_file(b'id-1', 'b', b'tree-root')), |
|
123 |
], b'new-rev-1') |
|
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
124 |
|
125 |
||
126 |
class TestInventoryReads(TestInventory): |
|
127 |
||
128 |
def test_is_root(self): |
|
129 |
"""Ensure our root-checking code is accurate.""" |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
130 |
inv = self.make_init_inventory() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
131 |
self.assertTrue(inv.is_root(b'tree-root')) |
132 |
self.assertFalse(inv.is_root(b'booga')) |
|
|
7045.1.17
by Jelmer Vernooij
Fix another test. |
133 |
ie = inv.get_entry(b'tree-root').copy() |
134 |
ie.file_id = b'booga' |
|
135 |
inv = inv.create_by_apply_delta([("", None, b"tree-root", None), |
|
136 |
(None, "", b"booga", ie)], b'new-rev-2') |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
137 |
self.assertFalse(inv.is_root(b'TREE_ROOT')) |
138 |
self.assertTrue(inv.is_root(b'booga')) |
|
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
139 |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
140 |
def test_ids(self): |
141 |
"""Test detection of files within selected directories.""" |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
142 |
inv = inventory.Inventory(b'TREE_ROOT') |
|
7045.1.19
by Jelmer Vernooij
Fix remaining inventory tests. |
143 |
inv.root.revision = b'revision' |
|
6973.6.1
by Jelmer Vernooij
More bees. |
144 |
for args in [('src', 'directory', b'src-id'), |
145 |
('doc', 'directory', b'doc-id'), |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
146 |
('src/hello.c', 'file'), |
|
6973.6.1
by Jelmer Vernooij
More bees. |
147 |
('src/bye.c', 'file', b'bye-id'), |
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
148 |
('Makefile', 'file')]: |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
149 |
ie = inv.add_path(*args) |
|
7045.1.19
by Jelmer Vernooij
Fix remaining inventory tests. |
150 |
ie.revision = b'revision' |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
151 |
if args[1] == 'file': |
|
6973.6.1
by Jelmer Vernooij
More bees. |
152 |
ie.text_sha1 = osutils.sha_string(b'content\n') |
153 |
ie.text_size = len(b'content\n') |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
154 |
inv = self.inv_to_test_inv(inv) |
|
6973.6.1
by Jelmer Vernooij
More bees. |
155 |
self.assertEqual(inv.path2id('src'), b'src-id') |
156 |
self.assertEqual(inv.path2id('src/bye.c'), b'bye-id') |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
157 |
|
158 |
def test_non_directory_children(self): |
|
159 |
"""Test path2id when a parent directory has no children""" |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
160 |
inv = inventory.Inventory(b'tree-root') |
161 |
inv.add(self.make_file(b'file-id', 'file', b'tree-root')) |
|
162 |
inv.add(self.make_link(b'link-id', 'link', b'tree-root')) |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
163 |
self.assertIs(None, inv.path2id('file/subfile')) |
164 |
self.assertIs(None, inv.path2id('link/subfile')) |
|
165 |
||
166 |
def test_iter_entries(self): |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
167 |
inv = self.prepare_inv_with_nested_dirs() |
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
168 |
|
169 |
# Test all entries
|
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
170 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
171 |
('', b'tree-root'), |
172 |
('Makefile', b'makefile-id'), |
|
173 |
('doc', b'doc-id'), |
|
174 |
('src', b'src-id'), |
|
175 |
('src/bye.c', b'bye-id'), |
|
176 |
('src/hello.c', b'hello-id'), |
|
177 |
('src/sub', b'sub-id'), |
|
178 |
('src/sub/a', b'a-id'), |
|
179 |
('src/zz.c', b'zzc-id'), |
|
180 |
('zz', b'zz-id'), |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
181 |
], [(path, ie.file_id) for path, ie in inv.iter_entries()]) |
182 |
||
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
183 |
# Test a subdirectory
|
184 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
185 |
('bye.c', b'bye-id'), |
186 |
('hello.c', b'hello-id'), |
|
187 |
('sub', b'sub-id'), |
|
188 |
('sub/a', b'a-id'), |
|
189 |
('zz.c', b'zzc-id'), |
|
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
190 |
], [(path, ie.file_id) for path, ie in inv.iter_entries( |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
191 |
from_dir=b'src-id')]) |
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
192 |
|
193 |
# Test not recursing at the root level
|
|
194 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
195 |
('', b'tree-root'), |
196 |
('Makefile', b'makefile-id'), |
|
197 |
('doc', b'doc-id'), |
|
198 |
('src', b'src-id'), |
|
199 |
('zz', b'zz-id'), |
|
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
200 |
], [(path, ie.file_id) for path, ie in inv.iter_entries( |
201 |
recursive=False)]) |
|
202 |
||
203 |
# Test not recursing at a subdirectory level
|
|
204 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
205 |
('bye.c', b'bye-id'), |
206 |
('hello.c', b'hello-id'), |
|
207 |
('sub', b'sub-id'), |
|
208 |
('zz.c', b'zzc-id'), |
|
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
209 |
], [(path, ie.file_id) for path, ie in inv.iter_entries( |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
210 |
from_dir=b'src-id', recursive=False)]) |
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
211 |
|
|
3735.2.155
by Ian Clatworthy
Inventory.iter_just_entries() API & test |
212 |
def test_iter_just_entries(self): |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
213 |
inv = self.prepare_inv_with_nested_dirs() |
|
3735.2.155
by Ian Clatworthy
Inventory.iter_just_entries() API & test |
214 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
215 |
b'a-id', |
216 |
b'bye-id', |
|
217 |
b'doc-id', |
|
218 |
b'hello-id', |
|
219 |
b'makefile-id', |
|
220 |
b'src-id', |
|
221 |
b'sub-id', |
|
222 |
b'tree-root', |
|
223 |
b'zz-id', |
|
224 |
b'zzc-id', |
|
|
3735.2.155
by Ian Clatworthy
Inventory.iter_just_entries() API & test |
225 |
], sorted([ie.file_id for ie in inv.iter_just_entries()])) |
226 |
||
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
227 |
def test_iter_entries_by_dir(self): |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
228 |
inv = self. prepare_inv_with_nested_dirs() |
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
229 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
230 |
('', b'tree-root'), |
231 |
('Makefile', b'makefile-id'), |
|
232 |
('doc', b'doc-id'), |
|
233 |
('src', b'src-id'), |
|
234 |
('zz', b'zz-id'), |
|
235 |
('src/bye.c', b'bye-id'), |
|
236 |
('src/hello.c', b'hello-id'), |
|
237 |
('src/sub', b'sub-id'), |
|
238 |
('src/zz.c', b'zzc-id'), |
|
239 |
('src/sub/a', b'a-id'), |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
240 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir()]) |
241 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
242 |
('', b'tree-root'), |
243 |
('Makefile', b'makefile-id'), |
|
244 |
('doc', b'doc-id'), |
|
245 |
('src', b'src-id'), |
|
246 |
('zz', b'zz-id'), |
|
247 |
('src/bye.c', b'bye-id'), |
|
248 |
('src/hello.c', b'hello-id'), |
|
249 |
('src/sub', b'sub-id'), |
|
250 |
('src/zz.c', b'zzc-id'), |
|
251 |
('src/sub/a', b'a-id'), |
|
252 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
253 |
specific_file_ids=(b'a-id', b'zzc-id', b'doc-id', b'tree-root', |
|
254 |
b'hello-id', b'bye-id', b'zz-id', b'src-id', b'makefile-id', |
|
255 |
b'sub-id'))]) |
|
256 |
||
257 |
self.assertEqual([ |
|
258 |
('Makefile', b'makefile-id'), |
|
259 |
('doc', b'doc-id'), |
|
260 |
('zz', b'zz-id'), |
|
261 |
('src/bye.c', b'bye-id'), |
|
262 |
('src/hello.c', b'hello-id'), |
|
263 |
('src/zz.c', b'zzc-id'), |
|
264 |
('src/sub/a', b'a-id'), |
|
265 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
266 |
specific_file_ids=(b'a-id', b'zzc-id', b'doc-id', |
|
267 |
b'hello-id', b'bye-id', b'zz-id', b'makefile-id'))]) |
|
268 |
||
269 |
self.assertEqual([ |
|
270 |
('Makefile', b'makefile-id'), |
|
271 |
('src/bye.c', b'bye-id'), |
|
272 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
273 |
specific_file_ids=(b'bye-id', b'makefile-id'))]) |
|
274 |
||
275 |
self.assertEqual([ |
|
276 |
('Makefile', b'makefile-id'), |
|
277 |
('src/bye.c', b'bye-id'), |
|
278 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
279 |
specific_file_ids=(b'bye-id', b'makefile-id'))]) |
|
280 |
||
281 |
self.assertEqual([ |
|
282 |
('src/bye.c', b'bye-id'), |
|
283 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
284 |
specific_file_ids=(b'bye-id',))]) |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
285 |
|
286 |
||
287 |
class TestInventoryFiltering(TestInventory): |
|
288 |
||
289 |
def test_inv_filter_empty(self): |
|
290 |
inv = self.prepare_inv_with_nested_dirs() |
|
291 |
new_inv = inv.filter([]) |
|
292 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
293 |
('', b'tree-root'), |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
294 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |
295 |
||
296 |
def test_inv_filter_files(self): |
|
297 |
inv = self.prepare_inv_with_nested_dirs() |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
298 |
new_inv = inv.filter([b'zz-id', b'hello-id', b'a-id']) |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
299 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
300 |
('', b'tree-root'), |
301 |
('src', b'src-id'), |
|
302 |
('src/hello.c', b'hello-id'), |
|
303 |
('src/sub', b'sub-id'), |
|
304 |
('src/sub/a', b'a-id'), |
|
305 |
('zz', b'zz-id'), |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
306 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |
307 |
||
308 |
def test_inv_filter_dirs(self): |
|
309 |
inv = self.prepare_inv_with_nested_dirs() |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
310 |
new_inv = inv.filter([b'doc-id', b'sub-id']) |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
311 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
312 |
('', b'tree-root'), |
313 |
('doc', b'doc-id'), |
|
314 |
('src', b'src-id'), |
|
315 |
('src/sub', b'sub-id'), |
|
316 |
('src/sub/a', b'a-id'), |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
317 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |
318 |
||
319 |
def test_inv_filter_files_and_dirs(self): |
|
320 |
inv = self.prepare_inv_with_nested_dirs() |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
321 |
new_inv = inv.filter([b'makefile-id', b'src-id']) |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
322 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
323 |
('', b'tree-root'), |
324 |
('Makefile', b'makefile-id'), |
|
325 |
('src', b'src-id'), |
|
326 |
('src/bye.c', b'bye-id'), |
|
327 |
('src/hello.c', b'hello-id'), |
|
328 |
('src/sub', b'sub-id'), |
|
329 |
('src/sub/a', b'a-id'), |
|
330 |
('src/zz.c', b'zzc-id'), |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
331 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |
|
4634.51.11
by John Arbash Meinel
Handle the case when the specific_fileids don't exist in this revision. |
332 |
|
333 |
def test_inv_filter_entry_not_present(self): |
|
334 |
inv = self.prepare_inv_with_nested_dirs() |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
335 |
new_inv = inv.filter([b'not-present-id']) |
|
4634.51.11
by John Arbash Meinel
Handle the case when the specific_fileids don't exist in this revision. |
336 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
337 |
('', b'tree-root'), |
|
4634.51.11
by John Arbash Meinel
Handle the case when the specific_fileids don't exist in this revision. |
338 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |