Show More
@@ -9,10 +9,9 b' from kallithea.lib.vcs.nodes import Node' | |||
|
9 | 9 | |
|
10 | 10 | from kallithea.tests.vcs.conf import TEST_HG_REPO, TEST_HG_REPO_CLONE, \ |
|
11 | 11 | TEST_HG_REPO_PULL, TESTS_TMP_PATH |
|
12 | from kallithea.lib.vcs.utils.compat import unittest | |
|
13 | 12 | |
|
14 | 13 | |
|
15 |
class MercurialRepository |
|
|
14 | class TestMercurialRepository(object): | |
|
16 | 15 | |
|
17 | 16 | def __check_for_existing_repo(self): |
|
18 | 17 | if os.path.exists(TEST_HG_REPO_CLONE): |
@@ -20,46 +19,52 b' class MercurialRepositoryTest(unittest.T' | |||
|
20 | 19 | 'exists. You should manually remove it first.' |
|
21 | 20 | % TEST_HG_REPO_CLONE) |
|
22 | 21 | |
|
23 |
def set |
|
|
22 | def setup_method(self): | |
|
24 | 23 | self.repo = MercurialRepository(safe_str(TEST_HG_REPO)) |
|
25 | 24 | |
|
26 | 25 | def test_wrong_repo_path(self): |
|
27 | 26 | wrong_repo_path = os.path.join(TESTS_TMP_PATH, 'errorrepo') |
|
28 | self.assertRaises(RepositoryError, MercurialRepository, wrong_repo_path) | |
|
27 | with pytest.raises(RepositoryError): | |
|
28 | MercurialRepository(wrong_repo_path) | |
|
29 | 29 | |
|
30 | 30 | def test_unicode_path_repo(self): |
|
31 | self.assertRaises(VCSError, lambda: MercurialRepository(u'iShouldFail')) | |
|
31 | with pytest.raises(VCSError): | |
|
32 | MercurialRepository(u'iShouldFail') | |
|
32 | 33 | |
|
33 | 34 | def test_repo_clone(self): |
|
34 | 35 | self.__check_for_existing_repo() |
|
35 | 36 | repo = MercurialRepository(safe_str(TEST_HG_REPO)) |
|
36 | 37 | repo_clone = MercurialRepository(TEST_HG_REPO_CLONE, |
|
37 | 38 | src_url=TEST_HG_REPO, update_after_clone=True) |
|
38 |
|
|
|
39 | assert len(repo.revisions) == len(repo_clone.revisions) | |
|
39 | 40 | # Checking hashes of changesets should be enough |
|
40 | 41 | for changeset in repo.get_changesets(): |
|
41 | 42 | raw_id = changeset.raw_id |
|
42 |
|
|
|
43 | assert raw_id == repo_clone.get_changeset(raw_id).raw_id | |
|
43 | 44 | |
|
44 | 45 | def test_repo_clone_with_update(self): |
|
45 | 46 | repo = MercurialRepository(safe_str(TEST_HG_REPO)) |
|
46 | 47 | repo_clone = MercurialRepository(TEST_HG_REPO_CLONE + '_w_update', |
|
47 | 48 | src_url=TEST_HG_REPO, update_after_clone=True) |
|
48 |
|
|
|
49 | assert len(repo.revisions) == len(repo_clone.revisions) | |
|
49 | 50 | |
|
50 | 51 | # check if current workdir was updated |
|
51 | self.assertEqual(os.path.isfile(os.path.join(TEST_HG_REPO_CLONE \ | |
|
52 | + '_w_update', | |
|
53 | 'MANIFEST.in')), True,) | |
|
52 | assert os.path.isfile( | |
|
53 | os.path.join( | |
|
54 | TEST_HG_REPO_CLONE + '_w_update', 'MANIFEST.in' | |
|
55 | ) | |
|
56 | ) | |
|
54 | 57 | |
|
55 | 58 | def test_repo_clone_without_update(self): |
|
56 | 59 | repo = MercurialRepository(safe_str(TEST_HG_REPO)) |
|
57 | 60 | repo_clone = MercurialRepository(TEST_HG_REPO_CLONE + '_wo_update', |
|
58 | 61 | src_url=TEST_HG_REPO, update_after_clone=False) |
|
59 |
|
|
|
60 | self.assertEqual(os.path.isfile(os.path.join(TEST_HG_REPO_CLONE \ | |
|
61 | + '_wo_update', | |
|
62 | 'MANIFEST.in')), False,) | |
|
62 | assert len(repo.revisions) == len(repo_clone.revisions) | |
|
63 | assert not os.path.isfile( | |
|
64 | os.path.join( | |
|
65 | TEST_HG_REPO_CLONE + '_wo_update', 'MANIFEST.in' | |
|
66 | ) | |
|
67 | ) | |
|
63 | 68 | |
|
64 | 69 | def test_pull(self): |
|
65 | 70 | if os.path.exists(TEST_HG_REPO_PULL): |
@@ -67,11 +72,11 b' class MercurialRepositoryTest(unittest.T' | |||
|
67 | 72 | 'already exists. You should manually remove it first' |
|
68 | 73 | % TEST_HG_REPO_PULL) |
|
69 | 74 | repo_new = MercurialRepository(TEST_HG_REPO_PULL, create=True) |
|
70 |
|
|
|
75 | assert len(self.repo.revisions) > len(repo_new.revisions) | |
|
71 | 76 | |
|
72 | 77 | repo_new.pull(self.repo.path) |
|
73 | 78 | repo_new = MercurialRepository(TEST_HG_REPO_PULL) |
|
74 |
|
|
|
79 | assert len(self.repo.revisions) == len(repo_new.revisions) | |
|
75 | 80 | |
|
76 | 81 | def test_revisions(self): |
|
77 | 82 | # there are 21 revisions at bitbucket now |
@@ -96,7 +101,7 b' class MercurialRepositoryTest(unittest.T' | |||
|
96 | 101 | 'aa6a0de05b7612707db567078e130a6cd114a9a7', |
|
97 | 102 | 'eada5a770da98ab0dd7325e29d00e0714f228d09' |
|
98 | 103 | ]) |
|
99 |
|
|
|
104 | assert subset.issubset(set(self.repo.revisions)) | |
|
100 | 105 | |
|
101 | 106 | # check if we have the proper order of revisions |
|
102 | 107 | org = ['b986218ba1c9b0d6a259fac9b050b1724ed8e545', |
@@ -130,90 +135,87 b' class MercurialRepositoryTest(unittest.T' | |||
|
130 | 135 | 'ff5ab059786ebc7411e559a2cc309dfae3625a3b', |
|
131 | 136 | '6b6ad5f82ad5bb6190037671bd254bd4e1f4bf08', |
|
132 | 137 | 'ee87846a61c12153b51543bf860e1026c6d3dcba', ] |
|
133 |
|
|
|
138 | assert org == self.repo.revisions[:31] | |
|
134 | 139 | |
|
135 | 140 | def test_iter_slice(self): |
|
136 | 141 | sliced = list(self.repo[:10]) |
|
137 | 142 | itered = list(self.repo)[:10] |
|
138 |
|
|
|
143 | assert sliced == itered | |
|
139 | 144 | |
|
140 | 145 | def test_slicing(self): |
|
141 | 146 | # 4 1 5 10 95 |
|
142 | 147 | for sfrom, sto, size in [(0, 4, 4), (1, 2, 1), (10, 15, 5), |
|
143 | 148 | (10, 20, 10), (5, 100, 95)]: |
|
144 | 149 | revs = list(self.repo[sfrom:sto]) |
|
145 |
|
|
|
146 |
|
|
|
147 |
|
|
|
150 | assert len(revs) == size | |
|
151 | assert revs[0] == self.repo.get_changeset(sfrom) | |
|
152 | assert revs[-1] == self.repo.get_changeset(sto - 1) | |
|
148 | 153 | |
|
149 | 154 | def test_branches(self): |
|
150 | 155 | # TODO: Need more tests here |
|
151 | 156 | |
|
152 | 157 | # active branches |
|
153 |
|
|
|
154 |
|
|
|
158 | assert 'default' in self.repo.branches | |
|
159 | assert 'stable' in self.repo.branches | |
|
155 | 160 | |
|
156 | 161 | # closed |
|
157 |
|
|
|
158 |
|
|
|
162 | assert 'git' in self.repo._get_branches(closed=True) | |
|
163 | assert 'web' in self.repo._get_branches(closed=True) | |
|
159 | 164 | |
|
160 | 165 | for name, id in self.repo.branches.items(): |
|
161 | self.assertTrue(isinstance( | |
|
162 | self.repo.get_changeset(id), MercurialChangeset)) | |
|
166 | assert isinstance(self.repo.get_changeset(id), MercurialChangeset) | |
|
163 | 167 | |
|
164 | 168 | def test_tip_in_tags(self): |
|
165 | 169 | # tip is always a tag |
|
166 |
|
|
|
170 | assert 'tip' in self.repo.tags | |
|
167 | 171 | |
|
168 | 172 | def test_tip_changeset_in_tags(self): |
|
169 | 173 | tip = self.repo.get_changeset() |
|
170 |
|
|
|
174 | assert self.repo.tags['tip'] == tip.raw_id | |
|
171 | 175 | |
|
172 | 176 | def test_initial_changeset(self): |
|
173 | 177 | |
|
174 | 178 | init_chset = self.repo.get_changeset(0) |
|
175 |
|
|
|
176 | self.assertEqual(init_chset.author, | |
|
177 | 'Marcin Kuzminski <marcin@python-blog.com>') | |
|
178 | self.assertEqual(sorted(init_chset._file_paths), | |
|
179 | sorted([ | |
|
180 |
|
|
|
181 | 'vcs/backends/BaseRepository.py', | |
|
182 | 'vcs/backends/__init__.py', | |
|
183 | ]) | |
|
184 | ) | |
|
185 | self.assertEqual(sorted(init_chset._dir_paths), | |
|
186 | sorted(['', 'vcs', 'vcs/backends'])) | |
|
179 | assert init_chset.message == 'initial import' | |
|
180 | assert init_chset.author == 'Marcin Kuzminski <marcin@python-blog.com>' | |
|
181 | assert sorted(init_chset._file_paths) == sorted([ | |
|
182 | 'vcs/__init__.py', | |
|
183 | 'vcs/backends/BaseRepository.py', | |
|
184 | 'vcs/backends/__init__.py', | |
|
185 | ]) | |
|
187 | 186 | |
|
188 | self.assertRaises(NodeDoesNotExistError, init_chset.get_node, path='foobar') | |
|
187 | assert sorted(init_chset._dir_paths) == sorted(['', 'vcs', 'vcs/backends']) | |
|
188 | ||
|
189 | with pytest.raises(NodeDoesNotExistError): | |
|
190 | init_chset.get_node(path='foobar') | |
|
189 | 191 | |
|
190 | 192 | node = init_chset.get_node('vcs/') |
|
191 |
|
|
|
192 |
|
|
|
193 | assert hasattr(node, 'kind') | |
|
194 | assert node.kind == NodeKind.DIR | |
|
193 | 195 | |
|
194 | 196 | node = init_chset.get_node('vcs') |
|
195 |
|
|
|
196 |
|
|
|
197 | assert hasattr(node, 'kind') | |
|
198 | assert node.kind == NodeKind.DIR | |
|
197 | 199 | |
|
198 | 200 | node = init_chset.get_node('vcs/__init__.py') |
|
199 |
|
|
|
200 |
|
|
|
201 | assert hasattr(node, 'kind') | |
|
202 | assert node.kind == NodeKind.FILE | |
|
201 | 203 | |
|
202 | 204 | def test_not_existing_changeset(self): |
|
203 | 205 | # rawid |
|
204 | self.assertRaises(RepositoryError, self.repo.get_changeset, | |
|
205 | 'abcd' * 10) | |
|
206 | with pytest.raises(RepositoryError): | |
|
207 | self.repo.get_changeset('abcd' * 10) | |
|
206 | 208 | # shortid |
|
207 | self.assertRaises(RepositoryError, self.repo.get_changeset, | |
|
208 | 'erro' * 4) | |
|
209 | with pytest.raises(RepositoryError): | |
|
210 | self.repo.get_changeset('erro' * 4) | |
|
209 | 211 | # numeric |
|
210 | self.assertRaises(RepositoryError, self.repo.get_changeset, | |
|
211 | self.repo.count() + 1) | |
|
212 | ||
|
212 | with pytest.raises(RepositoryError): | |
|
213 | self.repo.get_changeset(self.repo.count() + 1) | |
|
213 | 214 | |
|
214 | 215 | # Small chance we ever get to this one |
|
215 | 216 | revision = pow(2, 30) |
|
216 | self.assertRaises(RepositoryError, self.repo.get_changeset, revision) | |
|
217 | with pytest.raises(RepositoryError): | |
|
218 | self.repo.get_changeset(revision) | |
|
217 | 219 | |
|
218 | 220 | def test_changeset10(self): |
|
219 | 221 | |
@@ -231,21 +233,20 b' TODO: To be written...' | |||
|
231 | 233 | |
|
232 | 234 | """ |
|
233 | 235 | node = chset10.get_node('README.rst') |
|
234 |
|
|
|
235 |
|
|
|
236 | assert node.kind == NodeKind.FILE | |
|
237 | assert node.content == readme | |
|
236 | 238 | |
|
237 | 239 | |
|
238 |
class MercurialChangeset |
|
|
240 | class TestMercurialChangeset(object): | |
|
239 | 241 | |
|
240 |
def set |
|
|
242 | def setup_method(self): | |
|
241 | 243 | self.repo = MercurialRepository(safe_str(TEST_HG_REPO)) |
|
242 | 244 | |
|
243 | 245 | def _test_equality(self, changeset): |
|
244 | 246 | revision = changeset.revision |
|
245 |
|
|
|
247 | assert changeset == self.repo.get_changeset(revision) | |
|
246 | 248 | |
|
247 | 249 | def test_equality(self): |
|
248 | self.setUp() | |
|
249 | 250 | revs = [0, 10, 20] |
|
250 | 251 | changesets = [self.repo.get_changeset(rev) for rev in revs] |
|
251 | 252 | for changeset in changesets: |
@@ -253,13 +254,13 b' class MercurialChangesetTest(unittest.Te' | |||
|
253 | 254 | |
|
254 | 255 | def test_default_changeset(self): |
|
255 | 256 | tip = self.repo.get_changeset('tip') |
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
|
257 | assert tip == self.repo.get_changeset() | |
|
258 | assert tip == self.repo.get_changeset(revision=None) | |
|
259 | assert tip == list(self.repo[-1:])[0] | |
|
259 | 260 | |
|
260 | 261 | def test_root_node(self): |
|
261 | 262 | tip = self.repo.get_changeset('tip') |
|
262 |
|
|
|
263 | assert tip.root is tip.get_node('') | |
|
263 | 264 | |
|
264 | 265 | def test_lazy_fetch(self): |
|
265 | 266 | """ |
@@ -267,60 +268,56 b' class MercurialChangesetTest(unittest.Te' | |||
|
267 | 268 | the revision. This test is somewhat hard to write as order of tests |
|
268 | 269 | is a key here. Written by running command after command in a shell. |
|
269 | 270 | """ |
|
270 | self.setUp() | |
|
271 | 271 | chset = self.repo.get_changeset(45) |
|
272 |
|
|
|
272 | assert len(chset.nodes) == 0 | |
|
273 | 273 | root = chset.root |
|
274 |
|
|
|
275 |
|
|
|
274 | assert len(chset.nodes) == 1 | |
|
275 | assert len(root.nodes) == 8 | |
|
276 | 276 | # accessing root.nodes updates chset.nodes |
|
277 |
|
|
|
277 | assert len(chset.nodes) == 9 | |
|
278 | 278 | |
|
279 | 279 | docs = root.get_node('docs') |
|
280 | 280 | # we haven't yet accessed anything new as docs dir was already cached |
|
281 |
|
|
|
282 |
|
|
|
281 | assert len(chset.nodes) == 9 | |
|
282 | assert len(docs.nodes) == 8 | |
|
283 | 283 | # accessing docs.nodes updates chset.nodes |
|
284 |
|
|
|
284 | assert len(chset.nodes) == 17 | |
|
285 | 285 | |
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
|
|
|
286 | assert docs is chset.get_node('docs') | |
|
287 | assert docs is root.nodes[0] | |
|
288 | assert docs is root.dirs[0] | |
|
289 | assert docs is chset.get_node('docs') | |
|
290 | 290 | |
|
291 | 291 | def test_nodes_with_changeset(self): |
|
292 | self.setUp() | |
|
293 | 292 | chset = self.repo.get_changeset(45) |
|
294 | 293 | root = chset.root |
|
295 | 294 | docs = root.get_node('docs') |
|
296 |
|
|
|
295 | assert docs is chset.get_node('docs') | |
|
297 | 296 | api = docs.get_node('api') |
|
298 |
|
|
|
297 | assert api is chset.get_node('docs/api') | |
|
299 | 298 | index = api.get_node('index.rst') |
|
300 |
|
|
|
301 |
|
|
|
302 | .get_node('api') \ | |
|
303 | .get_node('index.rst')) | |
|
299 | assert index is chset.get_node('docs/api/index.rst') | |
|
300 | assert index is chset.get_node('docs').get_node('api').get_node('index.rst') | |
|
304 | 301 | |
|
305 | 302 | def test_branch_and_tags(self): |
|
306 | 303 | chset0 = self.repo.get_changeset(0) |
|
307 |
|
|
|
308 |
|
|
|
304 | assert chset0.branch == 'default' | |
|
305 | assert chset0.tags == [] | |
|
309 | 306 | |
|
310 | 307 | chset10 = self.repo.get_changeset(10) |
|
311 |
|
|
|
312 |
|
|
|
308 | assert chset10.branch == 'default' | |
|
309 | assert chset10.tags == [] | |
|
313 | 310 | |
|
314 | 311 | chset44 = self.repo.get_changeset(44) |
|
315 |
|
|
|
312 | assert chset44.branch == 'web' | |
|
316 | 313 | |
|
317 | 314 | tip = self.repo.get_changeset('tip') |
|
318 |
|
|
|
315 | assert 'tip' in tip.tags | |
|
319 | 316 | |
|
320 | 317 | def _test_file_size(self, revision, path, size): |
|
321 | 318 | node = self.repo.get_changeset(revision).get_node(path) |
|
322 |
|
|
|
323 |
|
|
|
319 | assert node.is_file() | |
|
320 | assert node.size == size | |
|
324 | 321 | |
|
325 | 322 | def test_file_size(self): |
|
326 | 323 | to_check = ( |
@@ -337,8 +334,8 b' class MercurialChangesetTest(unittest.Te' | |||
|
337 | 334 | |
|
338 | 335 | def _test_dir_size(self, revision, path, size): |
|
339 | 336 | node = self.repo.get_changeset(revision).get_node(path) |
|
340 |
|
|
|
341 |
|
|
|
337 | assert not node.is_file() | |
|
338 | assert node.size == size | |
|
342 | 339 | |
|
343 | 340 | def test_dir_size(self): |
|
344 | 341 | to_check = ( |
@@ -350,7 +347,7 b' class MercurialChangesetTest(unittest.Te' | |||
|
350 | 347 | self._test_dir_size(revision, path, size) |
|
351 | 348 | |
|
352 | 349 | def test_repo_size(self): |
|
353 |
|
|
|
350 | assert self.repo.size == 682421 | |
|
354 | 351 | |
|
355 | 352 | def test_file_history(self): |
|
356 | 353 | # we can only check if those revisions are present in the history |
@@ -368,10 +365,10 b' class MercurialChangesetTest(unittest.Te' | |||
|
368 | 365 | tip = self.repo.get_changeset(revs[-1]) |
|
369 | 366 | node = tip.get_node(path) |
|
370 | 367 | node_revs = [chset.revision for chset in node.history] |
|
371 |
|
|
|
372 | "We assumed that %s is subset of revisions for which file %s " | |
|
373 | "has been changed, and history of that node returned: %s" | |
|
374 |
% (revs, path, node_revs) |
|
|
368 | assert set(revs).issubset(set(node_revs)), \ | |
|
369 | "We assumed that %s is subset of revisions for which file %s " \ | |
|
370 | "has been changed, and history of that node returned: %s" \ | |
|
371 | % (revs, path, node_revs) | |
|
375 | 372 | |
|
376 | 373 | def test_file_annotate(self): |
|
377 | 374 | files = { |
@@ -410,12 +407,12 b' class MercurialChangesetTest(unittest.Te' | |||
|
410 | 407 | cs = self.repo.get_changeset(rev) |
|
411 | 408 | l1_1 = [x[1] for x in cs.get_file_annotate(fname)] |
|
412 | 409 | l1_2 = [x[2]().raw_id for x in cs.get_file_annotate(fname)] |
|
413 |
|
|
|
410 | assert l1_1 == l1_2 | |
|
414 | 411 | l1 = l1_2 = [x[2]().revision for x in cs.get_file_annotate(fname)] |
|
415 | 412 | l2 = files[fname][rev]['changesets'] |
|
416 |
|
|
|
417 |
|
|
|
418 |
|
|
|
413 | assert l1 == l2, "The lists of revision for %s@rev%s" \ | |
|
414 | "from annotation list should match each other," \ | |
|
415 | "got \n%s \nvs \n%s " % (fname, rev, l1, l2) | |
|
419 | 416 | |
|
420 | 417 | def test_changeset_state(self): |
|
421 | 418 | """ |
@@ -447,9 +444,9 b' class MercurialChangesetTest(unittest.Te' | |||
|
447 | 444 | removed = set(['docs/api.rst']) |
|
448 | 445 | |
|
449 | 446 | chset64 = self.repo.get_changeset('46ad32a4f974') |
|
450 |
|
|
|
451 |
|
|
|
452 |
|
|
|
447 | assert set((node.path for node in chset64.added)) == added | |
|
448 | assert set((node.path for node in chset64.changed)) == changed | |
|
449 | assert set((node.path for node in chset64.removed)) == removed | |
|
453 | 450 | |
|
454 | 451 | # rev b090f22d27d6: |
|
455 | 452 | # hg st --rev b090f22d27d6 |
@@ -457,27 +454,30 b' class MercurialChangesetTest(unittest.Te' | |||
|
457 | 454 | # added: 20 |
|
458 | 455 | # removed: 1 |
|
459 | 456 | chset88 = self.repo.get_changeset('b090f22d27d6') |
|
460 |
|
|
|
461 |
|
|
|
462 | set(['.hgignore'])) | |
|
463 | self.assertEqual(set((node.path for node in chset88.removed)), set()) | |
|
457 | assert set((node.path for node in chset88.added)) == set() | |
|
458 | assert set((node.path for node in chset88.changed)) == set(['.hgignore']) | |
|
459 | assert set((node.path for node in chset88.removed)) == set() | |
|
464 | 460 | |
|
465 | 461 | # 85: |
|
466 | 462 | # added: 2 ['vcs/utils/diffs.py', 'vcs/web/simplevcs/views/diffs.py'] |
|
467 | 463 | # changed: 4 ['vcs/web/simplevcs/models.py', ...] |
|
468 | 464 | # removed: 1 ['vcs/utils/web.py'] |
|
469 | 465 | chset85 = self.repo.get_changeset(85) |
|
470 |
|
|
|
466 | assert set((node.path for node in chset85.added)) == set([ | |
|
471 | 467 | 'vcs/utils/diffs.py', |
|
472 |
'vcs/web/simplevcs/views/diffs.py' |
|
|
473 | self.assertEqual(set((node.path for node in chset85.changed)), set([ | |
|
468 | 'vcs/web/simplevcs/views/diffs.py' | |
|
469 | ]) | |
|
470 | ||
|
471 | assert set((node.path for node in chset85.changed)) == set([ | |
|
474 | 472 | 'vcs/web/simplevcs/models.py', |
|
475 | 473 | 'vcs/web/simplevcs/utils.py', |
|
476 | 474 | 'vcs/web/simplevcs/views/__init__.py', |
|
477 | 475 | 'vcs/web/simplevcs/views/repository.py', |
|
478 |
|
|
|
479 | self.assertEqual(set((node.path for node in chset85.removed)), | |
|
480 | set(['vcs/utils/web.py'])) | |
|
476 | ]) | |
|
477 | ||
|
478 | assert set((node.path for node in chset85.removed)) == set([ | |
|
479 | 'vcs/utils/web.py' | |
|
480 | ]) | |
|
481 | 481 | |
|
482 | 482 | |
|
483 | 483 | def test_files_state(self): |
@@ -486,54 +486,56 b' class MercurialChangesetTest(unittest.Te' | |||
|
486 | 486 | """ |
|
487 | 487 | chset = self.repo.get_changeset(85) |
|
488 | 488 | node = chset.get_node('vcs/utils/diffs.py') |
|
489 |
|
|
|
490 |
|
|
|
491 |
|
|
|
492 |
|
|
|
493 |
|
|
|
489 | assert node.state, NodeState.ADDED | |
|
490 | assert node.added | |
|
491 | assert not node.changed | |
|
492 | assert not node.not_changed | |
|
493 | assert not node.removed | |
|
494 | 494 | |
|
495 | 495 | chset = self.repo.get_changeset(88) |
|
496 | 496 | node = chset.get_node('.hgignore') |
|
497 |
|
|
|
498 |
|
|
|
499 |
|
|
|
500 |
|
|
|
501 |
|
|
|
497 | assert node.state, NodeState.CHANGED | |
|
498 | assert not node.added | |
|
499 | assert node.changed | |
|
500 | assert not node.not_changed | |
|
501 | assert not node.removed | |
|
502 | 502 | |
|
503 | 503 | chset = self.repo.get_changeset(85) |
|
504 | 504 | node = chset.get_node('setup.py') |
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
|
505 | assert node.state, NodeState.NOT_CHANGED | |
|
506 | assert not node.added | |
|
507 | assert not node.changed | |
|
508 | assert node.not_changed | |
|
509 | assert not node.removed | |
|
510 | 510 | |
|
511 | 511 | # If node has REMOVED state then trying to fetch it would raise |
|
512 | 512 | # ChangesetError exception |
|
513 | 513 | chset = self.repo.get_changeset(2) |
|
514 | 514 | path = 'vcs/backends/BaseRepository.py' |
|
515 |
|
|
|
515 | with pytest.raises(NodeDoesNotExistError): | |
|
516 | chset.get_node(path) | |
|
516 | 517 | # but it would be one of ``removed`` (changeset's attribute) |
|
517 |
|
|
|
518 | assert path in [rf.path for rf in chset.removed] | |
|
518 | 519 | |
|
519 | 520 | def test_commit_message_is_unicode(self): |
|
520 | 521 | for cm in self.repo: |
|
521 |
|
|
|
522 | assert type(cm.message) == unicode | |
|
522 | 523 | |
|
523 | 524 | def test_changeset_author_is_unicode(self): |
|
524 | 525 | for cm in self.repo: |
|
525 |
|
|
|
526 | assert type(cm.author) == unicode | |
|
526 | 527 | |
|
527 | 528 | def test_repo_files_content_is_unicode(self): |
|
528 | 529 | test_changeset = self.repo.get_changeset(100) |
|
529 | 530 | for node in test_changeset.get_node('/'): |
|
530 | 531 | if node.is_file(): |
|
531 |
|
|
|
532 | assert type(node.content) == unicode | |
|
532 | 533 | |
|
533 | 534 | def test_wrong_path(self): |
|
534 | 535 | # There is 'setup.py' in the root dir but not there: |
|
535 | 536 | path = 'foo/bar/setup.py' |
|
536 | self.assertRaises(VCSError, self.repo.get_changeset().get_node, path) | |
|
537 | with pytest.raises(VCSError): | |
|
538 | self.repo.get_changeset().get_node(path) | |
|
537 | 539 | |
|
538 | 540 | def test_archival_file(self): |
|
539 | 541 | # TODO: |
@@ -545,24 +547,19 b' class MercurialChangesetTest(unittest.Te' | |||
|
545 | 547 | |
|
546 | 548 | def test_archival_wrong_kind(self): |
|
547 | 549 | tip = self.repo.get_changeset() |
|
548 | self.assertRaises(VCSError, tip.fill_archive, kind='error') | |
|
550 | with pytest.raises(VCSError): | |
|
551 | tip.fill_archive(kind='error') | |
|
549 | 552 | |
|
550 | 553 | def test_archival_empty_prefix(self): |
|
551 | 554 | # TODO: |
|
552 | 555 | pass |
|
553 | 556 | |
|
554 | 557 | def test_author_email(self): |
|
555 | self.assertEqual('marcin@python-blog.com', | |
|
556 | self.repo.get_changeset('b986218ba1c9').author_email) | |
|
557 | self.assertEqual('lukasz.balcerzak@python-center.pl', | |
|
558 | self.repo.get_changeset('3803844fdbd3').author_email) | |
|
559 | self.assertEqual('', | |
|
560 | self.repo.get_changeset('84478366594b').author_email) | |
|
558 | assert 'marcin@python-blog.com' == self.repo.get_changeset('b986218ba1c9').author_email | |
|
559 | assert 'lukasz.balcerzak@python-center.pl' == self.repo.get_changeset('3803844fdbd3').author_email | |
|
560 | assert '' == self.repo.get_changeset('84478366594b').author_email | |
|
561 | 561 | |
|
562 | 562 | def test_author_username(self): |
|
563 | self.assertEqual('Marcin Kuzminski', | |
|
564 |
|
|
|
565 | self.assertEqual('Lukasz Balcerzak', | |
|
566 | self.repo.get_changeset('3803844fdbd3').author_name) | |
|
567 | self.assertEqual('marcink', | |
|
568 | self.repo.get_changeset('84478366594b').author_name) | |
|
563 | assert 'Marcin Kuzminski' == self.repo.get_changeset('b986218ba1c9').author_name | |
|
564 | assert 'Lukasz Balcerzak' == self.repo.get_changeset('3803844fdbd3').author_name | |
|
565 | assert 'marcink' == self.repo.get_changeset('84478366594b').author_name |
General Comments 0
You need to be logged in to leave comments.
Login now