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 |
"""
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
88 |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
89 |
def test_add(self): |
90 |
inv = self.make_init_inventory() |
|
91 |
inv = inv.create_by_apply_delta([ |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
92 |
(None, "a", b"a-id", self.make_file(b'a-id', 'a', b'tree-root')), |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
93 |
], b'new-test-rev') |
94 |
self.assertEqual('a', inv.id2path(b'a-id')) |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
95 |
|
96 |
def test_delete(self): |
|
97 |
inv = self.make_init_inventory() |
|
98 |
inv = inv.create_by_apply_delta([ |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
99 |
(None, "a", b"a-id", self.make_file(b'a-id', 'a', b'tree-root')), |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
100 |
], b'new-rev-1') |
101 |
self.assertEqual('a', inv.id2path(b'a-id')) |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
102 |
inv = inv.create_by_apply_delta([ |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
103 |
("a", None, b"a-id", None), |
104 |
], b'new-rev-2') |
|
105 |
self.assertRaises(errors.NoSuchId, inv.id2path, b'a-id') |
|
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
106 |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
107 |
def test_rename(self): |
108 |
inv = self.make_init_inventory() |
|
109 |
inv = inv.create_by_apply_delta([ |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
110 |
(None, "a", b"a-id", self.make_file(b'a-id', 'a', b'tree-root')), |
111 |
], b'new-rev-1') |
|
112 |
self.assertEqual('a', inv.id2path(b'a-id')) |
|
|
6855.4.10
by Jelmer Vernooij
merge trunk |
113 |
a_ie = inv.get_entry(b'a-id') |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
114 |
b_ie = self.make_file(a_ie.file_id, "b", a_ie.parent_id) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
115 |
inv = inv.create_by_apply_delta( |
116 |
[("a", "b", b"a-id", b_ie)], b'new-rev-2') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
117 |
self.assertEqual("b", inv.id2path(b'a-id')) |
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
118 |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
119 |
def test_illegal(self): |
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
120 |
# 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. |
121 |
inv = self.make_init_inventory() |
122 |
self.assertRaises(errors.InconsistentDelta, inv.create_by_apply_delta, [ |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
123 |
(None, "a", b"id-1", self.make_file(b'id-1', 'a', b'tree-root')), |
124 |
(None, "b", b"id-1", self.make_file(b'id-1', 'b', b'tree-root')), |
|
125 |
], b'new-rev-1') |
|
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
126 |
|
127 |
||
128 |
class TestInventoryReads(TestInventory): |
|
129 |
||
130 |
def test_is_root(self): |
|
131 |
"""Ensure our root-checking code is accurate.""" |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
132 |
inv = self.make_init_inventory() |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
133 |
self.assertTrue(inv.is_root(b'tree-root')) |
134 |
self.assertFalse(inv.is_root(b'booga')) |
|
|
7045.1.17
by Jelmer Vernooij
Fix another test. |
135 |
ie = inv.get_entry(b'tree-root').copy() |
136 |
ie.file_id = b'booga' |
|
137 |
inv = inv.create_by_apply_delta([("", None, b"tree-root", None), |
|
138 |
(None, "", b"booga", ie)], b'new-rev-2') |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
139 |
self.assertFalse(inv.is_root(b'TREE_ROOT')) |
140 |
self.assertTrue(inv.is_root(b'booga')) |
|
|
4090.3.1
by Ian Clatworthy
check delta is legal in Inventory.apply_delta() |
141 |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
142 |
def test_ids(self): |
143 |
"""Test detection of files within selected directories.""" |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
144 |
inv = inventory.Inventory(b'TREE_ROOT') |
|
7045.1.19
by Jelmer Vernooij
Fix remaining inventory tests. |
145 |
inv.root.revision = b'revision' |
|
6973.6.1
by Jelmer Vernooij
More bees. |
146 |
for args in [('src', 'directory', b'src-id'), |
147 |
('doc', 'directory', b'doc-id'), |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
148 |
('src/hello.c', 'file'), |
|
6973.6.1
by Jelmer Vernooij
More bees. |
149 |
('src/bye.c', 'file', b'bye-id'), |
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
150 |
('Makefile', 'file')]: |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
151 |
ie = inv.add_path(*args) |
|
7045.1.19
by Jelmer Vernooij
Fix remaining inventory tests. |
152 |
ie.revision = b'revision' |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
153 |
if args[1] == 'file': |
|
6973.6.1
by Jelmer Vernooij
More bees. |
154 |
ie.text_sha1 = osutils.sha_string(b'content\n') |
155 |
ie.text_size = len(b'content\n') |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
156 |
inv = self.inv_to_test_inv(inv) |
|
6973.6.1
by Jelmer Vernooij
More bees. |
157 |
self.assertEqual(inv.path2id('src'), b'src-id') |
158 |
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) |
159 |
|
160 |
def test_non_directory_children(self): |
|
161 |
"""Test path2id when a parent directory has no children""" |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
162 |
inv = inventory.Inventory(b'tree-root') |
163 |
inv.add(self.make_file(b'file-id', 'file', b'tree-root')) |
|
164 |
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) |
165 |
self.assertIs(None, inv.path2id('file/subfile')) |
166 |
self.assertIs(None, inv.path2id('link/subfile')) |
|
167 |
||
168 |
def test_iter_entries(self): |
|
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
169 |
inv = self.prepare_inv_with_nested_dirs() |
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
170 |
|
171 |
# Test all entries
|
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
172 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
173 |
('', b'tree-root'), |
174 |
('Makefile', b'makefile-id'), |
|
175 |
('doc', b'doc-id'), |
|
176 |
('src', b'src-id'), |
|
177 |
('src/bye.c', b'bye-id'), |
|
178 |
('src/hello.c', b'hello-id'), |
|
179 |
('src/sub', b'sub-id'), |
|
180 |
('src/sub/a', b'a-id'), |
|
181 |
('src/zz.c', b'zzc-id'), |
|
182 |
('zz', b'zz-id'), |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
183 |
], [(path, ie.file_id) for path, ie in inv.iter_entries()]) |
184 |
||
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
185 |
# Test a subdirectory
|
186 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
187 |
('bye.c', b'bye-id'), |
188 |
('hello.c', b'hello-id'), |
|
189 |
('sub', b'sub-id'), |
|
190 |
('sub/a', b'a-id'), |
|
191 |
('zz.c', b'zzc-id'), |
|
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
192 |
], [(path, ie.file_id) for path, ie in inv.iter_entries( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
193 |
from_dir=b'src-id')]) |
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
194 |
|
195 |
# Test not recursing at the root level
|
|
196 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
197 |
('', b'tree-root'), |
198 |
('Makefile', b'makefile-id'), |
|
199 |
('doc', b'doc-id'), |
|
200 |
('src', b'src-id'), |
|
201 |
('zz', b'zz-id'), |
|
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
202 |
], [(path, ie.file_id) for path, ie in inv.iter_entries( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
203 |
recursive=False)]) |
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
204 |
|
205 |
# Test not recursing at a subdirectory level
|
|
206 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
207 |
('bye.c', b'bye-id'), |
208 |
('hello.c', b'hello-id'), |
|
209 |
('sub', b'sub-id'), |
|
210 |
('zz.c', b'zzc-id'), |
|
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
211 |
], [(path, ie.file_id) for path, ie in inv.iter_entries( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
212 |
from_dir=b'src-id', recursive=False)]) |
|
4370.5.1
by Ian Clatworthy
add recursive parameter to iter_entries() |
213 |
|
|
3735.2.155
by Ian Clatworthy
Inventory.iter_just_entries() API & test |
214 |
def test_iter_just_entries(self): |
|
4634.51.7
by John Arbash Meinel
Finish adding CHKInventory as a permutation in per_inventory. |
215 |
inv = self.prepare_inv_with_nested_dirs() |
|
3735.2.155
by Ian Clatworthy
Inventory.iter_just_entries() API & test |
216 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
217 |
b'a-id', |
218 |
b'bye-id', |
|
219 |
b'doc-id', |
|
220 |
b'hello-id', |
|
221 |
b'makefile-id', |
|
222 |
b'src-id', |
|
223 |
b'sub-id', |
|
224 |
b'tree-root', |
|
225 |
b'zz-id', |
|
226 |
b'zzc-id', |
|
|
3735.2.155
by Ian Clatworthy
Inventory.iter_just_entries() API & test |
227 |
], sorted([ie.file_id for ie in inv.iter_just_entries()])) |
228 |
||
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
229 |
def test_iter_entries_by_dir(self): |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
230 |
inv = self. prepare_inv_with_nested_dirs() |
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
231 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
232 |
('', b'tree-root'), |
233 |
('Makefile', b'makefile-id'), |
|
234 |
('doc', b'doc-id'), |
|
235 |
('src', b'src-id'), |
|
236 |
('zz', b'zz-id'), |
|
237 |
('src/bye.c', b'bye-id'), |
|
238 |
('src/hello.c', b'hello-id'), |
|
239 |
('src/sub', b'sub-id'), |
|
240 |
('src/zz.c', b'zzc-id'), |
|
241 |
('src/sub/a', b'a-id'), |
|
|
2729.2.9
by Martin Pool
Move actual tests from inventory_implementations __init__ into basics.py (Aaron) |
242 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir()]) |
243 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
244 |
('', b'tree-root'), |
245 |
('Makefile', b'makefile-id'), |
|
246 |
('doc', b'doc-id'), |
|
247 |
('src', b'src-id'), |
|
248 |
('zz', b'zz-id'), |
|
249 |
('src/bye.c', b'bye-id'), |
|
250 |
('src/hello.c', b'hello-id'), |
|
251 |
('src/sub', b'sub-id'), |
|
252 |
('src/zz.c', b'zzc-id'), |
|
253 |
('src/sub/a', b'a-id'), |
|
254 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
255 |
specific_file_ids=(b'a-id', b'zzc-id', b'doc-id', b'tree-root', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
256 |
b'hello-id', b'bye-id', b'zz-id', b'src-id', b'makefile-id', |
257 |
b'sub-id'))]) |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
258 |
|
259 |
self.assertEqual([ |
|
260 |
('Makefile', b'makefile-id'), |
|
261 |
('doc', b'doc-id'), |
|
262 |
('zz', b'zz-id'), |
|
263 |
('src/bye.c', b'bye-id'), |
|
264 |
('src/hello.c', b'hello-id'), |
|
265 |
('src/zz.c', b'zzc-id'), |
|
266 |
('src/sub/a', b'a-id'), |
|
267 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
268 |
specific_file_ids=(b'a-id', b'zzc-id', b'doc-id', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
269 |
b'hello-id', b'bye-id', b'zz-id', b'makefile-id'))]) |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
270 |
|
271 |
self.assertEqual([ |
|
272 |
('Makefile', b'makefile-id'), |
|
273 |
('src/bye.c', b'bye-id'), |
|
274 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
275 |
specific_file_ids=(b'bye-id', b'makefile-id'))]) |
|
276 |
||
277 |
self.assertEqual([ |
|
278 |
('Makefile', b'makefile-id'), |
|
279 |
('src/bye.c', b'bye-id'), |
|
280 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
281 |
specific_file_ids=(b'bye-id', b'makefile-id'))]) |
|
282 |
||
283 |
self.assertEqual([ |
|
284 |
('src/bye.c', b'bye-id'), |
|
285 |
], [(path, ie.file_id) for path, ie in inv.iter_entries_by_dir( |
|
286 |
specific_file_ids=(b'bye-id',))]) |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
287 |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
288 |
|
289 |
class TestInventoryFiltering(TestInventory): |
|
290 |
||
291 |
def test_inv_filter_empty(self): |
|
292 |
inv = self.prepare_inv_with_nested_dirs() |
|
293 |
new_inv = inv.filter([]) |
|
294 |
self.assertEqual([ |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
295 |
('', b'tree-root'), |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
296 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
297 |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
298 |
def test_inv_filter_files(self): |
299 |
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. |
300 |
new_inv = inv.filter([b'zz-id', b'hello-id', b'a-id']) |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
301 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
302 |
('', b'tree-root'), |
303 |
('src', b'src-id'), |
|
304 |
('src/hello.c', b'hello-id'), |
|
305 |
('src/sub', b'sub-id'), |
|
306 |
('src/sub/a', b'a-id'), |
|
307 |
('zz', b'zz-id'), |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
308 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
309 |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
310 |
def test_inv_filter_dirs(self): |
311 |
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. |
312 |
new_inv = inv.filter([b'doc-id', b'sub-id']) |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
313 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
314 |
('', b'tree-root'), |
315 |
('doc', b'doc-id'), |
|
316 |
('src', b'src-id'), |
|
317 |
('src/sub', b'sub-id'), |
|
318 |
('src/sub/a', b'a-id'), |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
319 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |
320 |
||
321 |
def test_inv_filter_files_and_dirs(self): |
|
322 |
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. |
323 |
new_inv = inv.filter([b'makefile-id', b'src-id']) |
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
324 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
325 |
('', b'tree-root'), |
326 |
('Makefile', b'makefile-id'), |
|
327 |
('src', b'src-id'), |
|
328 |
('src/bye.c', b'bye-id'), |
|
329 |
('src/hello.c', b'hello-id'), |
|
330 |
('src/sub', b'sub-id'), |
|
331 |
('src/sub/a', b'a-id'), |
|
332 |
('src/zz.c', b'zzc-id'), |
|
|
4137.3.1
by Ian Clatworthy
Inventory.filter() API with tests |
333 |
], [(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. |
334 |
|
335 |
def test_inv_filter_entry_not_present(self): |
|
336 |
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. |
337 |
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. |
338 |
self.assertEqual([ |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
339 |
('', b'tree-root'), |
|
4634.51.11
by John Arbash Meinel
Handle the case when the specific_fileids don't exist in this revision. |
340 |
], [(path, ie.file_id) for path, ie in new_inv.iter_entries()]) |