Mercurial > kallithea
annotate rhodecode/tests/vcs/test_getitem.py @ 2822:1670ee0aded7 beta
fixed issue #559 fixed bug in routing that mapped repo names with <name>_<num> in name as
if it was a request to url by repository ID
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 07 Sep 2012 18:00:31 +0200 |
parents | 402a96fcfa22 |
children | d7488551578e |
rev | line source |
---|---|
2451
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 from __future__ import with_statement |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 import datetime |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 from base import BackendTestMixin |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 from conf import SCM_TESTS |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 from rhodecode.lib.vcs.nodes import FileNode |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 from rhodecode.lib.vcs.utils.compat import unittest |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 class GetitemTestCaseMixin(BackendTestMixin): |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 @classmethod |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 def _get_commits(cls): |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 start_date = datetime.datetime(2010, 1, 1, 20) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 for x in xrange(5): |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 yield { |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 'message': 'Commit %d' % x, |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 'author': 'Joe Doe <joe.doe@example.com>', |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 'date': start_date + datetime.timedelta(hours=12 * x), |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 'added': [ |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 FileNode('file_%d.txt' % x, content='Foobar %d' % x), |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 ], |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 } |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 def test__getitem__last_item_is_tip(self): |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 self.assertEqual(self.repo[-1], self.repo.get_changeset()) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 def test__getitem__returns_correct_items(self): |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 changesets = [self.repo[x] for x in xrange(len(self.repo.revisions))] |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 self.assertEqual(changesets, list(self.repo.get_changesets())) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 # For each backend create test case class |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 for alias in SCM_TESTS: |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 attrs = { |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 'backend_alias': alias, |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 } |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 cls_name = ''.join(('%s getitem test' % alias).title().split()) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 bases = (GetitemTestCaseMixin, unittest.TestCase) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 globals()[cls_name] = type(cls_name, bases, attrs) |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 if __name__ == '__main__': |
402a96fcfa22
Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 unittest.main() |