Changeset - bc7fb3e8d77e
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2013-03-06 14:14:57
marcin@python-works.com
again they channged git return commands :/ and i need to fix the tests. Now running agains 1.8.1
1 file changed with 10 insertions and 8 deletions:
0 comments (0 inline, 0 general)
rhodecode/tests/scripts/test_vcs_operations.py
Show inline comments
 
# -*- coding: utf-8 -*-
 
"""
 
    rhodecode.tests.test_scm_operations
 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

	
 
    Test suite for making push/pull operations.
 
    Run using::
 
    Run using after doing paster serve test.ini::
 
     RC_WHOOSH_TEST_DISABLE=1 RC_NO_TMP_PATH=1 nosetests rhodecode/tests/scripts/test_vcs_operations.py
 

	
 
     RC_WHOOSH_TEST_DISABLE=1 RC_NO_TMP_PATH=1 nosetests rhodecode/tests/scripts/test_vcs_operations.py
 
    You must have git > 1.8.1 for tests to work fine
 

	
 
    :created_on: Dec 30, 2010
 
    :author: marcink
 
    :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com>
 
    :license: GPLv3, see COPYING for more details.
 
"""
 
@@ -104,19 +105,20 @@ def _add_files_and_push(vcs, DEST, **kwa
 
    Command(cwd).execute('touch %s' % added_file)
 
    Command(cwd).execute('%s add %s' % (vcs, added_file))
 

	
 
    for i in xrange(3):
 
        cmd = """echo 'added_line%s' >> %s""" % (i, added_file)
 
        Command(cwd).execute(cmd)
 
        author_str = 'Marcin Kuźminski <me@email.com>'
 
        if vcs == 'hg':
 
            cmd = """hg commit -m 'commited new %s' -u '%s' %s """ % (
 
                i, 'Marcin Kuźminski <marcin@python-blog.com>', added_file
 
                i, author_str, added_file
 
            )
 
        elif vcs == 'git':
 
            cmd = """git commit -m 'commited new %s' --author '%s' %s """ % (
 
                i, 'Marcin Kuźminski <marcin@python-blog.com>', added_file
 
                i, author_str, added_file
 
            )
 
        Command(cwd).execute(cmd)
 
    # PUSH it back
 
    if vcs == 'hg':
 
        _REPO = HG_REPO
 
    elif vcs == 'git':
 
@@ -126,13 +128,13 @@ def _add_files_and_push(vcs, DEST, **kwa
 
    clone_url = _construct_url(_REPO, **kwargs)
 
    if 'clone_url' in kwargs:
 
        clone_url = kwargs['clone_url']
 
    if vcs == 'hg':
 
        stdout, stderr = Command(cwd).execute('hg push --verbose', clone_url)
 
    elif vcs == 'git':
 
        stdout, stderr = Command(cwd).execute('git push', clone_url + " master")
 
        stdout, stderr = Command(cwd).execute('git push --verbose', clone_url + " master")
 

	
 
    return stdout, stderr
 

	
 

	
 
def set_anonymous_access(enable=True):
 
    user = User.get_by_username(User.DEFAULT_USER)
 
@@ -321,14 +323,13 @@ class TestVCSOperations(unittest.TestCas
 
        #lock repo
 
        r = Repository.get_by_repo_name(GIT_REPO)
 
        Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id)
 
        #pull fails since repo is locked
 
        clone_url = _construct_url(GIT_REPO)
 
        stdout, stderr = Command('/tmp').execute('git clone', clone_url)
 
        msg = ("""423 Repository `%s` locked by user `%s`"""
 
                % (GIT_REPO, TEST_USER_ADMIN_LOGIN))
 
        msg = ("""The requested URL returned error: 423""")
 
        assert msg in stderr
 

	
 
    def test_push_on_locked_repo_by_other_user_hg(self):
 
        #clone some temp
 
        DEST = _get_tmp_dir()
 
        clone_url = _construct_url(HG_REPO, dest=DEST)
 
@@ -452,13 +453,14 @@ class TestVCSOperations(unittest.TestCas
 
        user_model = UserModel()
 
        try:
 
            user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32')
 
            Session().commit()
 
            clone_url = _construct_url(GIT_REPO)
 
            stdout, stderr = Command('/tmp').execute('git clone', clone_url)
 
            assert 'error: The requested URL returned error: 403 Forbidden' in stderr
 
            msg = ("""The requested URL returned error: 403""")
 
            assert msg in stderr
 
        finally:
 
            #release IP restrictions
 
            for ip in UserIpMap.getAll():
 
                UserIpMap.delete(ip.ip_id)
 
            Session().commit()
 

	
0 comments (0 inline, 0 general)