annotate rhodecode/tests/vcs/test_changesets.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 03a770980b55
children 4abfb1afd9f5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 from rhodecode.lib import vcs
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 import datetime
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 from base import BackendTestMixin
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 from conf import SCM_TESTS
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 from rhodecode.lib.vcs.backends.base import BaseChangeset
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 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
9 from rhodecode.lib.vcs.exceptions import BranchDoesNotExistError
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 from rhodecode.lib.vcs.exceptions import RepositoryError
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 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
13
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 class TestBaseChangeset(unittest.TestCase):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 def test_as_dict(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 changeset = BaseChangeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 changeset.id = 'ID'
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 changeset.raw_id = 'RAW_ID'
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 changeset.short_id = 'SHORT_ID'
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 changeset.revision = 1009
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 changeset.date = datetime.datetime(2011, 1, 30, 1, 45)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 changeset.message = 'Message of a commit'
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 changeset.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
26 changeset.added = [FileNode('foo/bar/baz'), FileNode('foobar')]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 changeset.changed = []
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 changeset.removed = []
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 self.assertEqual(changeset.as_dict(), {
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 'id': 'ID',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 'raw_id': 'RAW_ID',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 'short_id': 'SHORT_ID',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 'revision': 1009,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 'date': datetime.datetime(2011, 1, 30, 1, 45),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 'message': 'Message of a commit',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 'author': {
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 'name': 'Joe Doe',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 'email': 'joe.doe@example.com',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 },
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 'added': ['foo/bar/baz', 'foobar'],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 'changed': [],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 'removed': [],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 })
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 class ChangesetsWithCommitsTestCaseixin(BackendTestMixin):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 recreate_repo_per_test = True
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 @classmethod
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 def _get_commits(cls):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 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
51 for x in xrange(5):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 yield {
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 'message': 'Commit %d' % x,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 '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
55 '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
56 'added': [
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 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
58 ],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 }
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 def test_new_branch(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 self.imc.add(vcs.nodes.FileNode('docs/index.txt',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 content='Documentation\n'))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 foobar_tip = self.imc.commit(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 message=u'New branch: foobar',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 author=u'joe',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 branch='foobar',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 )
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 self.assertTrue('foobar' in self.repo.branches)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 self.assertEqual(foobar_tip.branch, 'foobar')
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 # 'foobar' should be the only branch that contains the new commit
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 self.assertNotEqual(*self.repo.branches.values())
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 def test_new_head_in_default_branch(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 tip = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 self.imc.add(vcs.nodes.FileNode('docs/index.txt',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 content='Documentation\n'))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 foobar_tip = self.imc.commit(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 message=u'New branch: foobar',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 author=u'joe',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 branch='foobar',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 parents=[tip],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 )
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84 self.imc.change(vcs.nodes.FileNode('docs/index.txt',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 content='Documentation\nand more...\n'))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 newtip = self.imc.commit(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 message=u'At default branch',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 author=u'joe',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 branch=foobar_tip.branch,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90 parents=[foobar_tip],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91 )
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 newest_tip = self.imc.commit(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94 message=u'Merged with %s' % foobar_tip.raw_id,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 author=u'joe',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 branch=self.backend_class.DEFAULT_BRANCH_NAME,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 parents=[newtip, foobar_tip],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
98 )
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100 self.assertEqual(newest_tip.branch,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101 self.backend_class.DEFAULT_BRANCH_NAME)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103 def test_get_changesets_respects_branch_name(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104 tip = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105 self.imc.add(vcs.nodes.FileNode('docs/index.txt',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
106 content='Documentation\n'))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107 doc_changeset = self.imc.commit(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108 message=u'New branch: docs',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109 author=u'joe',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110 branch='docs',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
111 )
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112 self.imc.add(vcs.nodes.FileNode('newfile', content=''))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113 self.imc.commit(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114 message=u'Back in default branch',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
115 author=u'joe',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116 parents=[tip],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117 )
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118 default_branch_changesets = self.repo.get_changesets(
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119 branch_name=self.repo.DEFAULT_BRANCH_NAME)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120 self.assertNotIn(doc_changeset, default_branch_changesets)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121
2543
03a770980b55 Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
122 def test_get_changeset_by_branch(self):
03a770980b55 Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
123 for branch, sha in self.repo.branches.iteritems():
03a770980b55 Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
124 self.assertEqual(sha, self.repo.get_changeset(branch).raw_id)
03a770980b55 Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
125
03a770980b55 Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
126 def test_get_changeset_by_tag(self):
03a770980b55 Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
127 for tag, sha in self.repo.tags.iteritems():
03a770980b55 Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
128 self.assertEqual(sha, self.repo.get_changeset(tag).raw_id)
03a770980b55 Synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
129
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 class ChangesetsTestCaseMixin(BackendTestMixin):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132 recreate_repo_per_test = False
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
133
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134 @classmethod
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135 def _get_commits(cls):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 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
137 for x in xrange(5):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138 yield {
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139 'message': u'Commit %d' % x,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
140 'author': u'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
141 '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
142 'added': [
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
143 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
144 ],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
145 }
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
146
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
147 def test_simple(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
148 tip = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149 self.assertEqual(tip.date, datetime.datetime(2010, 1, 3, 20))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
151 def test_get_changesets_is_ordered_by_date(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
152 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
153 ordered_by_date = sorted(changesets,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
154 key=lambda cs: cs.date)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
155 self.assertItemsEqual(changesets, ordered_by_date)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
157 def test_get_changesets_respects_start(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
158 second_id = self.repo.revisions[1]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
159 changesets = list(self.repo.get_changesets(start=second_id))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
160 self.assertEqual(len(changesets), 4)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
161
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
162 def test_get_changesets_numerical_id_respects_start(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
163 second_id = 1
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
164 changesets = list(self.repo.get_changesets(start=second_id))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
165 self.assertEqual(len(changesets), 4)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
166
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
167 def test_get_changesets_includes_start_changeset(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
168 second_id = self.repo.revisions[1]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
169 changesets = list(self.repo.get_changesets(start=second_id))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
170 self.assertEqual(changesets[0].raw_id, second_id)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
171
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
172 def test_get_changesets_respects_end(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
173 second_id = self.repo.revisions[1]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
174 changesets = list(self.repo.get_changesets(end=second_id))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
175 self.assertEqual(changesets[-1].raw_id, second_id)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
176 self.assertEqual(len(changesets), 2)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
177
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
178 def test_get_changesets_numerical_id_respects_end(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
179 second_id = 1
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
180 changesets = list(self.repo.get_changesets(end=second_id))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
181 self.assertEqual(changesets.index(changesets[-1]), second_id)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
182 self.assertEqual(len(changesets), 2)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
183
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
184 def test_get_changesets_respects_both_start_and_end(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
185 second_id = self.repo.revisions[1]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
186 third_id = self.repo.revisions[2]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
187 changesets = list(self.repo.get_changesets(start=second_id,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
188 end=third_id))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
189 self.assertEqual(len(changesets), 2)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
190
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
191 def test_get_changesets_numerical_id_respects_both_start_and_end(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
192 changesets = list(self.repo.get_changesets(start=2, end=3))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
193 self.assertEqual(len(changesets), 2)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
194
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
195 def test_get_changesets_includes_end_changeset(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
196 second_id = self.repo.revisions[1]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
197 changesets = list(self.repo.get_changesets(end=second_id))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
198 self.assertEqual(changesets[-1].raw_id, second_id)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
199
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
200 def test_get_changesets_respects_start_date(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
201 start_date = datetime.datetime(2010, 2, 1)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
202 for cs in self.repo.get_changesets(start_date=start_date):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
203 self.assertGreaterEqual(cs.date, start_date)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
204
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
205 def test_get_changesets_respects_end_date(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
206 end_date = datetime.datetime(2010, 2, 1)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
207 for cs in self.repo.get_changesets(end_date=end_date):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
208 self.assertLessEqual(cs.date, end_date)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
209
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
210 def test_get_changesets_respects_reverse(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
211 changesets_id_list = [cs.raw_id for cs in
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
212 self.repo.get_changesets(reverse=True)]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
213 self.assertItemsEqual(changesets_id_list, reversed(self.repo.revisions))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
214
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
215 def test_get_filenodes_generator(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
216 tip = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
217 filepaths = [node.path for node in tip.get_filenodes_generator()]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
218 self.assertItemsEqual(filepaths, ['file_%d.txt' % x for x in xrange(5)])
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
219
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
220 def test_size(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
221 tip = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
222 size = 5 * len('Foobar N') # Size of 5 files
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
223 self.assertEqual(tip.size, size)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
224
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
225 def test_author(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
226 tip = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
227 self.assertEqual(tip.author, u'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
228
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
229 def test_author_name(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
230 tip = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
231 self.assertEqual(tip.author_name, u'Joe Doe')
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
232
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
233 def test_author_email(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
234 tip = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
235 self.assertEqual(tip.author_email, u'joe.doe@example.com')
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
236
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
237 def test_get_changesets_raise_changesetdoesnotexist_for_wrong_start(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
238 with self.assertRaises(ChangesetDoesNotExistError):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
239 list(self.repo.get_changesets(start='foobar'))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
240
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
241 def test_get_changesets_raise_changesetdoesnotexist_for_wrong_end(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
242 with self.assertRaises(ChangesetDoesNotExistError):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
243 list(self.repo.get_changesets(end='foobar'))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
244
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
245 def test_get_changesets_raise_branchdoesnotexist_for_wrong_branch_name(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
246 with self.assertRaises(BranchDoesNotExistError):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
247 list(self.repo.get_changesets(branch_name='foobar'))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
248
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
249 def test_get_changesets_raise_repositoryerror_for_wrong_start_end(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
250 start = self.repo.revisions[-1]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
251 end = self.repo.revisions[0]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
252 with self.assertRaises(RepositoryError):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
253 list(self.repo.get_changesets(start=start, end=end))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
254
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
255 def test_get_changesets_numerical_id_reversed(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
256 with self.assertRaises(RepositoryError):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
257 [x for x in self.repo.get_changesets(start=3, end=2)]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
258
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
259 def test_get_changesets_numerical_id_respects_both_start_and_end_last(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
260 with self.assertRaises(RepositoryError):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
261 last = len(self.repo.revisions)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
262 list(self.repo.get_changesets(start=last-1, end=last-2))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
263
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
264 def test_get_changesets_numerical_id_last_zero_error(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
265 with self.assertRaises(RepositoryError):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
266 last = len(self.repo.revisions)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
267 list(self.repo.get_changesets(start=last-1, end=0))
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
268
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
269
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
270 class ChangesetsChangesTestCaseMixin(BackendTestMixin):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
271 recreate_repo_per_test = False
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
272
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
273 @classmethod
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
274 def _get_commits(cls):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
275 return [
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
276 {
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
277 'message': u'Initial',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
278 'author': u'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
279 '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
280 'added': [
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
281 FileNode('foo/bar', content='foo'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
282 FileNode('foobar', content='foo'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
283 FileNode('qwe', content='foo'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
284 ],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
285 },
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
286 {
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
287 'message': u'Massive changes',
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
288 'author': u'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
289 'date': datetime.datetime(2010, 1, 1, 22),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
290 'added': [FileNode('fallout', content='War never changes')],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
291 'changed': [
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
292 FileNode('foo/bar', content='baz'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
293 FileNode('foobar', content='baz'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
294 ],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
295 'removed': [FileNode('qwe')],
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
296 },
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
297 ]
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
298
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
299 def test_initial_commit(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
300 changeset = self.repo.get_changeset(0)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
301 self.assertItemsEqual(changeset.added, [
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
302 changeset.get_node('foo/bar'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
303 changeset.get_node('foobar'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
304 changeset.get_node('qwe'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
305 ])
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
306 self.assertItemsEqual(changeset.changed, [])
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
307 self.assertItemsEqual(changeset.removed, [])
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
308
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
309 def test_head_added(self):
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
310 changeset = self.repo.get_changeset()
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
311 self.assertItemsEqual(changeset.added, [
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
312 changeset.get_node('fallout'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
313 ])
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
314 self.assertItemsEqual(changeset.changed, [
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
315 changeset.get_node('foo/bar'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
316 changeset.get_node('foobar'),
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
317 ])
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
318 self.assertEqual(len(changeset.removed), 1)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
319 self.assertEqual(list(changeset.removed)[0].path, 'qwe')
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
320
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
321
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
322 # 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
323 for alias in SCM_TESTS:
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
324 attrs = {
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
325 'backend_alias': alias,
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
326 }
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
327 # tests with additional commits
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
328 cls_name = ''.join(('%s changesets with commits test' % alias).title().split())
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
329 bases = (ChangesetsWithCommitsTestCaseixin, unittest.TestCase)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
330 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
331
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
332 # tests without additional commits
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
333 cls_name = ''.join(('%s changesets test' % alias).title().split())
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
334 bases = (ChangesetsTestCaseMixin, unittest.TestCase)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
335 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
336
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
337 # tests changes
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
338 cls_name = ''.join(('%s changesets changes test' % alias).title().split())
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
339 bases = (ChangesetsChangesTestCaseMixin, unittest.TestCase)
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
340 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
341
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
342
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
343 if __name__ == '__main__':
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
344 unittest.main()