Mercurial > kallithea
comparison rhodecode/tests/functional/test_compare.py @ 3645:aef5f5ce5ead beta
use fixtures for forking
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 31 Mar 2013 21:31:36 +0200 |
parents | 2053053e0882 |
children | 8a86836fad64 |
comparison
equal
deleted
inserted
replaced
3644:71860d0737e7 | 3645:aef5f5ce5ead |
---|---|
2 from rhodecode.model.repo import RepoModel | 2 from rhodecode.model.repo import RepoModel |
3 from rhodecode.model.meta import Session | 3 from rhodecode.model.meta import Session |
4 from rhodecode.model.db import Repository | 4 from rhodecode.model.db import Repository |
5 from rhodecode.model.scm import ScmModel | 5 from rhodecode.model.scm import ScmModel |
6 from rhodecode.lib.vcs.backends.base import EmptyChangeset | 6 from rhodecode.lib.vcs.backends.base import EmptyChangeset |
7 | 7 from rhodecode.tests.fixture import Fixture |
8 | 8 |
9 def _fork_repo(fork_name, vcs_type, parent=None): | 9 fixture = Fixture() |
10 if vcs_type =='hg': | |
11 _REPO = HG_REPO | |
12 elif vcs_type == 'git': | |
13 _REPO = GIT_REPO | |
14 | |
15 if parent: | |
16 _REPO = parent | |
17 | |
18 form_data = dict( | |
19 repo_name=fork_name, | |
20 repo_name_full=fork_name, | |
21 repo_group=None, | |
22 repo_type=vcs_type, | |
23 description='', | |
24 private=False, | |
25 copy_permissions=False, | |
26 landing_rev='tip', | |
27 update_after_clone=False, | |
28 fork_parent_id=Repository.get_by_repo_name(_REPO), | |
29 ) | |
30 RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN) | |
31 | |
32 Session().commit() | |
33 return Repository.get_by_repo_name(fork_name) | |
34 | 10 |
35 | 11 |
36 def _commit_change(repo, filename, content, message, vcs_type, parent=None, newfile=False): | 12 def _commit_change(repo, filename, content, message, vcs_type, parent=None, newfile=False): |
37 repo = Repository.get_by_repo_name(repo) | 13 repo = Repository.get_by_repo_name(repo) |
38 _cs = parent | 14 _cs = parent |
84 #commit something ! | 60 #commit something ! |
85 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | 61 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', |
86 message='commit1', vcs_type='hg', parent=None, newfile=True) | 62 message='commit1', vcs_type='hg', parent=None, newfile=True) |
87 | 63 |
88 #fork this repo | 64 #fork this repo |
89 repo2 = _fork_repo('one-fork', 'hg', parent='one') | 65 repo2 = fixture.create_fork('one', 'one-fork') |
90 self.r2_id = repo2.repo_id | 66 self.r2_id = repo2.repo_id |
91 | 67 |
92 #add two extra commit into fork | 68 #add two extra commit into fork |
93 cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n', | 69 cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n', |
94 message='commit2', vcs_type='hg', parent=cs0) | 70 message='commit2', vcs_type='hg', parent=cs0) |
135 #commit something ! | 111 #commit something ! |
136 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | 112 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', |
137 message='commit1', vcs_type='hg', parent=None, newfile=True) | 113 message='commit1', vcs_type='hg', parent=None, newfile=True) |
138 | 114 |
139 #fork this repo | 115 #fork this repo |
140 repo2 = _fork_repo('one-fork', 'hg', parent='one') | 116 repo2 = fixture.create_fork('one', 'one-fork') |
141 self.r2_id = repo2.repo_id | 117 self.r2_id = repo2.repo_id |
142 | 118 |
143 #now commit something to origin repo | 119 #now commit something to origin repo |
144 cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n', | 120 cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n', |
145 message='commit2', vcs_type='hg', parent=cs0, newfile=True) | 121 message='commit2', vcs_type='hg', parent=cs0, newfile=True) |
203 message='commit1', vcs_type='hg', parent=None, | 179 message='commit1', vcs_type='hg', parent=None, |
204 newfile=True) | 180 newfile=True) |
205 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n', | 181 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n', |
206 message='commit2', vcs_type='hg', parent=cs0) | 182 message='commit2', vcs_type='hg', parent=cs0) |
207 #fork this repo | 183 #fork this repo |
208 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1') | 184 repo2 = fixture.create_fork('repo1', 'repo1-fork') |
209 self.r2_id = repo2.repo_id | 185 self.r2_id = repo2.repo_id |
210 #now make cs3-6 | 186 #now make cs3-6 |
211 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n', | 187 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n', |
212 message='commit3', vcs_type='hg', parent=cs1) | 188 message='commit3', vcs_type='hg', parent=cs1) |
213 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n', | 189 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n', |
265 message='commit1', vcs_type='hg', parent=None, | 241 message='commit1', vcs_type='hg', parent=None, |
266 newfile=True) | 242 newfile=True) |
267 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n', | 243 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n', |
268 message='commit2', vcs_type='hg', parent=cs0) | 244 message='commit2', vcs_type='hg', parent=cs0) |
269 #fork this repo | 245 #fork this repo |
270 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1') | 246 repo2 = fixture.create_fork('repo1', 'repo1-fork') |
271 self.r2_id = repo2.repo_id | 247 self.r2_id = repo2.repo_id |
272 #now make cs3-6 | 248 #now make cs3-6 |
273 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n', | 249 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n', |
274 message='commit3', vcs_type='hg', parent=cs1) | 250 message='commit3', vcs_type='hg', parent=cs1) |
275 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n', | 251 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n', |
309 #TODO write this tastecase | 285 #TODO write this tastecase |
310 | 286 |
311 def test_compare_remote_branches_hg(self): | 287 def test_compare_remote_branches_hg(self): |
312 self.log_user() | 288 self.log_user() |
313 | 289 |
314 repo2 = _fork_repo(HG_FORK, 'hg') | 290 repo2 = fixture.create_fork(HG_REPO, HG_FORK) |
315 self.r2_id = repo2.repo_id | 291 self.r2_id = repo2.repo_id |
316 rev1 = '56349e29c2af' | 292 rev1 = '56349e29c2af' |
317 rev2 = '7d4bc8ec6be5' | 293 rev2 = '7d4bc8ec6be5' |
318 | 294 |
319 response = self.app.get(url(controller='compare', action='index', | 295 response = self.app.get(url(controller='compare', action='index', |