Changeset - aef5f5ce5ead
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2013-03-31 21:31:36
marcin@python-works.com
use fixtures for forking
2 files changed with 7 insertions and 34 deletions:
0 comments (0 inline, 0 general)
rhodecode/tests/functional/test_admin_repos.py
Show inline comments
 
@@ -20,15 +20,12 @@ def _get_permission_for_user(user, repo)
 
                .all()
 
    return perm
 

	
 

	
 
class TestAdminReposController(TestController):
 

	
 
    def __make_repo(self):
 
        pass
 

	
 
    def test_index(self):
 
        self.log_user()
 
        response = self.app.get(url('repos'))
 
        # Test response...
 

	
 
    def test_index_as_xml(self):
rhodecode/tests/functional/test_compare.py
Show inline comments
 
from rhodecode.tests import *
 
from rhodecode.model.repo import RepoModel
 
from rhodecode.model.meta import Session
 
from rhodecode.model.db import Repository
 
from rhodecode.model.scm import ScmModel
 
from rhodecode.lib.vcs.backends.base import EmptyChangeset
 

	
 

	
 
def _fork_repo(fork_name, vcs_type, parent=None):
 
    if vcs_type =='hg':
 
        _REPO = HG_REPO
 
    elif vcs_type == 'git':
 
        _REPO = GIT_REPO
 

	
 
    if parent:
 
        _REPO = parent
 
from rhodecode.tests.fixture import Fixture
 

	
 
    form_data = dict(
 
        repo_name=fork_name,
 
        repo_name_full=fork_name,
 
        repo_group=None,
 
        repo_type=vcs_type,
 
        description='',
 
        private=False,
 
        copy_permissions=False,
 
        landing_rev='tip',
 
        update_after_clone=False,
 
        fork_parent_id=Repository.get_by_repo_name(_REPO),
 
    )
 
    RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN)
 

	
 
    Session().commit()
 
    return Repository.get_by_repo_name(fork_name)
 
fixture = Fixture()
 

	
 

	
 
def _commit_change(repo, filename, content, message, vcs_type, parent=None, newfile=False):
 
    repo = Repository.get_by_repo_name(repo)
 
    _cs = parent
 
    if not parent:
 
@@ -83,13 +59,13 @@ class TestCompareController(TestControll
 
        self.r1_id = repo1.repo_id
 
        #commit something !
 
        cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None, newfile=True)
 

	
 
        #fork this repo
 
        repo2 = _fork_repo('one-fork', 'hg', parent='one')
 
        repo2 = fixture.create_fork('one', 'one-fork')
 
        self.r2_id = repo2.repo_id
 

	
 
        #add two extra commit into fork
 
        cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
 
                             message='commit2', vcs_type='hg', parent=cs0)
 

	
 
@@ -134,13 +110,13 @@ class TestCompareController(TestControll
 

	
 
        #commit something !
 
        cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None, newfile=True)
 

	
 
        #fork this repo
 
        repo2 = _fork_repo('one-fork', 'hg', parent='one')
 
        repo2 = fixture.create_fork('one', 'one-fork')
 
        self.r2_id = repo2.repo_id
 

	
 
        #now commit something to origin repo
 
        cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n',
 
                                  message='commit2', vcs_type='hg', parent=cs0, newfile=True)
 

	
 
@@ -202,13 +178,13 @@ class TestCompareController(TestControll
 
        cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None,
 
                             newfile=True)
 
        cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n',
 
                             message='commit2', vcs_type='hg', parent=cs0)
 
        #fork this repo
 
        repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1')
 
        repo2 = fixture.create_fork('repo1', 'repo1-fork')
 
        self.r2_id = repo2.repo_id
 
        #now make cs3-6
 
        cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n',
 
                             message='commit3', vcs_type='hg', parent=cs1)
 
        cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n',
 
                             message='commit4', vcs_type='hg', parent=cs2)
 
@@ -264,13 +240,13 @@ class TestCompareController(TestControll
 
        cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
 
                             message='commit1', vcs_type='hg', parent=None,
 
                             newfile=True)
 
        cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n',
 
                             message='commit2', vcs_type='hg', parent=cs0)
 
        #fork this repo
 
        repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1')
 
        repo2 = fixture.create_fork('repo1', 'repo1-fork')
 
        self.r2_id = repo2.repo_id
 
        #now make cs3-6
 
        cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n',
 
                             message='commit3', vcs_type='hg', parent=cs1)
 
        cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n',
 
                             message='commit4', vcs_type='hg', parent=cs2)
 
@@ -308,13 +284,13 @@ class TestCompareController(TestControll
 
        pass
 
        #TODO write this tastecase
 

	
 
    def test_compare_remote_branches_hg(self):
 
        self.log_user()
 

	
 
        repo2 = _fork_repo(HG_FORK, 'hg')
 
        repo2 = fixture.create_fork(HG_REPO, HG_FORK)
 
        self.r2_id = repo2.repo_id
 
        rev1 = '56349e29c2af'
 
        rev2 = '7d4bc8ec6be5'
 

	
 
        response = self.app.get(url(controller='compare', action='index',
 
                                    repo_name=HG_REPO,
0 comments (0 inline, 0 general)