Esempio n. 1
0
    def test_create_hg_non_ascii(self):
        self.log_user()
        non_ascii = "ąęł"
        repo_name = "%s%s" % (NEW_HG_REPO, non_ascii)
        repo_name_unicode = repo_name.decode('utf8')
        description = 'description for newly created repo' + non_ascii
        description_unicode = description.decode('utf8')
        private = False
        response = self.app.post(url('repos'),
                        fixture._get_repo_create_params(repo_private=False,
                                                repo_name=repo_name,
                                                repo_description=description))
        self.checkSessionFlash(response,
                               u'Created repository <a href="/%s">%s</a>'
                               % (urllib.quote(repo_name), repo_name_unicode))
        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name_unicode).one()

        self.assertEqual(new_repo.repo_name, repo_name_unicode)
        self.assertEqual(new_repo.description, description_unicode)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except Exception:
            self.fail('no repo %s in filesystem' % repo_name)
Esempio n. 2
0
    def test_create_git(self):
        self.log_user()
        repo_name = NEW_GIT_REPO
        description = 'description for newly created repo'

        response = self.app.post(url('repos'),
                        fixture._get_repo_create_params(repo_private=False,
                                                repo_type='git',
                                                repo_name=repo_name,
                                                repo_description=description))
        self.checkSessionFlash(response,
                               'Created repository <a href="/%s">%s</a>'
                               % (repo_name, repo_name))

        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name).one()

        self.assertEqual(new_repo.repo_name, repo_name)
        self.assertEqual(new_repo.description, description)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except Exception:
            self.fail('no repo %s in filesystem' % repo_name)
Esempio n. 3
0
    def test_create_git(self):
        return
        self.log_user()
        repo_name = NEW_GIT_REPO
        description = 'description for newly created repo'
        private = False
        response = self.app.post(url('repos'), {'repo_name':repo_name,
                                                'repo_type':'git',
                                                'clone_uri':'',
                                                'repo_group':'',
                                                'description':description,
                                                'private':private})


        #test if we have a message for that repository
        assert '''created repository %s''' % (repo_name) in response.session['flash'][0], 'No flash message about new repo'

        #test if the fork was created in the database
        new_repo = self.Session.query(Repository).filter(Repository.repo_name == repo_name).one()

        assert new_repo.repo_name == repo_name, 'wrong name of repo name in db'
        assert new_repo.description == description, 'wrong description'

        #test if repository is visible in the list ?
        response = response.follow()

        assert repo_name in response.body, 'missing new repo from the main repos list'

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except:
            assert False , 'no repo in filesystem'
Esempio n. 4
0
    def test_create_hg_non_ascii(self):
        self.log_user()
        non_ascii = "ąęł"
        repo_name = "%s%s" % (NEW_HG_REPO, non_ascii)
        repo_name_unicode = repo_name.decode('utf8')
        description = 'description for newly created repo' + non_ascii
        description_unicode = description.decode('utf8')
        private = False
        response = self.app.post(url('repos'), {'repo_name':repo_name,
                                                'repo_type':'hg',
                                                'clone_uri':'',
                                                'repo_group':'',
                                                'description':description,
                                                'private':private})
        self.checkSessionFlash(response,
                               'created repository %s' % (repo_name_unicode))

        #test if the repo was created in the database
        new_repo = self.Session.query(Repository).filter(Repository.repo_name ==
                                                repo_name_unicode).one()

        self.assertEqual(new_repo.repo_name, repo_name_unicode)
        self.assertEqual(new_repo.description, description_unicode)

        #test if repository is visible in the list ?
        response = response.follow()

        self.assertTrue(repo_name in response.body)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except:
            self.fail('no repo in filesystem')
Esempio n. 5
0
    def test_create_hg_non_ascii(self):
        self.log_user()
        non_ascii = "ąęł"
        repo_name = "%s%s" % (NEW_HG_REPO, non_ascii)
        repo_name_unicode = repo_name.decode('utf8')
        description = 'description for newly created repo' + non_ascii
        description_unicode = description.decode('utf8')
        private = False
        response = self.app.post(url('repos'), {'repo_name': repo_name,
                                                'repo_type': 'hg',
                                                'clone_uri': '',
                                                'repo_group': '',
                                                'description': description,
                                                'private': private,
                                                'landing_rev': 'tip'})
        self.checkSessionFlash(response,
                               'created repository %s' % (repo_name_unicode))

        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name_unicode).one()

        self.assertEqual(new_repo.repo_name, repo_name_unicode)
        self.assertEqual(new_repo.description, description_unicode)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except:
            self.fail('no repo %s in filesystem' % repo_name)
Esempio n. 6
0
    def test_create_git(self):
        self.log_user()
        repo_name = NEW_GIT_REPO
        description = 'description for newly created repo'

        response = self.app.post(
            url('repos'),
            fixture._get_repo_create_params(repo_private=False,
                                            repo_type='git',
                                            repo_name=repo_name,
                                            repo_description=description))
        self.checkSessionFlash(
            response,
            'Created repository <a href="/%s">%s</a>' % (repo_name, repo_name))

        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name).one()

        self.assertEqual(new_repo.repo_name, repo_name)
        self.assertEqual(new_repo.description, description)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except Exception:
            self.fail('no repo %s in filesystem' % repo_name)
Esempio n. 7
0
    def test_create_hg_non_ascii(self):
        self.log_user()
        non_ascii = "ąęł"
        repo_name = "%s%s" % (NEW_HG_REPO, non_ascii)
        repo_name_unicode = repo_name.decode('utf8')
        description = 'description for newly created repo' + non_ascii
        description_unicode = description.decode('utf8')
        private = False
        response = self.app.post(
            url('repos'),
            fixture._get_repo_create_params(repo_private=False,
                                            repo_name=repo_name,
                                            repo_description=description))
        self.checkSessionFlash(
            response, u'Created repository <a href="/%s">%s</a>' %
            (urllib.quote(repo_name), repo_name_unicode))
        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name_unicode).one()

        self.assertEqual(new_repo.repo_name, repo_name_unicode)
        self.assertEqual(new_repo.description, description_unicode)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except Exception:
            self.fail('no repo %s in filesystem' % repo_name)
Esempio n. 8
0
    def test_create_hg(self):
        self.log_user()
        repo_name = NEW_HG_REPO
        description = "description for newly created repo"
        private = False
        response = self.app.post(
            url("repos"),
            {
                "repo_name": repo_name,
                "repo_type": "hg",
                "clone_uri": "",
                "repo_group": "",
                "description": description,
                "private": private,
            },
        )
        self.checkSessionFlash(response, "created repository %s" % (repo_name))

        # test if the repo was created in the database
        new_repo = self.Session.query(Repository).filter(Repository.repo_name == repo_name).one()

        self.assertEqual(new_repo.repo_name, repo_name)
        self.assertEqual(new_repo.description, description)

        # test if repository is visible in the list ?
        response = response.follow()

        self.assertTrue(repo_name in response.body)

        # test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except:
            self.fail("no repo in filesystem")
Esempio n. 9
0
def test_get_repo_autoalias_hg():
    alias = 'hg'
    path = TEST_HG_REPO
    backend = get_backend(alias)
    repo = backend(path)

    assert repo.__class__ == get_repo(path).__class__
    assert repo.path == get_repo(path).path
Esempio n. 10
0
def test_get_repo():
    alias = 'hg'
    path = TEST_HG_REPO
    backend = get_backend(alias)
    repo = backend(path)

    assert repo.__class__, get_repo(path == alias).__class__
    assert repo.path, get_repo(path == alias).path
Esempio n. 11
0
def test_get_repo_autoalias_git():
    alias = 'git'
    path = TEST_GIT_REPO
    backend = get_backend(alias)
    repo = backend(path)

    assert repo.__class__ == get_repo(path).__class__
    assert repo.path == get_repo(path).path
Esempio n. 12
0
    def test_get_repo_autoalias_git(self):
        alias = 'git'
        path = TEST_GIT_REPO
        backend = get_backend(alias)
        repo = backend(path)

        self.assertEqual(repo.__class__, get_repo(path).__class__)
        self.assertEqual(repo.path, get_repo(path).path)
Esempio n. 13
0
    def test_get_repo(self):
        alias = 'hg'
        path = TEST_HG_REPO
        backend = get_backend(alias)
        repo = backend(path)

        self.assertEqual(repo.__class__, get_repo(path, alias).__class__)
        self.assertEqual(repo.path, get_repo(path, alias).path)
Esempio n. 14
0
    def test_create_hg_in_group(self):
        self.log_user()

        ## create GROUP
        group_name = 'sometest'
        gr = ReposGroupModel().create(group_name=group_name,
                                      group_description='test',
                                      owner=TEST_USER_ADMIN_LOGIN)
        self.Session().commit()

        repo_name = 'ingroup'
        repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
        description = 'description for newly created repo'
        response = self.app.post(
            url('repos'),
            fixture._get_repo_create_params(
                repo_private=False,
                repo_name=repo_name,
                repo_description=description,
                repo_group=gr.group_id,
            ))

        self.checkSessionFlash(
            response, 'Created repository <a href="/%s">%s</a>' %
            (repo_name_full, repo_name))
        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name_full).one()

        self.assertEqual(new_repo.repo_name, repo_name_full)
        self.assertEqual(new_repo.description, description)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name_full)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name_full))
        except Exception:
            ReposGroupModel().delete(group_name)
            self.Session().commit()
            self.fail('no repo %s in filesystem' % repo_name)

        RepoModel().delete(repo_name_full)
        ReposGroupModel().delete(group_name)
        self.Session().commit()
Esempio n. 15
0
    def test_delete_git(self):
        self.log_user()
        repo_name = 'vcs_test_new_to_delete'
        description = 'description for newly created repo'
        private = False
        response = self.app.post(url('repos'), {'repo_name': repo_name,
                                                'repo_type': 'git',
                                                'clone_uri': '',
                                                'repo_group': '',
                                                'description': description,
                                                'private': private,
                                                'landing_rev': 'tip'})
        self.checkSessionFlash(response,
                               'created repository %s' % (repo_name))

        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name).one()

        self.assertEqual(new_repo.repo_name, repo_name)
        self.assertEqual(new_repo.description, description)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except:
            self.fail('no repo %s in filesystem' % repo_name)

        response = self.app.delete(url('repo', repo_name=repo_name))

        self.assertTrue('''deleted repository %s''' % (repo_name) in
                        response.session['flash'][0])

        response.follow()

        #check if repo was deleted from db
        deleted_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name).scalar()

        self.assertEqual(deleted_repo, None)

        self.assertEqual(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)),
                                  False)
Esempio n. 16
0
    def test_delete_hg(self):
        self.log_user()
        repo_name = 'vcs_test_new_to_delete'
        description = 'description for newly created repo'
        response = self.app.post(
            url('repos'),
            fixture._get_repo_create_params(repo_private=False,
                                            repo_type='hg',
                                            repo_name=repo_name,
                                            repo_description=description))

        self.checkSessionFlash(
            response,
            'Created repository <a href="/%s">%s</a>' % (repo_name, repo_name))
        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name).one()

        self.assertEqual(new_repo.repo_name, repo_name)
        self.assertEqual(new_repo.description, description)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except Exception:
            self.fail('no repo %s in filesystem' % repo_name)

        response = self.app.delete(url('repo', repo_name=repo_name))

        self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name))

        response.follow()

        #check if repo was deleted from db
        deleted_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name).scalar()

        self.assertEqual(deleted_repo, None)

        self.assertEqual(
            os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)), False)
Esempio n. 17
0
    def test_create_hg_in_group(self):
        self.log_user()

        ## create GROUP
        group_name = 'sometest'
        gr = ReposGroupModel().create(group_name=group_name,
                                      group_description='test',)
        self.Session().commit()

        repo_name = 'ingroup'
        repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
        description = 'description for newly created repo'
        private = False
        response = self.app.post(url('repos'), {'repo_name': repo_name,
                                                'repo_type': 'hg',
                                                'clone_uri': '',
                                                'repo_group': gr.group_id,
                                                'description': description,
                                                'private': private,
                                                'landing_rev': 'tip'})
        self.checkSessionFlash(response,
                               'created repository %s' % (repo_name))

        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name_full).one()

        self.assertEqual(new_repo.repo_name, repo_name_full)
        self.assertEqual(new_repo.description, description)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name_full)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name_full))
        except:
            ReposGroupModel().delete(group_name)
            self.Session().commit()
            self.fail('no repo %s in filesystem' % repo_name)

        RepoModel().delete(repo_name_full)
        ReposGroupModel().delete(group_name)
        self.Session().commit()
Esempio n. 18
0
    def test_delete_hg(self):
        self.log_user()
        repo_name = 'vcs_test_new_to_delete'
        description = 'description for newly created repo'
        response = self.app.post(url('repos'),
                        fixture._get_repo_create_params(repo_private=False,
                                                repo_type='hg',
                                                repo_name=repo_name,
                                                repo_description=description))

        self.checkSessionFlash(response,
                               'Created repository <a href="/%s">%s</a>'
                               % (repo_name, repo_name))
        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name).one()

        self.assertEqual(new_repo.repo_name, repo_name)
        self.assertEqual(new_repo.description, description)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except Exception:
            self.fail('no repo %s in filesystem' % repo_name)

        response = self.app.delete(url('repo', repo_name=repo_name))

        self.checkSessionFlash(response, 'Deleted repository %s' % (repo_name))

        response.follow()

        #check if repo was deleted from db
        deleted_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name).scalar()

        self.assertEqual(deleted_repo, None)

        self.assertEqual(os.path.isdir(os.path.join(TESTS_TMP_PATH, repo_name)),
                                  False)
Esempio n. 19
0
    def test_create_hg_in_group(self):
        self.log_user()

        ## create GROUP
        group_name = 'sometest'
        gr = ReposGroupModel().create(group_name=group_name,
                                      group_description='test',
                                      owner=TEST_USER_ADMIN_LOGIN)
        self.Session().commit()

        repo_name = 'ingroup'
        repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
        description = 'description for newly created repo'
        response = self.app.post(url('repos'),
                        fixture._get_repo_create_params(repo_private=False,
                                                repo_name=repo_name,
                                                repo_description=description,
                                                repo_group=gr.group_id,))

        self.checkSessionFlash(response,
                               'Created repository <a href="/%s">%s</a>'
                               % (repo_name_full, repo_name))
        #test if the repo was created in the database
        new_repo = self.Session().query(Repository)\
            .filter(Repository.repo_name == repo_name_full).one()

        self.assertEqual(new_repo.repo_name, repo_name_full)
        self.assertEqual(new_repo.description, description)

        #test if repository is visible in the list ?
        response = response.follow()

        response.mustcontain(repo_name_full)

        #test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name_full))
        except Exception:
            ReposGroupModel().delete(group_name)
            self.Session().commit()
            self.fail('no repo %s in filesystem' % repo_name)

        RepoModel().delete(repo_name_full)
        ReposGroupModel().delete(group_name)
        self.Session().commit()
Esempio n. 20
0
def _get_repo(proj):
    if isinstance(proj, basestring):
        repo = vcs.get_repo(jn(PROJECT_PATH, proj))
        proj = proj
    else:
        repo = proj
        proj = repo.name

    return repo, proj
Esempio n. 21
0
    def test_create_git(self):
        return
        self.log_user()
        repo_name = NEW_GIT_REPO
        description = "description for newly created repo"
        private = False
        response = self.app.post(
            url("repos"),
            {
                "repo_name": repo_name,
                "repo_type": "git",
                "clone_uri": "",
                "repo_group": "",
                "description": description,
                "private": private,
            },
        )

        # test if we have a message for that repository
        assert (
            """created repository %s""" % (repo_name) in response.session["flash"][0]
        ), "No flash message about new repo"

        # test if the fork was created in the database
        new_repo = self.Session.query(Repository).filter(Repository.repo_name == repo_name).one()

        assert new_repo.repo_name == repo_name, "wrong name of repo name in db"
        assert new_repo.description == description, "wrong description"

        # test if repository is visible in the list ?
        response = response.follow()

        assert repo_name in response.body, "missing new repo from the main repos list"

        # test if repository was created on filesystem
        try:
            vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        except:
            assert False, "no repo in filesystem"
Esempio n. 22
0
def get_current_revision(quiet=False):
    """
    Returns tuple of (number, id) from repository containing this package
    or None if repository could not be found.

    :param quiet: prints error for fetching revision if True
    """

    try:
        from rhodecode.lib.vcs import get_repo
        from rhodecode.lib.vcs.utils.helpers import get_scm
        repopath = os.path.join(os.path.dirname(__file__), '..', '..')
        scm = get_scm(repopath)[0]
        repo = get_repo(path=repopath, alias=scm)
        tip = repo.get_changeset()
        return (tip.revision, tip.short_id)
    except Exception, err:
        if not quiet:
            print("Cannot retrieve rhodecode's revision. Original error "
                  "was: %s" % err)
        return None
Esempio n. 23
0
def get_current_revision(quiet=False):
    """
    Returns tuple of (number, id) from repository containing this package
    or None if repository could not be found.

    :param quiet: prints error for fetching revision if True
    """

    try:
        from rhodecode.lib.vcs import get_repo
        from rhodecode.lib.vcs.utils.helpers import get_scm
        repopath = os.path.join(os.path.dirname(__file__), '..', '..')
        scm = get_scm(repopath)[0]
        repo = get_repo(path=repopath, alias=scm)
        tip = repo.get_changeset()
        return (tip.revision, tip.short_id)
    except Exception, err:
        if not quiet:
            print ("Cannot retrieve rhodecode's revision. Original error "
                   "was: %s" % err)
        return None
Esempio n. 24
0
def get_current_revision(quiet=False):
    """
    Returns tuple of (number, id) from repository containing this package
    or None if repository could not be found.

    :param quiet: prints error for fetching revision if True
    """

    try:
        from rhodecode.lib.vcs import get_repo
        from rhodecode.lib.vcs.utils.helpers import get_scm
        repopath = os.path.abspath(os.path.join(os.path.dirname(__file__),
                                                '..', '..'))
        scm = get_scm(repopath)[0]
        repo = get_repo(path=repopath, alias=scm)
        wk_dir = repo.workdir
        cur_rev = wk_dir.get_changeset()
        return (cur_rev.revision, cur_rev.short_id)
    except Exception, err:
        if not quiet:
            print ("WARNING: Cannot retrieve rhodecode's revision. "
                   "disregard this if you don't know what that means. "
                   "Original error was: %s" % err)
        return None
def repo_on_filesystem(repo_name):
    try:
        vcs.get_repo(os.path.join(TESTS_TMP_PATH, repo_name))
        return True
    except Exception:
        return False
Esempio n. 26
0
    except RepositoryError, e:
        pass

    cnt = 0
    for f in paths_:
        cnt += 1
        if limit and limit == cnt:
            break

        file_path = '/'.join((proj, 'files', 'tip', f))
        full_uri = (BASE_URI % file_path)
        print '%s visiting %s' % (cnt, full_uri)
        s = time.time()
        f = o.open(full_uri)
        size = len(f.read())
        e = time.time() - s
        total_time += e
        print '%s visited OK size:%s req:%s ms' % (cnt, size, e)

    print 'total_time', total_time
    print 'average on req', total_time / float(cnt)

if __name__ == '__main__':
    for path in PROJECTS:
        repo = vcs.get_repo(jn(PROJECT_PATH, path))
        for i in range(PASES):
            print 'PASS %s/%s' % (i, PASES)
            test_changelog_walk(repo, pages=80)
            test_changeset_walk(repo, limit=100)
            test_files_walk(repo, limit=100)