Changeset - e63bcce18fef
[Not reviewed]
default
! ! !
Mads Kiilerich - 6 years ago 2020-02-06 02:57:51
mads@kiilerich.com
py3: automatic migration with 2to3 -f unicode
73 files changed with 774 insertions and 774 deletions:
0 comments (0 inline, 0 general)
docs/conf.py
Show inline comments
 
@@ -46,8 +46,8 @@ source_suffix = '.rst'
 
master_doc = 'index'
 

	
 
# General information about the project.
 
project = u'Kallithea'
 
copyright = u'2010-2020 by various authors, licensed as GPLv3.'
 
project = 'Kallithea'
 
copyright = '2010-2020 by various authors, licensed as GPLv3.'
 

	
 
# The version info for the project you're documenting, acts as replacement for
 
# |version| and |release|, also used in various other places throughout the
 
@@ -187,8 +187,8 @@ htmlhelp_basename = 'Kallithea-docs'
 
# Grouping the document tree into LaTeX files. List of tuples
 
# (source start file, target name, title, author, documentclass [howto/manual]).
 
latex_documents = [
 
  ('index', 'Kallithea.tex', u'Kallithea Documentation',
 
   u'Kallithea Developers', 'manual'),
 
  ('index', 'Kallithea.tex', 'Kallithea Documentation',
 
   'Kallithea Developers', 'manual'),
 
]
 

	
 
# The name of an image file (relative to this directory) to place at the top of
 
@@ -220,8 +220,8 @@ latex_documents = [
 
# One entry per manual page. List of tuples
 
# (source start file, name, description, authors, manual section).
 
man_pages = [
 
    ('index', 'kallithea', u'Kallithea Documentation',
 
     [u'Kallithea Developers'], 1)
 
    ('index', 'kallithea', 'Kallithea Documentation',
 
     ['Kallithea Developers'], 1)
 
]
 

	
 

	
kallithea/controllers/api/api.py
Show inline comments
 
@@ -433,7 +433,7 @@ class ApiController(JSONRPCController):
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def create_user(self, username, email, password=Optional(''),
 
                    firstname=Optional(u''), lastname=Optional(u''),
 
                    firstname=Optional(''), lastname=Optional(''),
 
                    active=Optional(True), admin=Optional(False),
 
                    extern_type=Optional(User.DEFAULT_AUTH_TYPE),
 
                    extern_name=Optional('')):
 
@@ -686,7 +686,7 @@ class ApiController(JSONRPCController):
 
        ]
 

	
 
    @HasPermissionAnyDecorator('hg.admin', 'hg.usergroup.create.true')
 
    def create_user_group(self, group_name, description=Optional(u''),
 
    def create_user_group(self, group_name, description=Optional(''),
 
                          owner=Optional(OAttr('apiuser')), active=Optional(True)):
 
        """
 
        Creates new user group. This command can be executed only using api_key
 
@@ -2373,7 +2373,7 @@ class ApiController(JSONRPCController):
 
        return pull_request.get_api_data()
 

	
 
    # permission check inside
 
    def comment_pullrequest(self, pull_request_id, comment_msg=u'', status=None, close_pr=False):
 
    def comment_pullrequest(self, pull_request_id, comment_msg='', status=None, close_pr=False):
 
        """
 
        Add comment, close and change status of pull request.
 
        """
kallithea/controllers/search.py
Show inline comments
 
@@ -94,7 +94,7 @@ class SearchController(BaseRepoControlle
 
                if c.repo_name:
 
                    # use "repository_rawname:" instead of "repository:"
 
                    # for case-sensitive matching
 
                    cur_query = u'repository_rawname:%s %s' % (c.repo_name, cur_query)
 
                    cur_query = 'repository_rawname:%s %s' % (c.repo_name, cur_query)
 
                try:
 
                    query = qp.parse(cur_query)
 
                    # extract words for highlight
kallithea/lib/auth_modules/__init__.py
Show inline comments
 
@@ -286,11 +286,11 @@ def loadplugin(plugin):
 
        ImportError -- if we couldn't import the plugin at all
 
    """
 
    log.debug("Importing %s", plugin)
 
    if not plugin.startswith(u'kallithea.lib.auth_modules.auth_'):
 
        parts = plugin.split(u'.lib.auth_modules.auth_', 1)
 
    if not plugin.startswith('kallithea.lib.auth_modules.auth_'):
 
        parts = plugin.split('.lib.auth_modules.auth_', 1)
 
        if len(parts) == 2:
 
            _module, pn = parts
 
            plugin = u'kallithea.lib.auth_modules.auth_' + pn
 
            plugin = 'kallithea.lib.auth_modules.auth_' + pn
 
    PLUGIN_CLASS_NAME = "KallitheaAuthPlugin"
 
    try:
 
        module = importlib.import_module(plugin)
kallithea/lib/db_manage.py
Show inline comments
 
@@ -385,7 +385,7 @@ class DbManage(object):
 
    def create_user(self, username, password, email='', admin=False):
 
        log.info('creating user %s', username)
 
        UserModel().create_or_update(username, password, email,
 
                                     firstname=u'Kallithea', lastname=u'Admin',
 
                                     firstname='Kallithea', lastname='Admin',
 
                                     active=True, admin=admin,
 
                                     extern_type=User.DEFAULT_AUTH_TYPE)
 

	
 
@@ -395,8 +395,8 @@ class DbManage(object):
 
        user = UserModel().create_or_update(username=User.DEFAULT_USER,
 
                                            password=str(uuid.uuid1())[:20],
 
                                            email='anonymous@kallithea-scm.org',
 
                                            firstname=u'Anonymous',
 
                                            lastname=u'User')
 
                                            firstname='Anonymous',
 
                                            lastname='User')
 
        # based on configuration options activate/deactivate this user which
 
        # controls anonymous access
 
        if self.cli_args.get('public_access') is False:
kallithea/lib/feeds.py
Show inline comments
 
@@ -59,7 +59,7 @@ def get_tag_uri(url, date):
 
    if date is not None:
 
        tag = re.sub('/', ',%s:/' % date.strftime('%Y-%m-%d'), tag, 1)
 
    tag = re.sub('#', '/', tag)
 
    return u'tag:' + tag
 
    return 'tag:' + tag
 

	
 

	
 
class Attributes(object):
kallithea/lib/indexers/__init__.py
Show inline comments
 
@@ -203,7 +203,7 @@ class WhooshResultWrapper(object):
 
        return res
 

	
 
    def get_short_content(self, res, chunks):
 
        return u''.join([res['content'][chunk[0]:chunk[1]] for chunk in chunks])
 
        return ''.join([res['content'][chunk[0]:chunk[1]] for chunk in chunks])
 

	
 
    def get_chunks(self):
 
        """
kallithea/lib/indexers/daemon.py
Show inline comments
 
@@ -181,7 +181,7 @@ class WhooshIndexingDaemon(object):
 
            bytes_content = node.content
 
            if b'\0' in bytes_content:
 
                log.warning('    >> %s - no text content', path)
 
                u_content = u''
 
                u_content = ''
 
            else:
 
                log.debug('    >> %s', path)
 
                u_content = safe_str(bytes_content)
 
@@ -190,7 +190,7 @@ class WhooshIndexingDaemon(object):
 
        else:
 
            log.debug('    >> %s - not indexable', path)
 
            # just index file name without it's content
 
            u_content = u''
 
            u_content = ''
 
            indexed += 1
 

	
 
        writer.add_document(
 
@@ -241,10 +241,10 @@ class WhooshIndexingDaemon(object):
 
                author=cs.author,
 
                message=cs.message,
 
                last=cs.last,
 
                added=u' '.join(node.path for node in cs.added).lower(),
 
                removed=u' '.join(node.path for node in cs.removed).lower(),
 
                changed=u' '.join(node.path for node in cs.changed).lower(),
 
                parents=u' '.join(cs.raw_id for cs in cs.parents),
 
                added=' '.join(node.path for node in cs.added).lower(),
 
                removed=' '.join(node.path for node in cs.removed).lower(),
 
                changed=' '.join(node.path for node in cs.changed).lower(),
 
                parents=' '.join(cs.raw_id for cs in cs.parents),
 
            )
 

	
 
        return indexed
 
@@ -287,7 +287,7 @@ class WhooshIndexingDaemon(object):
 
                        continue
 

	
 
                    qp = QueryParser('repository', schema=CHGSETS_SCHEMA)
 
                    q = qp.parse(u"last:t AND %s" % repo_name)
 
                    q = qp.parse("last:t AND %s" % repo_name)
 

	
 
                    results = searcher.search(q)
 

	
 
@@ -306,7 +306,7 @@ class WhooshIndexingDaemon(object):
 
                        # delete the docs in the index for the previous
 
                        # last changeset(s)
 
                        for hit in results:
 
                            q = qp.parse(u"last:t AND %s AND raw_id:%s" %
 
                            q = qp.parse("last:t AND %s AND raw_id:%s" %
 
                                            (repo_name, hit['raw_id']))
 
                            writer.delete_by_query(q)
 

	
 
@@ -326,7 +326,7 @@ class WhooshIndexingDaemon(object):
 
                    log.debug('>> NOTHING TO COMMIT TO CHANGESET INDEX<<')
 

	
 
    def update_file_index(self):
 
        log.debug(u'STARTING INCREMENTAL INDEXING UPDATE FOR EXTENSIONS %s '
 
        log.debug('STARTING INCREMENTAL INDEXING UPDATE FOR EXTENSIONS %s '
 
                  'AND REPOS %s', INDEX_EXTENSIONS, ' and '.join(self.repo_paths))
 

	
 
        idx = open_dir(self.index_location, indexname=self.indexname)
kallithea/lib/locale.py
Show inline comments
 
@@ -24,7 +24,7 @@ def current_locale_is_valid():
 
    Note: UTF-8 is preferred, but for example ISO-8859-1 or mbcs should also
 
    work under the right circumstances."""
 
    try:
 
        u'\xe9'.encode(sys.getfilesystemencoding()) # Test using é (&eacute;)
 
        '\xe9'.encode(sys.getfilesystemencoding()) # Test using é (&eacute;)
 
    except UnicodeEncodeError:
 
        log.error("Cannot encode Unicode paths to file system encoding %r", sys.getfilesystemencoding())
 
        for var in ['LC_ALL', 'LC_CTYPE', 'LANG']:
kallithea/lib/middleware/pygrack.py
Show inline comments
 
@@ -165,7 +165,7 @@ class GitRepository(object):
 
            log.error(traceback.format_exc())
 
            raise exc.HTTPExpectationFailed()
 

	
 
        if git_command in [u'git-receive-pack']:
 
        if git_command in ['git-receive-pack']:
 
            # updating refs manually after each push.
 
            # Needed for pre-1.7.0.4 git clients using regular HTTP mode.
 
            from kallithea.lib.vcs import get_repo
kallithea/lib/utils.py
Show inline comments
 
@@ -145,7 +145,7 @@ def action_logger(user, action, repo, ip
 
        repo_obj = Repository.get_by_repo_name(repo_name)
 
    else:
 
        repo_obj = None
 
        repo_name = u''
 
        repo_name = ''
 

	
 
    user_log = UserLog()
 
    user_log.user_id = user_obj.user_id
 
@@ -428,7 +428,7 @@ def map_groups(path):
 
    rgm = RepoGroupModel()
 
    owner = User.get_first_admin()
 
    for lvl, group_name in enumerate(groups):
 
        group_name = u'/'.join(groups[:lvl] + [group_name])
 
        group_name = '/'.join(groups[:lvl] + [group_name])
 
        group = RepoGroup.get_by_group_name(group_name)
 
        desc = '%s group' % group_name
 

	
kallithea/lib/utils2.py
Show inline comments
 
@@ -239,12 +239,12 @@ def age(prevdate, show_short_version=Fal
 

	
 
    # Format the result
 
    fmt_funcs = {
 
        'year': lambda d: ungettext(u'%d year', '%d years', d) % d,
 
        'month': lambda d: ungettext(u'%d month', '%d months', d) % d,
 
        'day': lambda d: ungettext(u'%d day', '%d days', d) % d,
 
        'hour': lambda d: ungettext(u'%d hour', '%d hours', d) % d,
 
        'minute': lambda d: ungettext(u'%d minute', '%d minutes', d) % d,
 
        'second': lambda d: ungettext(u'%d second', '%d seconds', d) % d,
 
        'year': lambda d: ungettext('%d year', '%d years', d) % d,
 
        'month': lambda d: ungettext('%d month', '%d months', d) % d,
 
        'day': lambda d: ungettext('%d day', '%d days', d) % d,
 
        'hour': lambda d: ungettext('%d hour', '%d hours', d) % d,
 
        'minute': lambda d: ungettext('%d minute', '%d minutes', d) % d,
 
        'second': lambda d: ungettext('%d second', '%d seconds', d) % d,
 
    }
 

	
 
    for i, part in enumerate(order):
kallithea/lib/vcs/backends/base.py
Show inline comments
 
@@ -1026,7 +1026,7 @@ class EmptyChangeset(BaseChangeset):
 
        return self
 

	
 
    def get_file_content(self, path):
 
        return u''
 
        return ''
 

	
 
    def get_file_size(self, path):
 
        return 0
kallithea/lib/vcs/backends/git/repository.py
Show inline comments
 
@@ -351,7 +351,7 @@ class GitRepository(BaseRepository):
 

	
 
    @LazyProperty
 
    def contact(self):
 
        undefined_contact = u'Unknown'
 
        undefined_contact = 'Unknown'
 
        return undefined_contact
 

	
 
    @property
kallithea/lib/vcs/nodes.py
Show inline comments
 
@@ -27,10 +27,10 @@ class NodeKind:
 

	
 

	
 
class NodeState:
 
    ADDED = u'added'
 
    CHANGED = u'changed'
 
    NOT_CHANGED = u'not changed'
 
    REMOVED = u'removed'
 
    ADDED = 'added'
 
    CHANGED = 'changed'
 
    NOT_CHANGED = 'not changed'
 
    REMOVED = 'removed'
 

	
 

	
 
class NodeGeneratorBase(object):
 
@@ -606,4 +606,4 @@ class SubModuleNode(Node):
 
        then only last part is returned.
 
        """
 
        org = self.path.rstrip('/').rsplit('/', 1)[-1]
 
        return u'%s @ %s' % (org, self.changeset.short_id)
 
        return '%s @ %s' % (org, self.changeset.short_id)
kallithea/model/db.py
Show inline comments
 
@@ -959,9 +959,9 @@ class Repository(Base, BaseDbModel):
 
    DEFAULT_CLONE_URI = '{scheme}://{user}@{netloc}/{repo}'
 
    DEFAULT_CLONE_SSH = 'ssh://{system_user}@{hostname}/{repo}'
 

	
 
    STATE_CREATED = u'repo_state_created'
 
    STATE_PENDING = u'repo_state_pending'
 
    STATE_ERROR = u'repo_state_error'
 
    STATE_CREATED = 'repo_state_created'
 
    STATE_PENDING = 'repo_state_pending'
 
    STATE_ERROR = 'repo_state_error'
 

	
 
    repo_id = Column(Integer(), primary_key=True)
 
    repo_name = Column(Unicode(255), nullable=False, unique=True)
 
@@ -1490,7 +1490,7 @@ class RepoGroup(Base, BaseDbModel):
 
        """Return tuple with group_id and name as html literal"""
 
        from webhelpers2.html import literal
 
        if repo_group is None:
 
            return (-1, u'-- %s --' % _('top level'))
 
            return (-1, '-- %s --' % _('top level'))
 
        return repo_group.group_id, literal(cls.SEP.join(repo_group.full_path_splitted))
 

	
 
    @classmethod
 
@@ -2258,8 +2258,8 @@ class PullRequest(Base, BaseDbModel):
 
    )
 

	
 
    # values for .status
 
    STATUS_NEW = u'new'
 
    STATUS_CLOSED = u'closed'
 
    STATUS_NEW = 'new'
 
    STATUS_CLOSED = 'closed'
 

	
 
    pull_request_id = Column(Integer(), primary_key=True)
 
    title = Column(Unicode(255), nullable=False)
 
@@ -2428,9 +2428,9 @@ class Gist(Base, BaseDbModel):
 
        _table_args_default_dict,
 
    )
 

	
 
    GIST_PUBLIC = u'public'
 
    GIST_PRIVATE = u'private'
 
    DEFAULT_FILENAME = u'gistfile1.txt'
 
    GIST_PUBLIC = 'public'
 
    GIST_PRIVATE = 'private'
 
    DEFAULT_FILENAME = 'gistfile1.txt'
 

	
 
    gist_id = Column(Integer(), primary_key=True)
 
    gist_access_id = Column(Unicode(250), nullable=False)
kallithea/model/forms.py
Show inline comments
 
@@ -558,11 +558,11 @@ def GistForm(lifetime_options):
 

	
 
        filename = All(v.BasePath()(),
 
                       v.UnicodeString(strip=True, required=False))
 
        description = v.UnicodeString(required=False, if_missing=u'')
 
        description = v.UnicodeString(required=False, if_missing='')
 
        lifetime = v.OneOf(lifetime_options)
 
        mimetype = v.UnicodeString(required=False, if_missing=None)
 
        content = v.UnicodeString(required=True, not_empty=True)
 
        public = v.UnicodeString(required=False, if_missing=u'')
 
        private = v.UnicodeString(required=False, if_missing=u'')
 
        public = v.UnicodeString(required=False, if_missing='')
 
        private = v.UnicodeString(required=False, if_missing='')
 

	
 
    return _GistForm
kallithea/model/gist.py
Show inline comments
 
@@ -50,7 +50,7 @@ def make_gist_access_id():
 
    rnd = random.SystemRandom() # use cryptographically secure system PRNG
 
    alphabet = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjklmnpqrstuvwxyz'
 
    length = 20
 
    return u''.join(rnd.choice(alphabet) for _ in range(length))
 
    return ''.join(rnd.choice(alphabet) for _ in range(length))
 

	
 

	
 
class GistModel(object):
kallithea/model/notification.py
Show inline comments
 
@@ -43,12 +43,12 @@ log = logging.getLogger(__name__)
 

	
 
class NotificationModel(object):
 

	
 
    TYPE_CHANGESET_COMMENT = u'cs_comment'
 
    TYPE_MESSAGE = u'message'
 
    TYPE_MENTION = u'mention' # not used
 
    TYPE_REGISTRATION = u'registration'
 
    TYPE_PULL_REQUEST = u'pull_request'
 
    TYPE_PULL_REQUEST_COMMENT = u'pull_request_comment'
 
    TYPE_CHANGESET_COMMENT = 'cs_comment'
 
    TYPE_MESSAGE = 'message'
 
    TYPE_MENTION = 'mention' # not used
 
    TYPE_REGISTRATION = 'registration'
 
    TYPE_PULL_REQUEST = 'pull_request'
 
    TYPE_PULL_REQUEST_COMMENT = 'pull_request_comment'
 

	
 
    def create(self, created_by, subject, body, recipients=None,
 
               type_=TYPE_MESSAGE, with_email=True,
kallithea/model/pull_request.py
Show inline comments
 
@@ -265,7 +265,7 @@ class CreatePullRequestAction(object):
 
        from kallithea.model.changeset_status import ChangesetStatusModel
 
        from kallithea.model.comment import ChangesetCommentsModel
 
        comment = ChangesetCommentsModel().create(
 
            text=u'',
 
            text='',
 
            repo=self.org_repo,
 
            author=created_by,
 
            pull_request=pr,
kallithea/model/repo.py
Show inline comments
 
@@ -272,7 +272,7 @@ class RepoModel(object):
 
                cur_repo.owner = User.get_by_username(kwargs['owner'])
 

	
 
            if 'repo_group' in kwargs:
 
                assert kwargs['repo_group'] != u'-1', kwargs # RepoForm should have converted to None
 
                assert kwargs['repo_group'] != '-1', kwargs # RepoForm should have converted to None
 
                cur_repo.group = RepoGroup.get(kwargs['repo_group'])
 
                cur_repo.repo_name = cur_repo.get_new_name(cur_repo.just_name)
 
            log.debug('Updating repo %s with params:%s', cur_repo, kwargs)
kallithea/model/repo_group.py
Show inline comments
 
@@ -288,7 +288,7 @@ class RepoGroupModel(object):
 
                repo_group.parent_group_id = repo_group_args['parent_group_id']
 

	
 
            if 'parent_group_id' in repo_group_args:
 
                assert repo_group_args['parent_group_id'] != u'-1', repo_group_args  # RepoGroupForm should have converted to None
 
                assert repo_group_args['parent_group_id'] != '-1', repo_group_args  # RepoGroupForm should have converted to None
 
                repo_group.parent_group = RepoGroup.get(repo_group_args['parent_group_id'])
 
            if 'group_name' in repo_group_args:
 
                group_name = repo_group_args['group_name']
kallithea/model/scm.py
Show inline comments
 
@@ -659,18 +659,18 @@ class ScmModel(object):
 

	
 
        repo = repo.scm_instance
 

	
 
        branches_group = ([(u'branch:%s' % k, k) for k, v in
 
        branches_group = ([('branch:%s' % k, k) for k, v in
 
                           repo.branches.items()], _("Branches"))
 
        hist_l.append(branches_group)
 
        choices.extend([x[0] for x in branches_group[0]])
 

	
 
        if repo.alias == 'hg':
 
            bookmarks_group = ([(u'book:%s' % k, k) for k, v in
 
            bookmarks_group = ([('book:%s' % k, k) for k, v in
 
                                repo.bookmarks.items()], _("Bookmarks"))
 
            hist_l.append(bookmarks_group)
 
            choices.extend([x[0] for x in bookmarks_group[0]])
 

	
 
        tags_group = ([(u'tag:%s' % k, k) for k, v in
 
        tags_group = ([('tag:%s' % k, k) for k, v in
 
                       repo.tags.items()], _("Tags"))
 
        hist_l.append(tags_group)
 
        choices.extend([x[0] for x in tags_group[0]])
kallithea/model/user.py
Show inline comments
 
@@ -94,8 +94,8 @@ class UserModel(object):
 
        log_create_user(new_user.get_dict(), cur_user)
 
        return new_user
 

	
 
    def create_or_update(self, username, password, email, firstname=u'',
 
                         lastname=u'', active=True, admin=False,
 
    def create_or_update(self, username, password, email, firstname='',
 
                         lastname='', active=True, admin=False,
 
                         extern_type=None, extern_name=None, cur_user=None):
 
        """
 
        Creates a new instance if not found, or updates current one
 
@@ -183,7 +183,7 @@ class UserModel(object):
 
        # notification to admins
 
        subject = _('New user registration')
 
        body = (
 
            u'New user registration\n'
 
            'New user registration\n'
 
            '---------------------\n'
 
            '- Username: {user.username}\n'
 
            '- Full Name: {user.full_name}\n'
 
@@ -308,8 +308,8 @@ class UserModel(object):
 
        """
 
        app_secret = config.get('app_instance_uuid')
 
        return hmac.HMAC(
 
            key=u'\0'.join([app_secret, user.password]).encode('utf-8'),
 
            msg=u'\0'.join([session_id, str(user.user_id), user.email, str(timestamp)]).encode('utf-8'),
 
            key='\0'.join([app_secret, user.password]).encode('utf-8'),
 
            msg='\0'.join([session_id, str(user.user_id), user.email, str(timestamp)]).encode('utf-8'),
 
            digestmod=hashlib.sha1,
 
        ).hexdigest()
 

	
kallithea/model/user_group.py
Show inline comments
 
@@ -367,7 +367,7 @@ class UserGroupModel(object):
 
        for gr in set(groups):
 
            existing_group = UserGroup.get_by_group_name(gr)
 
            if not existing_group:
 
                desc = u'Automatically created from plugin:%s' % extern_type
 
                desc = 'Automatically created from plugin:%s' % extern_type
 
                # we use first admin account to set the owner of the group
 
                existing_group = UserGroupModel().create(gr, desc, owner,
 
                                        group_data={'extern_type': extern_type})
kallithea/model/validators.py
Show inline comments
 
@@ -276,7 +276,7 @@ def ValidPasswordsMatch(password_field, 
 
def ValidAuth():
 
    class _validator(formencode.validators.FancyValidator):
 
        messages = {
 
            'invalid_auth': _(u'Invalid username or password'),
 
            'invalid_auth': _('Invalid username or password'),
 
        }
 

	
 
        def _validate_python(self, value, state):
kallithea/tests/api/api_base.py
Show inline comments
 
@@ -40,8 +40,8 @@ from kallithea.tests.fixture import Fixt
 

	
 

	
 
API_URL = '/_admin/api'
 
TEST_USER_GROUP = u'test_user_group'
 
TEST_REPO_GROUP = u'test_repo_group'
 
TEST_USER_GROUP = 'test_user_group'
 
TEST_REPO_GROUP = 'test_repo_group'
 

	
 
fixture = Fixture()
 

	
 
@@ -100,8 +100,8 @@ class _BaseTestApi(object):
 
            username='test-api',
 
            password='test',
 
            email='test@example.com',
 
            firstname=u'first',
 
            lastname=u'last'
 
            firstname='first',
 
            lastname='last'
 
        )
 
        Session().commit()
 
        cls.TEST_USER_LOGIN = cls.test_user.username
 
@@ -281,7 +281,7 @@ class _BaseTestApi(object):
 
    def test_api_pull_remote(self):
 
        # Note: pulling from local repos is a mis-feature - it will bypass access control
 
        # ... but ok, if the path already has been set in the database
 
        repo_name = u'test_pull'
 
        repo_name = 'test_pull'
 
        r = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 
        # hack around that clone_uri can't be set to to a local path
 
        # (as shown by test_api_create_repo_clone_uri_local)
 
@@ -305,7 +305,7 @@ class _BaseTestApi(object):
 
        assert pre_cached_tip != post_cached_tip
 

	
 
    def test_api_pull_fork(self):
 
        fork_name = u'fork'
 
        fork_name = 'fork'
 
        fixture.create_fork(self.REPO, fork_name)
 
        id_, params = _build_data(self.apikey, 'pull',
 
                                  repoid=fork_name,)
 
@@ -327,7 +327,7 @@ class _BaseTestApi(object):
 
        self._compare_error(id_, expected, given=response.body)
 

	
 
    def test_api_pull_custom_remote(self):
 
        repo_name = u'test_pull_custom_remote'
 
        repo_name = 'test_pull_custom_remote'
 
        fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 

	
 
        custom_remote_path = os.path.join(Ui.get_by_key('paths', '/').ui_value, self.REPO)
 
@@ -489,10 +489,10 @@ class _BaseTestApi(object):
 
        self._compare_error(id_, expected, given=response.body)
 

	
 
    def test_api_delete_user(self):
 
        usr = UserModel().create_or_update(username=u'test_user',
 
                                           password=u'qweqwe',
 
                                           email=u'u232@example.com',
 
                                           firstname=u'u1', lastname=u'u1')
 
        usr = UserModel().create_or_update(username='test_user',
 
                                           password='qweqwe',
 
                                           email='u232@example.com',
 
                                           firstname='u1', lastname='u1')
 
        Session().commit()
 
        username = usr.username
 
        email = usr.email
 
@@ -510,10 +510,10 @@ class _BaseTestApi(object):
 

	
 
    @mock.patch.object(UserModel, 'delete', crash)
 
    def test_api_delete_user_when_exception_happened(self):
 
        usr = UserModel().create_or_update(username=u'test_user',
 
                                           password=u'qweqwe',
 
                                           email=u'u232@example.com',
 
                                           firstname=u'u1', lastname=u'u1')
 
        usr = UserModel().create_or_update(username='test_user',
 
                                           password='qweqwe',
 
                                           email='u232@example.com',
 
                                           firstname='u1', lastname='u1')
 
        Session().commit()
 
        username = usr.username
 

	
 
@@ -610,7 +610,7 @@ class _BaseTestApi(object):
 
        self._compare_error(id_, expected, given=response.body)
 

	
 
    def test_api_get_repo(self):
 
        new_group = u'some_new_group'
 
        new_group = 'some_new_group'
 
        make_user_group(new_group)
 
        RepoModel().grant_user_group_permission(repo=self.REPO,
 
                                                group_name=new_group,
 
@@ -619,8 +619,8 @@ class _BaseTestApi(object):
 
        id_, params = _build_data(self.apikey, 'get_repo',
 
                                  repoid=self.REPO)
 
        response = api_call(self, params)
 
        assert u"tags" not in response.json[u'result']
 
        assert u'pull_requests' not in response.json[u'result']
 
        assert "tags" not in response.json['result']
 
        assert 'pull_requests' not in response.json['result']
 

	
 
        repo = RepoModel().get_by_repo_name(self.REPO)
 
        ret = repo.get_api_data()
 
@@ -655,8 +655,8 @@ class _BaseTestApi(object):
 
                                  with_revision_names=True,
 
                                  with_pullrequests=True)
 
        response = api_call(self, params)
 
        assert u"v0.2.0" in response.json[u'result'][u'tags']
 
        assert u'pull_requests' in response.json[u'result']
 
        assert "v0.2.0" in response.json['result']['tags']
 
        assert 'pull_requests' in response.json['result']
 

	
 
    @base.parametrize('grant_perm', [
 
        ('repository.admin'),
 
@@ -838,7 +838,7 @@ class _BaseTestApi(object):
 
            RepoModel().revoke_user_permission(self.REPO, self.TEST_USER_LOGIN)
 

	
 
    def test_api_create_repo(self):
 
        repo_name = u'api-repo'
 
        repo_name = 'api-repo'
 
        id_, params = _build_data(self.apikey, 'create_repo',
 
                                  repo_name=repo_name,
 
                                  owner=base.TEST_USER_ADMIN_LOGIN,
 
@@ -858,12 +858,12 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo(repo_name)
 

	
 
    @base.parametrize('repo_name', [
 
        u'',
 
        u'.',
 
        u'..',
 
        u':',
 
        u'/',
 
        u'<test>',
 
        '',
 
        '.',
 
        '..',
 
        ':',
 
        '/',
 
        '<test>',
 
    ])
 
    def test_api_create_repo_bad_names(self, repo_name):
 
        id_, params = _build_data(self.apikey, 'create_repo',
 
@@ -884,7 +884,7 @@ class _BaseTestApi(object):
 
        # cloning from local repos was a mis-feature - it would bypass access control
 
        # TODO: introduce other test coverage of actual remote cloning
 
        clone_uri = os.path.join(base.TESTS_TMP_PATH, self.REPO)
 
        repo_name = u'api-repo'
 
        repo_name = 'api-repo'
 
        id_, params = _build_data(self.apikey, 'create_repo',
 
                                  repo_name=repo_name,
 
                                  owner=base.TEST_USER_ADMIN_LOGIN,
 
@@ -897,8 +897,8 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo(repo_name)
 

	
 
    def test_api_create_repo_and_repo_group(self):
 
        repo_group_name = u'my_gr'
 
        repo_name = u'%s/api-repo' % repo_group_name
 
        repo_group_name = 'my_gr'
 
        repo_name = '%s/api-repo' % repo_group_name
 

	
 
        # repo creation can no longer also create repo group
 
        id_, params = _build_data(self.apikey, 'create_repo',
 
@@ -906,7 +906,7 @@ class _BaseTestApi(object):
 
                                  owner=base.TEST_USER_ADMIN_LOGIN,
 
                                  repo_type=self.REPO_TYPE,)
 
        response = api_call(self, params)
 
        expected = u'repo group `%s` not found' % repo_group_name
 
        expected = 'repo group `%s` not found' % repo_group_name
 
        self._compare_error(id_, expected, given=response.body)
 
        assert RepoModel().get_by_repo_name(repo_name) is None
 

	
 
@@ -932,9 +932,9 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo_group(repo_group_name)
 

	
 
    def test_api_create_repo_in_repo_group_without_permission(self):
 
        repo_group_basename = u'api-repo-repo'
 
        repo_group_name = u'%s/%s' % (TEST_REPO_GROUP, repo_group_basename)
 
        repo_name = u'%s/api-repo' % repo_group_name
 
        repo_group_basename = 'api-repo-repo'
 
        repo_group_name = '%s/%s' % (TEST_REPO_GROUP, repo_group_basename)
 
        repo_name = '%s/api-repo' % repo_group_name
 

	
 
        top_group = RepoGroup.get_by_group_name(TEST_REPO_GROUP)
 
        assert top_group
 
@@ -968,7 +968,7 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo_group(repo_group_name)
 

	
 
    def test_api_create_repo_unknown_owner(self):
 
        repo_name = u'api-repo'
 
        repo_name = 'api-repo'
 
        owner = 'i-dont-exist'
 
        id_, params = _build_data(self.apikey, 'create_repo',
 
                                  repo_name=repo_name,
 
@@ -980,7 +980,7 @@ class _BaseTestApi(object):
 
        self._compare_error(id_, expected, given=response.body)
 

	
 
    def test_api_create_repo_dont_specify_owner(self):
 
        repo_name = u'api-repo'
 
        repo_name = 'api-repo'
 
        owner = 'i-dont-exist'
 
        id_, params = _build_data(self.apikey, 'create_repo',
 
                                  repo_name=repo_name,
 
@@ -1000,7 +1000,7 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo(repo_name)
 

	
 
    def test_api_create_repo_by_non_admin(self):
 
        repo_name = u'api-repo'
 
        repo_name = 'api-repo'
 
        owner = 'i-dont-exist'
 
        id_, params = _build_data(self.apikey_regular, 'create_repo',
 
                                  repo_name=repo_name,
 
@@ -1020,7 +1020,7 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo(repo_name)
 

	
 
    def test_api_create_repo_by_non_admin_specify_owner(self):
 
        repo_name = u'api-repo'
 
        repo_name = 'api-repo'
 
        owner = 'i-dont-exist'
 
        id_, params = _build_data(self.apikey_regular, 'create_repo',
 
                                  repo_name=repo_name,
 
@@ -1051,13 +1051,13 @@ class _BaseTestApi(object):
 
                                  owner=base.TEST_USER_ADMIN_LOGIN,
 
                                  repo_type=self.REPO_TYPE,)
 
        response = api_call(self, params)
 
        expected = u'repo group `%s` not found' % group_name
 
        expected = 'repo group `%s` not found' % group_name
 
        self._compare_error(id_, expected, given=response.body)
 
        fixture.destroy_repo(repo_name)
 

	
 
    @mock.patch.object(RepoModel, 'create', crash)
 
    def test_api_create_repo_exception_occurred(self):
 
        repo_name = u'api-repo'
 
        repo_name = 'api-repo'
 
        id_, params = _build_data(self.apikey, 'create_repo',
 
                                  repo_name=repo_name,
 
                                  owner=base.TEST_USER_ADMIN_LOGIN,
 
@@ -1068,18 +1068,18 @@ class _BaseTestApi(object):
 

	
 
    @base.parametrize('changing_attr,updates', [
 
        ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}),
 
        ('description', {'description': u'new description'}),
 
        ('description', {'description': 'new description'}),
 
        ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail
 
        ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control
 
        ('clone_uri', {'clone_uri': None}),
 
        ('landing_rev', {'landing_rev': 'branch:master'}),
 
        ('enable_statistics', {'enable_statistics': True}),
 
        ('enable_downloads', {'enable_downloads': True}),
 
        ('name', {'name': u'new_repo_name'}),
 
        ('repo_group', {'group': u'test_group_for_update'}),
 
        ('name', {'name': 'new_repo_name'}),
 
        ('repo_group', {'group': 'test_group_for_update'}),
 
    ])
 
    def test_api_update_repo(self, changing_attr, updates):
 
        repo_name = u'api_update_me'
 
        repo_name = 'api_update_me'
 
        repo = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 
        if changing_attr == 'repo_group':
 
            fixture.create_repo_group(updates['group'])
 
@@ -1090,10 +1090,10 @@ class _BaseTestApi(object):
 
        if changing_attr == 'name':
 
            repo_name = updates['name']
 
        if changing_attr == 'repo_group':
 
            repo_name = u'/'.join([updates['group'], repo_name])
 
            repo_name = '/'.join([updates['group'], repo_name])
 
        try:
 
            if changing_attr == 'clone_uri' and updates['clone_uri']:
 
                expected = u'failed to update repo `%s`' % repo_name
 
                expected = 'failed to update repo `%s`' % repo_name
 
                self._compare_error(id_, expected, given=response.body)
 
            else:
 
                expected = {
 
@@ -1108,20 +1108,20 @@ class _BaseTestApi(object):
 

	
 
    @base.parametrize('changing_attr,updates', [
 
        ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}),
 
        ('description', {'description': u'new description'}),
 
        ('description', {'description': 'new description'}),
 
        ('clone_uri', {'clone_uri': 'http://example.com/repo'}), # will fail - pulling from non-existing repo should fail
 
        ('clone_uri', {'clone_uri': '/repo'}), # will fail - pulling from local repo was a mis-feature - it would bypass access control
 
        ('clone_uri', {'clone_uri': None}),
 
        ('landing_rev', {'landing_rev': 'branch:master'}),
 
        ('enable_statistics', {'enable_statistics': True}),
 
        ('enable_downloads', {'enable_downloads': True}),
 
        ('name', {'name': u'new_repo_name'}),
 
        ('repo_group', {'group': u'test_group_for_update'}),
 
        ('name', {'name': 'new_repo_name'}),
 
        ('repo_group', {'group': 'test_group_for_update'}),
 
    ])
 
    def test_api_update_group_repo(self, changing_attr, updates):
 
        group_name = u'lololo'
 
        group_name = 'lololo'
 
        fixture.create_repo_group(group_name)
 
        repo_name = u'%s/api_update_me' % group_name
 
        repo_name = '%s/api_update_me' % group_name
 
        repo = fixture.create_repo(repo_name, repo_group=group_name, repo_type=self.REPO_TYPE)
 
        if changing_attr == 'repo_group':
 
            fixture.create_repo_group(updates['group'])
 
@@ -1130,12 +1130,12 @@ class _BaseTestApi(object):
 
                                  repoid=repo_name, **updates)
 
        response = api_call(self, params)
 
        if changing_attr == 'name':
 
            repo_name = u'%s/%s' % (group_name, updates['name'])
 
            repo_name = '%s/%s' % (group_name, updates['name'])
 
        if changing_attr == 'repo_group':
 
            repo_name = u'/'.join([updates['group'], repo_name.rsplit('/', 1)[-1]])
 
            repo_name = '/'.join([updates['group'], repo_name.rsplit('/', 1)[-1]])
 
        try:
 
            if changing_attr == 'clone_uri' and updates['clone_uri']:
 
                expected = u'failed to update repo `%s`' % repo_name
 
                expected = 'failed to update repo `%s`' % repo_name
 
                self._compare_error(id_, expected, given=response.body)
 
            else:
 
                expected = {
 
@@ -1150,7 +1150,7 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo_group(group_name)
 

	
 
    def test_api_update_repo_repo_group_does_not_exist(self):
 
        repo_name = u'admin_owned'
 
        repo_name = 'admin_owned'
 
        fixture.create_repo(repo_name)
 
        updates = {'group': 'test_group_for_update'}
 
        id_, params = _build_data(self.apikey, 'update_repo',
 
@@ -1163,7 +1163,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(repo_name)
 

	
 
    def test_api_update_repo_regular_user_not_allowed(self):
 
        repo_name = u'admin_owned'
 
        repo_name = 'admin_owned'
 
        fixture.create_repo(repo_name)
 
        updates = {'description': 'something else'}
 
        id_, params = _build_data(self.apikey_regular, 'update_repo',
 
@@ -1177,7 +1177,7 @@ class _BaseTestApi(object):
 

	
 
    @mock.patch.object(RepoModel, 'update', crash)
 
    def test_api_update_repo_exception_occurred(self):
 
        repo_name = u'api_update_me'
 
        repo_name = 'api_update_me'
 
        fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 
        id_, params = _build_data(self.apikey, 'update_repo',
 
                                  repoid=repo_name, owner=base.TEST_USER_ADMIN_LOGIN,)
 
@@ -1189,8 +1189,8 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(repo_name)
 

	
 
    def test_api_update_repo_regular_user_change_repo_name(self):
 
        repo_name = u'admin_owned'
 
        new_repo_name = u'new_repo_name'
 
        repo_name = 'admin_owned'
 
        new_repo_name = 'new_repo_name'
 
        fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 
        RepoModel().grant_user_permission(repo=repo_name,
 
                                          user=self.TEST_USER_LOGIN,
 
@@ -1209,8 +1209,8 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(new_repo_name)
 

	
 
    def test_api_update_repo_regular_user_change_repo_name_allowed(self):
 
        repo_name = u'admin_owned'
 
        new_repo_name = u'new_repo_name'
 
        repo_name = 'admin_owned'
 
        new_repo_name = 'new_repo_name'
 
        repo = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 
        RepoModel().grant_user_permission(repo=repo_name,
 
                                          user=self.TEST_USER_LOGIN,
 
@@ -1232,7 +1232,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(new_repo_name)
 

	
 
    def test_api_update_repo_regular_user_change_owner(self):
 
        repo_name = u'admin_owned'
 
        repo_name = 'admin_owned'
 
        fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 
        RepoModel().grant_user_permission(repo=repo_name,
 
                                          user=self.TEST_USER_LOGIN,
 
@@ -1248,7 +1248,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(repo_name)
 

	
 
    def test_api_delete_repo(self):
 
        repo_name = u'api_delete_me'
 
        repo_name = 'api_delete_me'
 
        fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 

	
 
        id_, params = _build_data(self.apikey, 'delete_repo',
 
@@ -1266,7 +1266,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(repo_name)
 

	
 
    def test_api_delete_repo_by_non_admin(self):
 
        repo_name = u'api_delete_me'
 
        repo_name = 'api_delete_me'
 
        fixture.create_repo(repo_name, repo_type=self.REPO_TYPE,
 
                            cur_user=self.TEST_USER_LOGIN)
 
        id_, params = _build_data(self.apikey_regular, 'delete_repo',
 
@@ -1284,7 +1284,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(repo_name)
 

	
 
    def test_api_delete_repo_by_non_admin_no_permission(self):
 
        repo_name = u'api_delete_me'
 
        repo_name = 'api_delete_me'
 
        fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 
        try:
 
            id_, params = _build_data(self.apikey_regular, 'delete_repo',
 
@@ -1296,7 +1296,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(repo_name)
 

	
 
    def test_api_delete_repo_exception_occurred(self):
 
        repo_name = u'api_delete_me'
 
        repo_name = 'api_delete_me'
 
        fixture.create_repo(repo_name, repo_type=self.REPO_TYPE)
 
        try:
 
            with mock.patch.object(RepoModel, 'delete', crash):
 
@@ -1310,7 +1310,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_repo(repo_name)
 

	
 
    def test_api_fork_repo(self):
 
        fork_name = u'api-repo-fork'
 
        fork_name = 'api-repo-fork'
 
        id_, params = _build_data(self.apikey, 'fork_repo',
 
                                  repoid=self.REPO,
 
                                  fork_name=fork_name,
 
@@ -1329,8 +1329,8 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo(fork_name)
 

	
 
    @base.parametrize('fork_name', [
 
        u'api-repo-fork',
 
        u'%s/api-repo-fork' % TEST_REPO_GROUP,
 
        'api-repo-fork',
 
        '%s/api-repo-fork' % TEST_REPO_GROUP,
 
    ])
 
    def test_api_fork_repo_non_admin(self, fork_name):
 
        id_, params = _build_data(self.apikey_regular, 'fork_repo',
 
@@ -1350,7 +1350,7 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo(fork_name)
 

	
 
    def test_api_fork_repo_non_admin_specify_owner(self):
 
        fork_name = u'api-repo-fork'
 
        fork_name = 'api-repo-fork'
 
        id_, params = _build_data(self.apikey_regular, 'fork_repo',
 
                                  repoid=self.REPO,
 
                                  fork_name=fork_name,
 
@@ -1366,7 +1366,7 @@ class _BaseTestApi(object):
 
                                          user=self.default_user_username,
 
                                          perm='repository.none')
 
        try:
 
            fork_name = u'api-repo-fork'
 
            fork_name = 'api-repo-fork'
 
            id_, params = _build_data(self.apikey_regular, 'fork_repo',
 
                                      repoid=self.REPO,
 
                                      fork_name=fork_name,
 
@@ -1386,7 +1386,7 @@ class _BaseTestApi(object):
 
        ('admin', 'repository.admin'),
 
    ])
 
    def test_api_fork_repo_non_admin_no_create_repo_permission(self, name, perm):
 
        fork_name = u'api-repo-fork'
 
        fork_name = 'api-repo-fork'
 
        # regardless of base repository permission, forking is disallowed
 
        # when repository creation is disabled
 
        RepoModel().grant_user_permission(repo=self.REPO,
 
@@ -1404,7 +1404,7 @@ class _BaseTestApi(object):
 
        fixture.destroy_repo(fork_name)
 

	
 
    def test_api_fork_repo_unknown_owner(self):
 
        fork_name = u'api-repo-fork'
 
        fork_name = 'api-repo-fork'
 
        owner = 'i-dont-exist'
 
        id_, params = _build_data(self.apikey, 'fork_repo',
 
                                  repoid=self.REPO,
 
@@ -1416,11 +1416,11 @@ class _BaseTestApi(object):
 
        self._compare_error(id_, expected, given=response.body)
 

	
 
    def test_api_fork_repo_fork_exists(self):
 
        fork_name = u'api-repo-fork'
 
        fork_name = 'api-repo-fork'
 
        fixture.create_fork(self.REPO, fork_name)
 

	
 
        try:
 
            fork_name = u'api-repo-fork'
 
            fork_name = 'api-repo-fork'
 

	
 
            id_, params = _build_data(self.apikey, 'fork_repo',
 
                                      repoid=self.REPO,
 
@@ -1449,7 +1449,7 @@ class _BaseTestApi(object):
 

	
 
    @mock.patch.object(RepoModel, 'create_fork', crash)
 
    def test_api_fork_repo_exception_occurred(self):
 
        fork_name = u'api-repo-fork'
 
        fork_name = 'api-repo-fork'
 
        id_, params = _build_data(self.apikey, 'fork_repo',
 
                                  repoid=self.REPO,
 
                                  fork_name=fork_name,
 
@@ -1478,7 +1478,7 @@ class _BaseTestApi(object):
 
        self._compare_ok(id_, expected, given=response.body)
 

	
 
    def test_api_get_user_groups(self):
 
        gr_name = u'test_user_group2'
 
        gr_name = 'test_user_group2'
 
        make_user_group(gr_name)
 

	
 
        try:
 
@@ -1486,7 +1486,7 @@ class _BaseTestApi(object):
 
            response = api_call(self, params)
 

	
 
            expected = []
 
            for gr_name in [TEST_USER_GROUP, u'test_user_group2']:
 
            for gr_name in [TEST_USER_GROUP, 'test_user_group2']:
 
                user_group = UserGroupModel().get_group(gr_name)
 
                ret = user_group.get_api_data()
 
                expected.append(ret)
 
@@ -1495,7 +1495,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_user_group(gr_name)
 

	
 
    def test_api_create_user_group(self):
 
        group_name = u'some_new_group'
 
        group_name = 'some_new_group'
 
        id_, params = _build_data(self.apikey, 'create_user_group',
 
                                  group_name=group_name)
 
        response = api_call(self, params)
 
@@ -1521,7 +1521,7 @@ class _BaseTestApi(object):
 

	
 
    @mock.patch.object(UserGroupModel, 'create', crash)
 
    def test_api_get_user_group_exception_occurred(self):
 
        group_name = u'exception_happens'
 
        group_name = 'exception_happens'
 
        id_, params = _build_data(self.apikey, 'create_user_group',
 
                                  group_name=group_name)
 
        response = api_call(self, params)
 
@@ -1530,14 +1530,14 @@ class _BaseTestApi(object):
 
        self._compare_error(id_, expected, given=response.body)
 

	
 
    @base.parametrize('changing_attr,updates', [
 
        ('group_name', {'group_name': u'new_group_name'}),
 
        ('group_name', {'group_name': u'test_group_for_update'}),
 
        ('group_name', {'group_name': 'new_group_name'}),
 
        ('group_name', {'group_name': 'test_group_for_update'}),
 
        ('owner', {'owner': base.TEST_USER_REGULAR_LOGIN}),
 
        ('active', {'active': False}),
 
        ('active', {'active': True}),
 
    ])
 
    def test_api_update_user_group(self, changing_attr, updates):
 
        gr_name = u'test_group_for_update'
 
        gr_name = 'test_group_for_update'
 
        user_group = fixture.create_user_group(gr_name)
 
        try:
 
            id_, params = _build_data(self.apikey, 'update_user_group',
 
@@ -1557,7 +1557,7 @@ class _BaseTestApi(object):
 

	
 
    @mock.patch.object(UserGroupModel, 'update', crash)
 
    def test_api_update_user_group_exception_occurred(self):
 
        gr_name = u'test_group'
 
        gr_name = 'test_group'
 
        fixture.create_user_group(gr_name)
 
        try:
 
            id_, params = _build_data(self.apikey, 'update_user_group',
 
@@ -1569,7 +1569,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_user_group(gr_name)
 

	
 
    def test_api_add_user_to_user_group(self):
 
        gr_name = u'test_group'
 
        gr_name = 'test_group'
 
        fixture.create_user_group(gr_name)
 
        try:
 
            id_, params = _build_data(self.apikey, 'add_user_to_user_group',
 
@@ -1596,7 +1596,7 @@ class _BaseTestApi(object):
 

	
 
    @mock.patch.object(UserGroupModel, 'add_user_to_group', crash)
 
    def test_api_add_user_to_user_group_exception_occurred(self):
 
        gr_name = u'test_group'
 
        gr_name = 'test_group'
 
        fixture.create_user_group(gr_name)
 
        try:
 
            id_, params = _build_data(self.apikey, 'add_user_to_user_group',
 
@@ -1609,7 +1609,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_user_group(gr_name)
 

	
 
    def test_api_remove_user_from_user_group(self):
 
        gr_name = u'test_group_3'
 
        gr_name = 'test_group_3'
 
        gr = fixture.create_user_group(gr_name)
 
        UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN)
 
        Session().commit()
 
@@ -1629,7 +1629,7 @@ class _BaseTestApi(object):
 

	
 
    @mock.patch.object(UserGroupModel, 'remove_user_from_group', crash)
 
    def test_api_remove_user_from_user_group_exception_occurred(self):
 
        gr_name = u'test_group_3'
 
        gr_name = 'test_group_3'
 
        gr = fixture.create_user_group(gr_name)
 
        UserGroupModel().add_user_to_group(gr, user=base.TEST_USER_ADMIN_LOGIN)
 
        Session().commit()
 
@@ -1644,7 +1644,7 @@ class _BaseTestApi(object):
 
            fixture.destroy_user_group(gr_name)
 

	
 
    def test_api_delete_user_group(self):
 
        gr_name = u'test_group'
 
        gr_name = 'test_group'
 
        ugroup = fixture.create_user_group(gr_name)
 
        gr_id = ugroup.users_group_id
 
        try:
 
@@ -1661,7 +1661,7 @@ class _BaseTestApi(object):
 
                fixture.destroy_user_group(gr_name)
 

	
 
    def test_api_delete_user_group_that_is_assigned(self):
 
        gr_name = u'test_group'
 
        gr_name = 'test_group'
 
        ugroup = fixture.create_user_group(gr_name)
 
        gr_id = ugroup.users_group_id
 

	
 
@@ -1679,7 +1679,7 @@ class _BaseTestApi(object):
 
                fixture.destroy_user_group(gr_name)
 

	
 
    def test_api_delete_user_group_exception_occurred(self):
 
        gr_name = u'test_group'
 
        gr_name = 'test_group'
 
        ugroup = fixture.create_user_group(gr_name)
 
        gr_id = ugroup.users_group_id
 
        id_, params = _build_data(self.apikey, 'delete_user_group',
 
@@ -2467,7 +2467,7 @@ class _BaseTestApi(object):
 
        id_, params = _build_data(self.apikey, 'get_changeset',
 
                                  repoid=self.REPO, raw_id = '7ab37bc680b4aa72c34d07b230c866c28e9fcfff')
 
        response = api_call(self, params)
 
        expected = u'Changeset %s does not exist' % ('7ab37bc680b4aa72c34d07b230c866c28e9fcfff',)
 
        expected = 'Changeset %s does not exist' % ('7ab37bc680b4aa72c34d07b230c866c28e9fcfff',)
 
        self._compare_error(id_, expected, given=response.body)
 

	
 
    def test_api_get_changeset_without_permission(self):
 
@@ -2477,11 +2477,11 @@ class _BaseTestApi(object):
 
        id_, params = _build_data(self.apikey_regular, 'get_changeset',
 
                                  repoid=self.REPO, raw_id=self.TEST_REVISION)
 
        response = api_call(self, params)
 
        expected = u'Access denied to repo %s' % self.REPO
 
        expected = 'Access denied to repo %s' % self.REPO
 
        self._compare_error(id_, expected, given=response.body)
 

	
 
    def test_api_get_pullrequest(self):
 
        pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, u'get test')
 
        pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, 'get test')
 
        random_id = random.randrange(1, 9999)
 
        params = ascii_bytes(ext_json.dumps({
 
            "id": random_id,
 
@@ -2512,7 +2512,7 @@ class _BaseTestApi(object):
 
                                      b"2000-01-01T00:00:00", response.body))
 

	
 
    def test_api_close_pullrequest(self):
 
        pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, u'close test')
 
        pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, 'close test')
 
        random_id = random.randrange(1, 9999)
 
        params = ascii_bytes(ext_json.dumps({
 
            "id": random_id,
 
@@ -2528,7 +2528,7 @@ class _BaseTestApi(object):
 
        assert pullrequest.is_closed() == True
 

	
 
    def test_api_status_pullrequest(self):
 
        pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, u"status test")
 
        pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, "status test")
 

	
 
        random_id = random.randrange(1, 9999)
 
        params = ascii_bytes(ext_json.dumps({
 
@@ -2553,7 +2553,7 @@ class _BaseTestApi(object):
 
        assert ChangesetStatus.STATUS_APPROVED == ChangesetStatusModel().calculate_pull_request_result(pullrequest)[2]
 

	
 
    def test_api_comment_pullrequest(self):
 
        pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, u"comment test")
 
        pull_request_id = fixture.create_pullrequest(self, self.REPO, self.TEST_PR_SRC, self.TEST_PR_DST, "comment test")
 
        random_id = random.randrange(1, 9999)
 
        params = ascii_bytes(ext_json.dumps({
 
            "id": random_id,
 
@@ -2564,4 +2564,4 @@ class _BaseTestApi(object):
 
        response = api_call(self, params)
 
        self._compare_ok(random_id, True, given=response.body)
 
        pullrequest = PullRequest().get(pull_request_id)
 
        assert pullrequest.comments[-1].text == u'Looks good to me'
 
        assert pullrequest.comments[-1].text == 'Looks good to me'
kallithea/tests/api/test_api_git.py
Show inline comments
 
@@ -20,9 +20,9 @@ class TestGitApi(_BaseTestApi, TestContr
 
    REPO = GIT_REPO
 
    REPO_TYPE = 'git'
 
    TEST_REVISION = GIT_TEST_REVISION
 
    TEST_PR_SRC = u'c60f01b77c42dce653d6b1d3b04689862c261929'
 
    TEST_PR_DST = u'10cddef6b794696066fb346434014f0a56810218'
 
    TEST_PR_REVISIONS = [u'1bead5880d2dbe831762bf7fb439ba2919b75fdd',
 
                         u'9bcd3ecfc8832a8cd881c1c1bbe2d13ffa9d94c7',
 
                         u'283de4dfca8479875a1befb8d4059f3bbb725145',
 
                         u'c60f01b77c42dce653d6b1d3b04689862c261929']
 
    TEST_PR_SRC = 'c60f01b77c42dce653d6b1d3b04689862c261929'
 
    TEST_PR_DST = '10cddef6b794696066fb346434014f0a56810218'
 
    TEST_PR_REVISIONS = ['1bead5880d2dbe831762bf7fb439ba2919b75fdd',
 
                         '9bcd3ecfc8832a8cd881c1c1bbe2d13ffa9d94c7',
 
                         '283de4dfca8479875a1befb8d4059f3bbb725145',
 
                         'c60f01b77c42dce653d6b1d3b04689862c261929']
kallithea/tests/api/test_api_hg.py
Show inline comments
 
@@ -20,10 +20,10 @@ class TestHgApi(_BaseTestApi, TestContro
 
    REPO = HG_REPO
 
    REPO_TYPE = 'hg'
 
    TEST_REVISION = HG_TEST_REVISION
 
    TEST_PR_SRC = u'4f7e2131323e0749a740c0a56ab68ae9269c562a'
 
    TEST_PR_DST = u'92831aebf2f8dd4879e897024b89d09af214df1c'
 
    TEST_PR_REVISIONS = [u'720bbdb27665d6262b313e8a541b654d0cbd5b27',
 
                         u'f41649565a9e89919a588a163e717b4084f8a3b1',
 
                         u'94f45ed825a113e61af7e141f44ca578374abef0',
 
                         u'fef5bfe1dc17611d5fb59a7f6f95c55c3606f933',
 
                         u'4f7e2131323e0749a740c0a56ab68ae9269c562a']
 
    TEST_PR_SRC = '4f7e2131323e0749a740c0a56ab68ae9269c562a'
 
    TEST_PR_DST = '92831aebf2f8dd4879e897024b89d09af214df1c'
 
    TEST_PR_REVISIONS = ['720bbdb27665d6262b313e8a541b654d0cbd5b27',
 
                         'f41649565a9e89919a588a163e717b4084f8a3b1',
 
                         '94f45ed825a113e61af7e141f44ca578374abef0',
 
                         'fef5bfe1dc17611d5fb59a7f6f95c55c3606f933',
 
                         '4f7e2131323e0749a740c0a56ab68ae9269c562a']
kallithea/tests/base.py
Show inline comments
 
@@ -66,17 +66,17 @@ TEST_USER_REGULAR2_EMAIL = 'test_regular
 

	
 
IP_ADDR = '127.0.0.127'
 

	
 
HG_REPO = u'vcs_test_hg'
 
GIT_REPO = u'vcs_test_git'
 
HG_REPO = 'vcs_test_hg'
 
GIT_REPO = 'vcs_test_git'
 

	
 
NEW_HG_REPO = u'vcs_test_hg_new'
 
NEW_GIT_REPO = u'vcs_test_git_new'
 
NEW_HG_REPO = 'vcs_test_hg_new'
 
NEW_GIT_REPO = 'vcs_test_git_new'
 

	
 
HG_FORK = u'vcs_test_hg_fork'
 
GIT_FORK = u'vcs_test_git_fork'
 
HG_FORK = 'vcs_test_hg_fork'
 
GIT_FORK = 'vcs_test_git_fork'
 

	
 
HG_TEST_REVISION = u"a53d9201d4bc278910d416d94941b7ea007ecd52"
 
GIT_TEST_REVISION = u"7ab37bc680b4aa72c34d07b230c866c28e9fc204"
 
HG_TEST_REVISION = "a53d9201d4bc278910d416d94941b7ea007ecd52"
 
GIT_TEST_REVISION = "7ab37bc680b4aa72c34d07b230c866c28e9fc204"
 

	
 

	
 
## VCS
 
@@ -180,14 +180,14 @@ class TestController(object):
 

	
 
    def checkSessionFlash(self, response, msg=None, skip=0, _matcher=lambda msg, m: msg in m):
 
        if 'flash' not in response.session:
 
            pytest.fail(u'msg `%s` not found - session has no flash:\n%s' % (msg, response))
 
            pytest.fail('msg `%s` not found - session has no flash:\n%s' % (msg, response))
 
        try:
 
            level, m = response.session['flash'][-1 - skip]
 
            if _matcher(msg, m):
 
                return
 
        except IndexError:
 
            pass
 
        pytest.fail(u'msg `%s` not found in session flash (skipping %s): %s' %
 
        pytest.fail('msg `%s` not found in session flash (skipping %s): %s' %
 
                    (msg, skip, ', '.join('`%s`' % m for level, m in response.session['flash'])))
 

	
 
    def checkSessionFlashRegex(self, response, regex, skip=0):
kallithea/tests/fixture.py
Show inline comments
 
@@ -92,8 +92,8 @@ class Fixture(object):
 
            repo_name=None,
 
            repo_type='hg',
 
            clone_uri='',
 
            repo_group=u'-1',
 
            repo_description=u'DESC',
 
            repo_group='-1',
 
            repo_description='DESC',
 
            repo_private=False,
 
            repo_landing_rev='rev:tip',
 
            repo_copy_permissions=False,
 
@@ -113,8 +113,8 @@ class Fixture(object):
 
        """Return form values to be validated through RepoGroupForm"""
 
        defs = dict(
 
            group_name=None,
 
            group_description=u'DESC',
 
            parent_group_id=u'-1',
 
            group_description='DESC',
 
            parent_group_id='-1',
 
            perms_updates=[],
 
            perms_new=[],
 
            recursive=False
 
@@ -128,8 +128,8 @@ class Fixture(object):
 
            username=name,
 
            password='qweqwe',
 
            email='%s+test@example.com' % name,
 
            firstname=u'TestUser',
 
            lastname=u'Test',
 
            firstname='TestUser',
 
            lastname='Test',
 
            active=True,
 
            admin=False,
 
            extern_type='internal',
 
@@ -142,7 +142,7 @@ class Fixture(object):
 
    def _get_user_group_create_params(self, name, **custom):
 
        defs = dict(
 
            users_group_name=name,
 
            user_group_description=u'DESC',
 
            user_group_description='DESC',
 
            users_group_active=True,
 
            user_group_data={},
 
        )
 
@@ -253,7 +253,7 @@ class Fixture(object):
 

	
 
    def create_gist(self, **kwargs):
 
        form_data = {
 
            'description': u'new-gist',
 
            'description': 'new-gist',
 
            'owner': TEST_USER_ADMIN_LOGIN,
 
            'gist_type': Gist.GIST_PUBLIC,
 
            'lifetime': -1,
 
@@ -324,12 +324,12 @@ class Fixture(object):
 
        return cs
 

	
 
    def review_changeset(self, repo, revision, status, author=TEST_USER_ADMIN_LOGIN):
 
        comment = ChangesetCommentsModel().create(u"review comment", repo, author, revision=revision, send_email=False)
 
        comment = ChangesetCommentsModel().create("review comment", repo, author, revision=revision, send_email=False)
 
        csm = ChangesetStatusModel().set_status(repo, ChangesetStatus.STATUS_APPROVED, author, comment, revision=revision)
 
        Session().commit()
 
        return csm
 

	
 
    def create_pullrequest(self, testcontroller, repo_name, pr_src_rev, pr_dst_rev, title=u'title'):
 
    def create_pullrequest(self, testcontroller, repo_name, pr_src_rev, pr_dst_rev, title='title'):
 
        org_ref = 'branch:stable:%s' % pr_src_rev
 
        other_ref = 'branch:default:%s' % pr_dst_rev
 
        with test_context(testcontroller.app): # needed to be able to mock request user
 
@@ -339,7 +339,7 @@ class Fixture(object):
 
            request.authuser = AuthUser(dbuser=owner_user)
 
            # creating a PR sends a message with an absolute URL - without routing that requires mocking
 
            with mock.patch.object(helpers, 'url', (lambda arg, qualified=False, **kwargs: ('https://localhost' if qualified else '') + '/fake/' + arg)):
 
                cmd = CreatePullRequestAction(org_repo, other_repo, org_ref, other_ref, title, u'No description', owner_user, reviewers)
 
                cmd = CreatePullRequestAction(org_repo, other_repo, org_ref, other_ref, title, 'No description', owner_user, reviewers)
 
                pull_request = cmd.execute()
 
            Session().commit()
 
        return pull_request.pull_request_id
kallithea/tests/functional/test_admin_auth_settings.py
Show inline comments
 
@@ -26,7 +26,7 @@ class TestAuthSettingsController(base.Te
 
        self.log_user()
 

	
 
        params = self._enable_plugins('kallithea.lib.auth_modules.auth_internal,kallithea.lib.auth_modules.auth_ldap')
 
        params.update({'auth_ldap_host': u'dc.example.com',
 
        params.update({'auth_ldap_host': 'dc.example.com',
 
                       'auth_ldap_port': '999',
 
                       'auth_ldap_tls_kind': 'PLAIN',
 
                       'auth_ldap_tls_reqcert': 'NEVER',
 
@@ -48,7 +48,7 @@ class TestAuthSettingsController(base.Te
 
        self.checkSessionFlash(response, 'Auth settings updated successfully')
 

	
 
        new_settings = Setting.get_auth_settings()
 
        assert new_settings['auth_ldap_host'] == u'dc.example.com', 'fail db write compare'
 
        assert new_settings['auth_ldap_host'] == 'dc.example.com', 'fail db write compare'
 

	
 
    @base.skipif(not base.ldap_lib_installed, reason='skipping due to missing ldap lib')
 
    def test_ldap_error_form_wrong_port_number(self):
 
@@ -239,7 +239,7 @@ class TestAuthSettingsController(base.Te
 
        self.checkSessionFlash(response, 'Auth settings updated successfully')
 

	
 
        new_settings = Setting.get_auth_settings()
 
        assert new_settings['auth_crowd_host'] == u'hostname', 'fail db write compare'
 
        assert new_settings['auth_crowd_host'] == 'hostname', 'fail db write compare'
 

	
 
    @base.skipif(not base.pam_lib_installed, reason='skipping due to missing pam lib')
 
    def test_pam_save_settings(self):
 
@@ -256,4 +256,4 @@ class TestAuthSettingsController(base.Te
 
        self.checkSessionFlash(response, 'Auth settings updated successfully')
 

	
 
        new_settings = Setting.get_auth_settings()
 
        assert new_settings['auth_pam_service'] == u'kallithea', 'fail db write compare'
 
        assert new_settings['auth_pam_service'] == 'kallithea', 'fail db write compare'
kallithea/tests/functional/test_admin_gists.py
Show inline comments
 
@@ -5,7 +5,7 @@ from kallithea.tests import base
 

	
 

	
 
def _create_gist(f_name, content='some gist', lifetime=-1,
 
                 description=u'gist-desc', gist_type='public',
 
                 description='gist-desc', gist_type='public',
 
                 owner=base.TEST_USER_ADMIN_LOGIN):
 
    gist_mapping = {
 
        f_name: {'content': content}
 
@@ -33,7 +33,7 @@ class TestGistsController(base.TestContr
 

	
 
        g1 = _create_gist('gist1').gist_access_id
 
        g2 = _create_gist('gist2', lifetime=1400).gist_access_id
 
        g3 = _create_gist('gist3', description=u'gist3-desc').gist_access_id
 
        g3 = _create_gist('gist3', description='gist3-desc').gist_access_id
 
        g4 = _create_gist('gist4', gist_type='private').gist_access_id
 
        response = self.app.get(base.url('gists'))
 
        # Test response...
kallithea/tests/functional/test_admin_repo_groups.py
Show inline comments
 
@@ -11,7 +11,7 @@ class TestRepoGroupsController(TestContr
 

	
 
    def test_case_insensitivity(self):
 
        self.log_user()
 
        group_name = u'newgroup'
 
        group_name = 'newgroup'
 
        response = self.app.post(url('repos_groups'),
 
                                 fixture._get_repo_group_create_params(group_name=group_name,
 
                                                                 _session_csrf_secret_token=self.session_csrf_secret_token()))
kallithea/tests/functional/test_admin_repos.py
Show inline comments
 
@@ -45,7 +45,7 @@ class _BaseTestCase(base.TestController)
 
    def test_create(self):
 
        self.log_user()
 
        repo_name = self.NEW_REPO
 
        description = u'description for newly created repo'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
 
                                                repo_name=repo_name,
 
@@ -54,7 +54,7 @@ class _BaseTestCase(base.TestController)
 
                                                _session_csrf_secret_token=self.session_csrf_secret_token()))
 
        ## run the check page that triggers the flash message
 
        response = self.app.get(base.url('repo_check_home', repo_name=repo_name))
 
        assert response.json == {u'result': True}
 
        assert response.json == {'result': True}
 
        self.checkSessionFlash(response,
 
                               'Created repository <a href="/%s">%s</a>'
 
                               % (repo_name, repo_name))
 
@@ -83,7 +83,7 @@ class _BaseTestCase(base.TestController)
 
    def test_case_insensitivity(self):
 
        self.log_user()
 
        repo_name = self.NEW_REPO
 
        description = u'description for newly created repo'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                                 fixture._get_repo_create_params(repo_private=False,
 
                                                                 repo_name=repo_name,
 
@@ -107,15 +107,15 @@ class _BaseTestCase(base.TestController)
 
        self.log_user()
 

	
 
        ## create GROUP
 
        group_name = u'sometest_%s' % self.REPO_TYPE
 
        group_name = 'sometest_%s' % self.REPO_TYPE
 
        gr = RepoGroupModel().create(group_name=group_name,
 
                                     group_description=u'test',
 
                                     group_description='test',
 
                                     owner=base.TEST_USER_ADMIN_LOGIN)
 
        Session().commit()
 

	
 
        repo_name = u'ingroup'
 
        repo_name = 'ingroup'
 
        repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
 
        description = u'description for newly created repo'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
 
                                                repo_name=repo_name,
 
@@ -125,7 +125,7 @@ class _BaseTestCase(base.TestController)
 
                                                _session_csrf_secret_token=self.session_csrf_secret_token()))
 
        ## run the check page that triggers the flash message
 
        response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full))
 
        assert response.json == {u'result': True}
 
        assert response.json == {'result': True}
 
        self.checkSessionFlash(response,
 
                               'Created repository <a href="/%s">%s</a>'
 
                               % (repo_name_full, repo_name_full))
 
@@ -178,21 +178,21 @@ class _BaseTestCase(base.TestController)
 
        Session().commit()
 

	
 
        ## create GROUP
 
        group_name = u'reg_sometest_%s' % self.REPO_TYPE
 
        group_name = 'reg_sometest_%s' % self.REPO_TYPE
 
        gr = RepoGroupModel().create(group_name=group_name,
 
                                     group_description=u'test',
 
                                     group_description='test',
 
                                     owner=base.TEST_USER_ADMIN_LOGIN)
 
        Session().commit()
 

	
 
        group_name_allowed = u'reg_sometest_allowed_%s' % self.REPO_TYPE
 
        group_name_allowed = 'reg_sometest_allowed_%s' % self.REPO_TYPE
 
        gr_allowed = RepoGroupModel().create(group_name=group_name_allowed,
 
                                     group_description=u'test',
 
                                     group_description='test',
 
                                     owner=base.TEST_USER_REGULAR_LOGIN)
 
        Session().commit()
 

	
 
        repo_name = u'ingroup'
 
        repo_name = 'ingroup'
 
        repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
 
        description = u'description for newly created repo'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
 
                                                repo_name=repo_name,
 
@@ -204,9 +204,9 @@ class _BaseTestCase(base.TestController)
 
        response.mustcontain('Invalid value')
 

	
 
        # user is allowed to create in this group
 
        repo_name = u'ingroup'
 
        repo_name = 'ingroup'
 
        repo_name_full = RepoGroup.url_sep().join([group_name_allowed, repo_name])
 
        description = u'description for newly created repo'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
 
                                                repo_name=repo_name,
 
@@ -217,7 +217,7 @@ class _BaseTestCase(base.TestController)
 

	
 
        ## run the check page that triggers the flash message
 
        response = self.app.get(base.url('repo_check_home', repo_name=repo_name_full))
 
        assert response.json == {u'result': True}
 
        assert response.json == {'result': True}
 
        self.checkSessionFlash(response,
 
                               'Created repository <a href="/%s">%s</a>'
 
                               % (repo_name_full, repo_name_full))
 
@@ -255,9 +255,9 @@ class _BaseTestCase(base.TestController)
 
        self.log_user()
 

	
 
        ## create GROUP
 
        group_name = u'sometest_%s' % self.REPO_TYPE
 
        group_name = 'sometest_%s' % self.REPO_TYPE
 
        gr = RepoGroupModel().create(group_name=group_name,
 
                                     group_description=u'test',
 
                                     group_description='test',
 
                                     owner=base.TEST_USER_ADMIN_LOGIN)
 
        perm = Permission.get_by_key('repository.write')
 
        RepoGroupModel().grant_user_permission(gr, base.TEST_USER_REGULAR_LOGIN, perm)
 
@@ -265,9 +265,9 @@ class _BaseTestCase(base.TestController)
 
        ## add repo permissions
 
        Session().commit()
 

	
 
        repo_name = u'ingroup_inherited_%s' % self.REPO_TYPE
 
        repo_name = 'ingroup_inherited_%s' % self.REPO_TYPE
 
        repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
 
        description = u'description for newly created repo'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
 
                                                repo_name=repo_name,
 
@@ -320,7 +320,7 @@ class _BaseTestCase(base.TestController)
 
    def test_create_remote_repo_wrong_clone_uri(self):
 
        self.log_user()
 
        repo_name = self.NEW_REPO
 
        description = u'description for newly created repo'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
 
                                                repo_name=repo_name,
 
@@ -333,7 +333,7 @@ class _BaseTestCase(base.TestController)
 
    def test_create_remote_repo_wrong_clone_uri_hg_svn(self):
 
        self.log_user()
 
        repo_name = self.NEW_REPO
 
        description = u'description for newly created repo'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
 
                                                repo_name=repo_name,
 
@@ -345,8 +345,8 @@ class _BaseTestCase(base.TestController)
 

	
 
    def test_delete(self):
 
        self.log_user()
 
        repo_name = u'vcs_test_new_to_delete_%s' % self.REPO_TYPE
 
        description = u'description for newly created repo'
 
        repo_name = 'vcs_test_new_to_delete_%s' % self.REPO_TYPE
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
 
                                                repo_type=self.REPO_TYPE,
 
@@ -404,9 +404,9 @@ class _BaseTestCase(base.TestController)
 
                                                _session_csrf_secret_token=self.session_csrf_secret_token()))
 
        ## run the check page that triggers the flash message
 
        response = self.app.get(base.url('repo_check_home', repo_name=repo_name))
 
        assert response.json == {u'result': True}
 
        assert response.json == {'result': True}
 
        self.checkSessionFlash(response,
 
                               u'Created repository <a href="/%s">%s</a>'
 
                               'Created repository <a href="/%s">%s</a>'
 
                               % (urllib.parse.quote(repo_name), repo_name))
 
        # test if the repo was created in the database
 
        new_repo = Session().query(Repository) \
 
@@ -505,7 +505,7 @@ class _BaseTestCase(base.TestController)
 

	
 
    def test_set_fork_of_other_repo(self):
 
        self.log_user()
 
        other_repo = u'other_%s' % self.REPO_TYPE
 
        other_repo = 'other_%s' % self.REPO_TYPE
 
        fixture.create_repo(other_repo, repo_type=self.REPO_TYPE)
 
        repo = Repository.get_by_repo_name(self.REPO)
 
        repo2 = Repository.get_by_repo_name(other_repo)
 
@@ -577,7 +577,7 @@ class _BaseTestCase(base.TestController)
 

	
 
        user = User.get(usr['user_id'])
 

	
 
        repo_name = self.NEW_REPO + u'no_perms'
 
        repo_name = self.NEW_REPO + 'no_perms'
 
        description = 'description for newly created repo'
 
        response = self.app.post(base.url('repos'),
 
                        fixture._get_repo_create_params(repo_private=False,
kallithea/tests/functional/test_admin_user_groups.py
Show inline comments
 
@@ -4,7 +4,7 @@ from kallithea.model.meta import Session
 
from kallithea.tests import base
 

	
 

	
 
TEST_USER_GROUP = u'admins_test'
 
TEST_USER_GROUP = 'admins_test'
 

	
 

	
 
class TestAdminUsersGroupsController(base.TestController):
 
@@ -19,7 +19,7 @@ class TestAdminUsersGroupsController(bas
 
        users_group_name = TEST_USER_GROUP
 
        response = self.app.post(base.url('users_groups'),
 
                                 {'users_group_name': users_group_name,
 
                                  'user_group_description': u'DESC',
 
                                  'user_group_description': 'DESC',
 
                                  'active': True,
 
                                  '_session_csrf_secret_token': self.session_csrf_secret_token()})
 
        response.follow()
 
@@ -44,7 +44,7 @@ class TestAdminUsersGroupsController(bas
 
        users_group_name = TEST_USER_GROUP + 'another'
 
        response = self.app.post(base.url('users_groups'),
 
                                 {'users_group_name': users_group_name,
 
                                  'user_group_description': u'DESC',
 
                                  'user_group_description': 'DESC',
 
                                  'active': True,
 
                                  '_session_csrf_secret_token': self.session_csrf_secret_token()})
 
        response.follow()
 
@@ -68,7 +68,7 @@ class TestAdminUsersGroupsController(bas
 
        users_group_name = TEST_USER_GROUP + 'another2'
 
        response = self.app.post(base.url('users_groups'),
 
                                 {'users_group_name': users_group_name,
 
                                  'user_group_description': u'DESC',
 
                                  'user_group_description': 'DESC',
 
                                  'active': True,
 
                                  '_session_csrf_secret_token': self.session_csrf_secret_token()})
 
        response.follow()
 
@@ -137,7 +137,7 @@ class TestAdminUsersGroupsController(bas
 
        users_group_name = TEST_USER_GROUP + 'another2'
 
        response = self.app.post(base.url('users_groups'),
 
                                 {'users_group_name': users_group_name,
 
                                  'user_group_description': u'DESC',
 
                                  'user_group_description': 'DESC',
 
                                  'active': True,
 
                                  '_session_csrf_secret_token': self.session_csrf_secret_token()})
 
        response.follow()
kallithea/tests/functional/test_admin_users.py
Show inline comments
 
@@ -34,7 +34,7 @@ fixture = Fixture()
 
@pytest.fixture
 
def user_and_repo_group_fail():
 
    username = 'repogrouperr'
 
    groupname = u'repogroup_fail'
 
    groupname = 'repogroup_fail'
 
    user = fixture.create_user(name=username)
 
    repo_group = fixture.create_repo_group(name=groupname, cur_user=username)
 
    yield user, repo_group
 
@@ -62,8 +62,8 @@ class TestAdminUsersController(base.Test
 
        username = 'newtestuser'
 
        password = 'test12'
 
        password_confirmation = password
 
        name = u'name'
 
        lastname = u'lastname'
 
        name = 'name'
 
        lastname = 'lastname'
 
        email = 'mail@example.com'
 

	
 
        response = self.app.post(base.url('new_user'),
 
@@ -98,8 +98,8 @@ class TestAdminUsersController(base.Test
 
        self.log_user()
 
        username = 'new_user'
 
        password = ''
 
        name = u'name'
 
        lastname = u'lastname'
 
        name = 'name'
 
        lastname = 'lastname'
 
        email = 'errmail.example.com'
 

	
 
        response = self.app.post(base.url('new_user'),
 
@@ -194,7 +194,7 @@ class TestAdminUsersController(base.Test
 
    def test_delete_repo_err(self):
 
        self.log_user()
 
        username = 'repoerr'
 
        reponame = u'repoerr_fail'
 
        reponame = 'repoerr_fail'
 

	
 
        fixture.create_user(name=username)
 
        fixture.create_repo(name=reponame, cur_user=username)
 
@@ -245,7 +245,7 @@ class TestAdminUsersController(base.Test
 
    def test_delete_user_group_err(self):
 
        self.log_user()
 
        username = 'usergrouperr'
 
        groupname = u'usergroup_fail'
 
        groupname = 'usergroup_fail'
 

	
 
        fixture.create_user(name=username)
 
        ug = fixture.create_user_group(name=groupname, cur_user=username)
 
@@ -280,8 +280,8 @@ class TestAdminUsersController(base.Test
 
        perm_create = Permission.get_by_key('hg.create.repository')
 

	
 
        user = UserModel().create_or_update(username='dummy', password='qwe',
 
                                            email='dummy', firstname=u'a',
 
                                            lastname=u'b')
 
                                            email='dummy', firstname='a',
 
                                            lastname='b')
 
        Session().commit()
 
        uid = user.user_id
 

	
 
@@ -310,8 +310,8 @@ class TestAdminUsersController(base.Test
 
        perm_create = Permission.get_by_key('hg.create.repository')
 

	
 
        user = UserModel().create_or_update(username='dummy', password='qwe',
 
                                            email='dummy', firstname=u'a',
 
                                            lastname=u'b')
 
                                            email='dummy', firstname='a',
 
                                            lastname='b')
 
        Session().commit()
 
        uid = user.user_id
 

	
 
@@ -339,8 +339,8 @@ class TestAdminUsersController(base.Test
 
        perm_fork = Permission.get_by_key('hg.fork.repository')
 

	
 
        user = UserModel().create_or_update(username='dummy', password='qwe',
 
                                            email='dummy', firstname=u'a',
 
                                            lastname=u'b')
 
                                            email='dummy', firstname='a',
 
                                            lastname='b')
 
        Session().commit()
 
        uid = user.user_id
 

	
 
@@ -369,8 +369,8 @@ class TestAdminUsersController(base.Test
 
        perm_fork = Permission.get_by_key('hg.fork.repository')
 

	
 
        user = UserModel().create_or_update(username='dummy', password='qwe',
 
                                            email='dummy', firstname=u'a',
 
                                            lastname=u'b')
 
                                            email='dummy', firstname='a',
 
                                            lastname='b')
 
        Session().commit()
 
        uid = user.user_id
 

	
 
@@ -515,9 +515,9 @@ class TestAdminUsersController(base.Test
 
        response.mustcontain(no=[api_key])
 

	
 
    def test_add_ssh_key(self):
 
        description = u'something'
 
        public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost'
 
        fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
 
        description = 'something'
 
        public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost'
 
        fingerprint = 'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
 

	
 
        self.log_user()
 
        user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
 
@@ -538,9 +538,9 @@ class TestAdminUsersController(base.Test
 
        Session().commit()
 

	
 
    def test_remove_ssh_key(self):
 
        description = u''
 
        public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost'
 
        fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
 
        description = ''
 
        public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost'
 
        fingerprint = 'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
 

	
 
        self.log_user()
 
        user = User.get_by_username(base.TEST_USER_REGULAR_LOGIN)
 
@@ -553,7 +553,7 @@ class TestAdminUsersController(base.Test
 
        self.checkSessionFlash(response, 'SSH key %s successfully added' % fingerprint)
 
        response.follow()
 
        ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one()
 
        assert ssh_key.description == u'me@localhost'
 
        assert ssh_key.description == 'me@localhost'
 

	
 
        response = self.app.post(base.url('edit_user_ssh_keys_delete', id=user_id),
 
                                 {'del_public_key_fingerprint': ssh_key.fingerprint,
kallithea/tests/functional/test_changeset_pullrequests_comments.py
Show inline comments
 
@@ -16,7 +16,7 @@ class TestChangeSetCommentsController(ba
 
    def test_create(self):
 
        self.log_user()
 
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
 
        text = u'general comment on changeset'
 
        text = 'general comment on changeset'
 

	
 
        params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='changeset', action='comment',
 
@@ -39,7 +39,7 @@ class TestChangeSetCommentsController(ba
 
    def test_create_inline(self):
 
        self.log_user()
 
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
 
        text = u'inline comment on changeset'
 
        text = 'inline comment on changeset'
 
        f_path = 'vcs/web/simplevcs/views/repository.py'
 
        line = 'n1'
 

	
 
@@ -70,7 +70,7 @@ class TestChangeSetCommentsController(ba
 
        self.log_user()
 

	
 
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
 
        text = u'@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN
 
        text = '@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN
 

	
 
        params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='changeset', action='comment',
 
@@ -93,7 +93,7 @@ class TestChangeSetCommentsController(ba
 
    def test_create_status_change(self):
 
        self.log_user()
 
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
 
        text = u'general comment on changeset'
 
        text = 'general comment on changeset'
 

	
 
        params = {'text': text, 'changeset_status': 'rejected',
 
                '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
@@ -121,7 +121,7 @@ class TestChangeSetCommentsController(ba
 
    def test_delete(self):
 
        self.log_user()
 
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
 
        text = u'general comment on changeset to be deleted'
 
        text = 'general comment on changeset to be deleted'
 

	
 
        params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='changeset', action='comment',
 
@@ -175,7 +175,7 @@ class TestPullrequestsCommentsController
 
        self.log_user()
 
        pr_id = self._create_pr()
 

	
 
        text = u'general comment on pullrequest'
 
        text = 'general comment on pullrequest'
 
        params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='pullrequests', action='comment',
 
                                     repo_name=base.HG_REPO, pull_request_id=pr_id),
 
@@ -201,7 +201,7 @@ class TestPullrequestsCommentsController
 
        self.log_user()
 
        pr_id = self._create_pr()
 

	
 
        text = u'inline comment on changeset'
 
        text = 'inline comment on changeset'
 
        f_path = 'vcs/web/simplevcs/views/repository.py'
 
        line = 'n1'
 
        params = {'text': text, 'f_path': f_path, 'line': line, '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
@@ -231,7 +231,7 @@ class TestPullrequestsCommentsController
 
        self.log_user()
 
        pr_id = self._create_pr()
 

	
 
        text = u'@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN
 
        text = '@%s check CommentOnRevision' % base.TEST_USER_REGULAR_LOGIN
 
        params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='pullrequests', action='comment',
 
                                     repo_name=base.HG_REPO, pull_request_id=pr_id),
 
@@ -254,7 +254,7 @@ class TestPullrequestsCommentsController
 
        self.log_user()
 
        pr_id = self._create_pr()
 

	
 
        text = u'general comment on pullrequest'
 
        text = 'general comment on pullrequest'
 
        params = {'text': text, 'changeset_status': 'rejected',
 
                '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='pullrequests', action='comment',
 
@@ -285,7 +285,7 @@ class TestPullrequestsCommentsController
 
        self.log_user()
 
        pr_id = self._create_pr()
 

	
 
        text = u'general comment on changeset to be deleted'
 
        text = 'general comment on changeset to be deleted'
 
        params = {'text': text, '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='pullrequests', action='comment',
 
                                     repo_name=base.HG_REPO, pull_request_id=pr_id),
 
@@ -315,7 +315,7 @@ class TestPullrequestsCommentsController
 
        self.log_user()
 
        pr_id = self._create_pr()
 

	
 
        text = u'general comment on pullrequest'
 
        text = 'general comment on pullrequest'
 
        params = {'text': text, 'save_close': 'close',
 
                '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='pullrequests', action='comment',
 
@@ -338,7 +338,7 @@ class TestPullrequestsCommentsController
 
        self.log_user()
 
        pr_id = self._create_pr()
 

	
 
        text = u'general comment on pullrequest'
 
        text = 'general comment on pullrequest'
 
        params = {'text': text, 'save_delete': 'delete',
 
                '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='pullrequests', action='comment',
 
@@ -358,7 +358,7 @@ class TestPullrequestsCommentsController
 
        pr_id = self._create_pr()
 

	
 
        # first close
 
        text = u'general comment on pullrequest'
 
        text = 'general comment on pullrequest'
 
        params = {'text': text, 'save_close': 'close',
 
                '_session_csrf_secret_token': self.session_csrf_secret_token()}
 
        response = self.app.post(base.url(controller='pullrequests', action='comment',
kallithea/tests/functional/test_compare.py
Show inline comments
 
@@ -28,7 +28,7 @@ class TestCompareController(base.TestCon
 

	
 
    def test_compare_forks_on_branch_extra_commits_hg(self):
 
        self.log_user()
 
        repo1 = fixture.create_repo(u'one', repo_type='hg',
 
        repo1 = fixture.create_repo('one', repo_type='hg',
 
                                    repo_description='diff-test',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 
        self.r1_id = repo1.repo_id
 
@@ -38,7 +38,7 @@ class TestCompareController(base.TestCon
 
                parent=None, newfile=True)
 

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

	
 
        # add two extra commit into fork
 
@@ -79,7 +79,7 @@ class TestCompareController(base.TestCon
 

	
 
    def test_compare_forks_on_branch_extra_commits_git(self):
 
        self.log_user()
 
        repo1 = fixture.create_repo(u'one-git', repo_type='git',
 
        repo1 = fixture.create_repo('one-git', repo_type='git',
 
                                    repo_description='diff-test',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 
        self.r1_id = repo1.repo_id
 
@@ -89,7 +89,7 @@ class TestCompareController(base.TestCon
 
                parent=None, newfile=True)
 

	
 
        # fork this repo
 
        repo2 = fixture.create_fork(u'one-git', u'one-git-fork')
 
        repo2 = fixture.create_fork('one-git', 'one-git-fork')
 
        self.r2_id = repo2.repo_id
 

	
 
        # add two extra commit into fork
 
@@ -131,7 +131,7 @@ class TestCompareController(base.TestCon
 
    def test_compare_forks_on_branch_extra_commits_origin_has_incoming_hg(self):
 
        self.log_user()
 

	
 
        repo1 = fixture.create_repo(u'one', repo_type='hg',
 
        repo1 = fixture.create_repo('one', repo_type='hg',
 
                                    repo_description='diff-test',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 

	
 
@@ -143,7 +143,7 @@ class TestCompareController(base.TestCon
 
                parent=None, newfile=True)
 

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

	
 
        # now commit something to origin repo
 
@@ -190,7 +190,7 @@ class TestCompareController(base.TestCon
 
    def test_compare_forks_on_branch_extra_commits_origin_has_incoming_git(self):
 
        self.log_user()
 

	
 
        repo1 = fixture.create_repo(u'one-git', repo_type='git',
 
        repo1 = fixture.create_repo('one-git', repo_type='git',
 
                                    repo_description='diff-test',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 

	
 
@@ -202,7 +202,7 @@ class TestCompareController(base.TestCon
 
                parent=None, newfile=True)
 

	
 
        # fork this repo
 
        repo2 = fixture.create_fork(u'one-git', u'one-git-fork')
 
        repo2 = fixture.create_fork('one-git', 'one-git-fork')
 
        self.r2_id = repo2.repo_id
 

	
 
        # now commit something to origin repo
 
@@ -261,7 +261,7 @@ class TestCompareController(base.TestCon
 
        # make repo1, and cs1+cs2
 
        self.log_user()
 

	
 
        repo1 = fixture.create_repo(u'repo1', repo_type='hg',
 
        repo1 = fixture.create_repo('repo1', repo_type='hg',
 
                                    repo_description='diff-test',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 
        self.r1_id = repo1.repo_id
 
@@ -274,7 +274,7 @@ class TestCompareController(base.TestCon
 
                content='line1\nline2\n', message='commit2', vcs_type='hg',
 
                parent=cs0)
 
        # fork this repo
 
        repo2 = fixture.create_fork(u'repo1', u'repo1-fork')
 
        repo2 = fixture.create_fork('repo1', 'repo1-fork')
 
        self.r2_id = repo2.repo_id
 
        # now make cs3-6
 
        cs2 = fixture.commit_change(repo1.repo_name, filename='file1',
 
@@ -329,7 +329,7 @@ class TestCompareController(base.TestCon
 
#
 
        # make repo1, and cs1+cs2
 
        self.log_user()
 
        repo1 = fixture.create_repo(u'repo1', repo_type='hg',
 
        repo1 = fixture.create_repo('repo1', repo_type='hg',
 
                                    repo_description='diff-test',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 
        self.r1_id = repo1.repo_id
 
@@ -342,7 +342,7 @@ class TestCompareController(base.TestCon
 
                content='line1\nline2\n', message='commit2', vcs_type='hg',
 
                parent=cs0)
 
        # fork this repo
 
        repo2 = fixture.create_fork(u'repo1', u'repo1-fork')
 
        repo2 = fixture.create_fork('repo1', 'repo1-fork')
 
        self.r2_id = repo2.repo_id
 
        # now make cs3-6
 
        cs2 = fixture.commit_change(repo1.repo_name, filename='file1',
 
@@ -448,7 +448,7 @@ class TestCompareController(base.TestCon
 
    def test_org_repo_new_commits_after_forking_simple_diff_hg(self):
 
        self.log_user()
 

	
 
        repo1 = fixture.create_repo(u'one', repo_type='hg',
 
        repo1 = fixture.create_repo('one', repo_type='hg',
 
                                    repo_description='diff-test',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 

	
 
@@ -460,7 +460,7 @@ class TestCompareController(base.TestCon
 
        Session().commit()
 
        assert repo1.scm_instance.revisions == [cs0.raw_id]
 
        # fork the repo1
 
        repo2 = fixture.create_fork(r1_name, u'one-fork',
 
        repo2 = fixture.create_fork(r1_name, 'one-fork',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 
        Session().commit()
 
        assert repo2.scm_instance.revisions == [cs0.raw_id]
 
@@ -520,7 +520,7 @@ class TestCompareController(base.TestCon
 
    def test_org_repo_new_commits_after_forking_simple_diff_git(self):
 
        self.log_user()
 

	
 
        repo1 = fixture.create_repo(u'one-git', repo_type='git',
 
        repo1 = fixture.create_repo('one-git', repo_type='git',
 
                                    repo_description='diff-test',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 

	
 
@@ -533,7 +533,7 @@ class TestCompareController(base.TestCon
 
        Session().commit()
 
        assert repo1.scm_instance.revisions == [cs0.raw_id]
 
        # fork the repo1
 
        repo2 = fixture.create_fork(r1_name, u'one-git-fork',
 
        repo2 = fixture.create_fork(r1_name, 'one-git-fork',
 
                                    cur_user=base.TEST_USER_ADMIN_LOGIN)
 
        Session().commit()
 
        assert repo2.scm_instance.revisions == [cs0.raw_id]
kallithea/tests/functional/test_files.py
Show inline comments
 
@@ -252,7 +252,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_raw_file_wrong_cs(self):
 
        self.log_user()
 
        rev = u'ERRORce30c96924232dffcd24178a07ffeb5dfc'
 
        rev = 'ERRORce30c96924232dffcd24178a07ffeb5dfc'
 
        f_path = 'vcs/nodes.py'
 

	
 
        response = self.app.get(base.url(controller='files', action='rawfile',
 
@@ -289,7 +289,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_raw_wrong_cs(self):
 
        self.log_user()
 
        rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc'
 
        rev = 'ERRORcce30c96924232dffcd24178a07ffeb5dfc'
 
        f_path = 'vcs/nodes.py'
 

	
 
        response = self.app.get(base.url(controller='files', action='raw',
 
@@ -381,7 +381,7 @@ class TestFilesController(base.TestContr
 
    ])
 
    def test_add_file_into_hg(self, cnt, location, filename):
 
        self.log_user()
 
        repo = fixture.create_repo(u'commit-test-%s' % cnt, repo_type='hg')
 
        repo = fixture.create_repo('commit-test-%s' % cnt, repo_type='hg')
 
        response = self.app.post(base.url('files_add_home',
 
                                      repo_name=repo.repo_name,
 
                                      revision='tip', f_path='/'),
 
@@ -457,7 +457,7 @@ class TestFilesController(base.TestContr
 
    ])
 
    def test_add_file_into_git(self, cnt, location, filename):
 
        self.log_user()
 
        repo = fixture.create_repo(u'commit-test-%s' % cnt, repo_type='git')
 
        repo = fixture.create_repo('commit-test-%s' % cnt, repo_type='git')
 
        response = self.app.post(base.url('files_add_home',
 
                                      repo_name=repo.repo_name,
 
                                      revision='tip', f_path='/'),
 
@@ -492,7 +492,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_edit_file_view_not_on_branch_hg(self):
 
        self.log_user()
 
        repo = fixture.create_repo(u'test-edit-repo', repo_type='hg')
 
        repo = fixture.create_repo('test-edit-repo', repo_type='hg')
 

	
 
        ## add file
 
        location = 'vcs'
 
@@ -522,7 +522,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_edit_file_view_commit_changes_hg(self):
 
        self.log_user()
 
        repo = fixture.create_repo(u'test-edit-repo', repo_type='hg')
 
        repo = fixture.create_repo('test-edit-repo', repo_type='hg')
 

	
 
        ## add file
 
        location = 'vcs'
 
@@ -566,7 +566,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_edit_file_view_not_on_branch_git(self):
 
        self.log_user()
 
        repo = fixture.create_repo(u'test-edit-repo', repo_type='git')
 
        repo = fixture.create_repo('test-edit-repo', repo_type='git')
 

	
 
        ## add file
 
        location = 'vcs'
 
@@ -596,7 +596,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_edit_file_view_commit_changes_git(self):
 
        self.log_user()
 
        repo = fixture.create_repo(u'test-edit-repo', repo_type='git')
 
        repo = fixture.create_repo('test-edit-repo', repo_type='git')
 

	
 
        ## add file
 
        location = 'vcs'
 
@@ -640,7 +640,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_delete_file_view_not_on_branch_hg(self):
 
        self.log_user()
 
        repo = fixture.create_repo(u'test-delete-repo', repo_type='hg')
 
        repo = fixture.create_repo('test-delete-repo', repo_type='hg')
 

	
 
        ## add file
 
        location = 'vcs'
 
@@ -670,7 +670,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_delete_file_view_commit_changes_hg(self):
 
        self.log_user()
 
        repo = fixture.create_repo(u'test-delete-repo', repo_type='hg')
 
        repo = fixture.create_repo('test-delete-repo', repo_type='hg')
 

	
 
        ## add file
 
        location = 'vcs'
 
@@ -713,7 +713,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_delete_file_view_not_on_branch_git(self):
 
        self.log_user()
 
        repo = fixture.create_repo(u'test-delete-repo', repo_type='git')
 
        repo = fixture.create_repo('test-delete-repo', repo_type='git')
 

	
 
        ## add file
 
        location = 'vcs'
 
@@ -743,7 +743,7 @@ class TestFilesController(base.TestContr
 

	
 
    def test_delete_file_view_commit_changes_git(self):
 
        self.log_user()
 
        repo = fixture.create_repo(u'test-delete-repo', repo_type='git')
 
        repo = fixture.create_repo('test-delete-repo', repo_type='git')
 

	
 
        ## add file
 
        location = 'vcs'
kallithea/tests/functional/test_forks.py
Show inline comments
 
@@ -23,9 +23,9 @@ class _BaseTestCase(base.TestController)
 
    REPO_FORK = None
 

	
 
    def setup_method(self, method):
 
        self.username = u'forkuser'
 
        self.password = u'qweqwe'
 
        u1 = fixture.create_user(self.username, password=self.password, email=u'fork_king@example.com')
 
        self.username = 'forkuser'
 
        self.password = 'qweqwe'
 
        u1 = fixture.create_user(self.username, password=self.password, email='fork_king@example.com')
 
        self.u1_id = u1.user_id
 
        Session().commit()
 

	
 
@@ -69,7 +69,7 @@ class _BaseTestCase(base.TestController)
 
        org_repo = Repository.get_by_repo_name(repo_name)
 
        creation_args = {
 
            'repo_name': fork_name,
 
            'repo_group': u'-1',
 
            'repo_group': '-1',
 
            'fork_parent_id': org_repo.repo_id,
 
            'repo_type': self.REPO_TYPE,
 
            'description': description,
 
@@ -93,7 +93,7 @@ class _BaseTestCase(base.TestController)
 

	
 
    def test_fork_create_into_group(self):
 
        self.log_user()
 
        group = fixture.create_repo_group(u'vc')
 
        group = fixture.create_repo_group('vc')
 
        group_id = group.group_id
 
        fork_name = self.REPO_FORK
 
        fork_name_full = 'vc/%s' % fork_name
 
@@ -143,10 +143,10 @@ class _BaseTestCase(base.TestController)
 
        # create a fork
 
        repo_name = self.REPO
 
        org_repo = Repository.get_by_repo_name(repo_name)
 
        fork_name = self.REPO_FORK + u'-rødgrød'
 
        fork_name = self.REPO_FORK + '-rødgrød'
 
        creation_args = {
 
            'repo_name': fork_name,
 
            'repo_group': u'-1',
 
            'repo_group': '-1',
 
            'fork_parent_id': org_repo.repo_id,
 
            'repo_type': self.REPO_TYPE,
 
            'description': 'unicode repo 1',
 
@@ -164,10 +164,10 @@ class _BaseTestCase(base.TestController)
 
        assert fork_repo
 

	
 
        # fork the fork
 
        fork_name_2 = self.REPO_FORK + u'-blåbærgrød'
 
        fork_name_2 = self.REPO_FORK + '-blåbærgrød'
 
        creation_args = {
 
            'repo_name': fork_name_2,
 
            'repo_group': u'-1',
 
            'repo_group': '-1',
 
            'fork_parent_id': fork_repo.repo_id,
 
            'repo_type': self.REPO_TYPE,
 
            'description': 'unicode repo 2',
 
@@ -196,7 +196,7 @@ class _BaseTestCase(base.TestController)
 
        org_repo = Repository.get_by_repo_name(repo_name)
 
        creation_args = {
 
            'repo_name': fork_name,
 
            'repo_group': u'-1',
 
            'repo_group': '-1',
 
            'fork_parent_id': org_repo.repo_id,
 
            'repo_type': self.REPO_TYPE,
 
            'description': description,
kallithea/tests/functional/test_home.py
Show inline comments
 
@@ -53,35 +53,35 @@ class TestHomeController(base.TestContro
 

	
 
    def test_index_page_on_groups(self):
 
        self.log_user()
 
        gr = fixture.create_repo_group(u'gr1')
 
        fixture.create_repo(name=u'gr1/repo_in_group', repo_group=gr)
 
        response = self.app.get(base.url('repos_group_home', group_name=u'gr1'))
 
        gr = fixture.create_repo_group('gr1')
 
        fixture.create_repo(name='gr1/repo_in_group', repo_group=gr)
 
        response = self.app.get(base.url('repos_group_home', group_name='gr1'))
 

	
 
        try:
 
            response.mustcontain(u"gr1/repo_in_group")
 
            response.mustcontain("gr1/repo_in_group")
 
        finally:
 
            RepoModel().delete(u'gr1/repo_in_group')
 
            RepoGroupModel().delete(repo_group=u'gr1', force_delete=True)
 
            RepoModel().delete('gr1/repo_in_group')
 
            RepoGroupModel().delete(repo_group='gr1', force_delete=True)
 
            Session().commit()
 

	
 
    def test_users_and_groups_data(self):
 
        fixture.create_user('evil', firstname=u'D\'o\'ct"o"r', lastname=u'Évíl')
 
        fixture.create_user_group(u'grrrr', user_group_description=u"Groüp")
 
        response = self.app.get(base.url('users_and_groups_data', query=u'evi'))
 
        fixture.create_user('evil', firstname='D\'o\'ct"o"r', lastname='Évíl')
 
        fixture.create_user_group('grrrr', user_group_description="Groüp")
 
        response = self.app.get(base.url('users_and_groups_data', query='evi'))
 
        assert response.status_code == 302
 
        assert base.url('login_home') in response.location
 
        self.log_user(base.TEST_USER_REGULAR_LOGIN, base.TEST_USER_REGULAR_PASS)
 
        response = self.app.get(base.url('users_and_groups_data', query=u'evi'))
 
        response = self.app.get(base.url('users_and_groups_data', query='evi'))
 
        result = json.loads(response.body)['results']
 
        assert result[0].get('fname') == u'D\'o\'ct"o"r'
 
        assert result[0].get('lname') == u'Évíl'
 
        response = self.app.get(base.url('users_and_groups_data', key=u'evil'))
 
        assert result[0].get('fname') == 'D\'o\'ct"o"r'
 
        assert result[0].get('lname') == 'Évíl'
 
        response = self.app.get(base.url('users_and_groups_data', key='evil'))
 
        result = json.loads(response.body)['results']
 
        assert result[0].get('fname') == u'D\'o\'ct"o"r'
 
        assert result[0].get('lname') == u'Évíl'
 
        response = self.app.get(base.url('users_and_groups_data', query=u'rrrr'))
 
        assert result[0].get('fname') == 'D\'o\'ct"o"r'
 
        assert result[0].get('lname') == 'Évíl'
 
        response = self.app.get(base.url('users_and_groups_data', query='rrrr'))
 
        result = json.loads(response.body)['results']
 
        assert not result
 
        response = self.app.get(base.url('users_and_groups_data', types='users,groups', query=u'rrrr'))
 
        response = self.app.get(base.url('users_and_groups_data', types='users,groups', query='rrrr'))
 
        result = json.loads(response.body)['results']
 
        assert result[0].get('grname') == u'grrrr'
 
        assert result[0].get('grname') == 'grrrr'
kallithea/tests/functional/test_login.py
Show inline comments
 
@@ -164,7 +164,7 @@ class TestLoginController(base.TestContr
 

	
 
    @base.parametrize('args', [
 
        {'foo':'one', 'bar':'two'},
 
        {'blue': u'blå', 'green': u'grøn'},
 
        {'blue': 'blå', 'green': 'grøn'},
 
    ])
 
    def test_redirection_to_login_form_preserves_get_args(self, args):
 
        with fixture.anon_access(False):
 
@@ -178,7 +178,7 @@ class TestLoginController(base.TestContr
 

	
 
    @base.parametrize('args,args_encoded', [
 
        ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')),
 
        ({'blue': u'blå', 'green':u'grøn'},
 
        ({'blue': 'blå', 'green':'grøn'},
 
             ('blue=bl%C3%A5', 'green=gr%C3%B8n')),
 
    ])
 
    def test_login_form_preserves_get_args(self, args, args_encoded):
 
@@ -190,7 +190,7 @@ class TestLoginController(base.TestContr
 

	
 
    @base.parametrize('args,args_encoded', [
 
        ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')),
 
        ({'blue': u'blå', 'green':u'grøn'},
 
        ({'blue': 'blå', 'green':'grøn'},
 
             ('blue=bl%C3%A5', 'green=gr%C3%B8n')),
 
    ])
 
    def test_redirection_after_successful_login_preserves_get_args(self, args, args_encoded):
 
@@ -205,7 +205,7 @@ class TestLoginController(base.TestContr
 

	
 
    @base.parametrize('args,args_encoded', [
 
        ({'foo':'one', 'bar':'two'}, ('foo=one', 'bar=two')),
 
        ({'blue': u'blå', 'green':u'grøn'},
 
        ({'blue': 'blå', 'green':'grøn'},
 
             ('blue=bl%C3%A5', 'green=gr%C3%B8n')),
 
    ])
 
    def test_login_form_after_incorrect_login_preserves_get_args(self, args, args_encoded):
 
@@ -392,8 +392,8 @@ class TestLoginController(base.TestContr
 
        username = 'test_password_reset_1'
 
        password = 'qweqwe'
 
        email = 'username@example.com'
 
        name = u'passwd'
 
        lastname = u'reset'
 
        name = 'passwd'
 
        lastname = 'reset'
 
        timestamp = int(time.time())
 

	
 
        new = User()
 
@@ -521,12 +521,12 @@ class TestLoginController(base.TestContr
 
        self._api_key_test(api_key, code)
 

	
 
    def test_access_page_via_extra_api_key(self):
 
        new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, u'test')
 
        new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, 'test')
 
        Session().commit()
 
        self._api_key_test(new_api_key.api_key, status=200)
 

	
 
    def test_access_page_via_expired_api_key(self):
 
        new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, u'test')
 
        new_api_key = ApiKeyModel().create(base.TEST_USER_ADMIN_LOGIN, 'test')
 
        Session().commit()
 
        # patch the API key and make it expired
 
        new_api_key.expires = 0
kallithea/tests/functional/test_my_account.py
Show inline comments
 
@@ -161,8 +161,8 @@ class TestMyAccountController(base.TestC
 
                                    username=base.TEST_USER_ADMIN_LOGIN,
 
                                    new_password=base.TEST_USER_ADMIN_PASS,
 
                                    password_confirmation='test122',
 
                                    firstname=u'NewName',
 
                                    lastname=u'NewLastname',
 
                                    firstname='NewName',
 
                                    lastname='NewLastname',
 
                                    email=new_email,
 
                                    _session_csrf_secret_token=self.session_csrf_secret_token())
 
                                )
 
@@ -178,8 +178,8 @@ class TestMyAccountController(base.TestC
 
                                            username=base.TEST_USER_ADMIN_LOGIN,
 
                                            new_password=base.TEST_USER_ADMIN_PASS,
 
                                            password_confirmation='test122',
 
                                            firstname=u'NewName',
 
                                            lastname=u'NewLastname',
 
                                            firstname='NewName',
 
                                            lastname='NewLastname',
 
                                            email=new_email,
 
                                            _session_csrf_secret_token=self.session_csrf_secret_token()))
 

	
 
@@ -252,9 +252,9 @@ class TestMyAccountController(base.TestC
 
        response.mustcontain(no=[api_key])
 

	
 
    def test_my_account_add_ssh_key(self):
 
        description = u'something'
 
        public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost'
 
        fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
 
        description = 'something'
 
        public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost'
 
        fingerprint = 'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
 

	
 
        self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS)
 
        response = self.app.post(base.url('my_account_ssh_keys'),
 
@@ -273,9 +273,9 @@ class TestMyAccountController(base.TestC
 
        Session().commit()
 

	
 
    def test_my_account_remove_ssh_key(self):
 
        description = u''
 
        public_key = u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost'
 
        fingerprint = u'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
 
        description = ''
 
        public_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== me@localhost'
 
        fingerprint = 'Ke3oUCNJM87P0jJTb3D+e3shjceP2CqMpQKVd75E9I8'
 

	
 
        self.log_user(base.TEST_USER_REGULAR2_LOGIN, base.TEST_USER_REGULAR2_PASS)
 
        response = self.app.post(base.url('my_account_ssh_keys'),
 
@@ -286,7 +286,7 @@ class TestMyAccountController(base.TestC
 
        response.follow()
 
        user_id = response.session['authuser']['user_id']
 
        ssh_key = UserSshKeys.query().filter(UserSshKeys.user_id == user_id).one()
 
        assert ssh_key.description == u'me@localhost'
 
        assert ssh_key.description == 'me@localhost'
 

	
 
        response = self.app.post(base.url('my_account_ssh_keys_delete'),
 
                                 {'del_public_key_fingerprint': ssh_key.fingerprint,
kallithea/tests/functional/test_pullrequests.py
Show inline comments
 
@@ -292,14 +292,14 @@ class TestPullrequestsController(base.Te
 
class TestPullrequestsGetRepoRefs(base.TestController):
 

	
 
    def setup_method(self, method):
 
        self.repo_name = u'main'
 
        self.repo_name = 'main'
 
        repo = fixture.create_repo(self.repo_name, repo_type='hg')
 
        self.repo_scm_instance = repo.scm_instance
 
        Session().commit()
 
        self.c = PullrequestsController()
 

	
 
    def teardown_method(self, method):
 
        fixture.destroy_repo(u'main')
 
        fixture.destroy_repo('main')
 
        Session().commit()
 
        Session.remove()
 

	
kallithea/tests/functional/test_search_indexing.py
Show inline comments
 
@@ -39,12 +39,12 @@ def init_stopword_test(repo):
 

	
 
repos = [
 
    # reponame,              init func or fork base, groupname
 
    (u'indexing_test',       init_indexing_test,     None),
 
    (u'indexing_test-fork',  u'indexing_test',       None),
 
    (u'group/indexing_test', u'indexing_test',       u'group'),
 
    (u'this-is-it',          u'indexing_test',       None),
 
    (u'indexing_test-foo',   u'indexing_test',       None),
 
    (u'stopword_test',       init_stopword_test,     None),
 
    ('indexing_test',       init_indexing_test,     None),
 
    ('indexing_test-fork',  'indexing_test',       None),
 
    ('group/indexing_test', 'indexing_test',       'group'),
 
    ('this-is-it',          'indexing_test',       None),
 
    ('indexing_test-foo',   'indexing_test',       None),
 
    ('stopword_test',       init_stopword_test,     None),
 
]
 

	
 

	
 
@@ -109,12 +109,12 @@ class TestSearchControllerIndexing(base.
 
        rebuild_index(full_index=True) # rebuild fully for subsequent tests
 

	
 
    @base.parametrize('reponame', [
 
        (u'indexing_test'),
 
        (u'indexing_test-fork'),
 
        (u'group/indexing_test'),
 
        (u'this-is-it'),
 
        (u'*-fork'),
 
        (u'group/*'),
 
        ('indexing_test'),
 
        ('indexing_test-fork'),
 
        ('group/indexing_test'),
 
        ('this-is-it'),
 
        ('*-fork'),
 
        ('group/*'),
 
    ])
 
    @base.parametrize('searchtype,query,hit', [
 
        ('content', 'this_should_be_unique_content', 1),
 
@@ -130,10 +130,10 @@ class TestSearchControllerIndexing(base.
 
        response.mustcontain('>%d results' % hit)
 

	
 
    @base.parametrize('reponame', [
 
        (u'indexing_test'),
 
        (u'indexing_test-fork'),
 
        (u'group/indexing_test'),
 
        (u'this-is-it'),
 
        ('indexing_test'),
 
        ('indexing_test-fork'),
 
        ('group/indexing_test'),
 
        ('this-is-it'),
 
    ])
 
    @base.parametrize('searchtype,query,hit', [
 
        ('content', 'this_should_be_unique_content', 1),
kallithea/tests/functional/test_summary.py
Show inline comments
 
@@ -111,7 +111,7 @@ class TestSummaryController(base.TestCon
 

	
 
    def test_index_by_repo_having_id_path_in_name_hg(self):
 
        self.log_user()
 
        fixture.create_repo(name=u'repo_1')
 
        fixture.create_repo(name='repo_1')
 
        response = self.app.get(base.url(controller='summary',
 
                                    action='index',
 
                                    repo_name='repo_1'))
 
@@ -119,7 +119,7 @@ class TestSummaryController(base.TestCon
 
        try:
 
            response.mustcontain("repo_1")
 
        finally:
 
            RepoModel().delete(Repository.get_by_repo_name(u'repo_1'))
 
            RepoModel().delete(Repository.get_by_repo_name('repo_1'))
 
            Session().commit()
 

	
 
    def test_index_by_id_git(self):
kallithea/tests/models/common.py
Show inline comments
 
@@ -12,7 +12,7 @@ fixture = Fixture()
 

	
 
def _destroy_project_tree(test_u1_id):
 
    Session.remove()
 
    repo_group = RepoGroup.get_by_group_name(group_name=u'g0')
 
    repo_group = RepoGroup.get_by_group_name(group_name='g0')
 
    for el in reversed(repo_group.recursive_groups_and_repos()):
 
        if isinstance(el, Repository):
 
            RepoModel().delete(el)
 
@@ -50,21 +50,21 @@ def _create_project_tree():
 

	
 
    """
 
    test_u1 = UserModel().create_or_update(
 
        username=u'test_u1', password=u'qweqwe',
 
        email=u'test_u1@example.com', firstname=u'test_u1', lastname=u'test_u1'
 
        username='test_u1', password='qweqwe',
 
        email='test_u1@example.com', firstname='test_u1', lastname='test_u1'
 
    )
 
    g0 = fixture.create_repo_group(u'g0')
 
    g0_1 = fixture.create_repo_group(u'g0_1', parent_group_id=g0)
 
    g0_1_1 = fixture.create_repo_group(u'g0_1_1', parent_group_id=g0_1)
 
    g0_1_1_r1 = fixture.create_repo(u'g0/g0_1/g0_1_1/g0_1_1_r1', repo_group=g0_1_1)
 
    g0_1_1_r2 = fixture.create_repo(u'g0/g0_1/g0_1_1/g0_1_1_r2', repo_group=g0_1_1)
 
    g0_1_r1 = fixture.create_repo(u'g0/g0_1/g0_1_r1', repo_group=g0_1)
 
    g0_2 = fixture.create_repo_group(u'g0_2', parent_group_id=g0)
 
    g0_2_r1 = fixture.create_repo(u'g0/g0_2/g0_2_r1', repo_group=g0_2)
 
    g0_2_r2 = fixture.create_repo(u'g0/g0_2/g0_2_r2', repo_group=g0_2)
 
    g0_3 = fixture.create_repo_group(u'g0_3', parent_group_id=g0)
 
    g0_3_r1 = fixture.create_repo(u'g0/g0_3/g0_3_r1', repo_group=g0_3)
 
    g0_3_r2_private = fixture.create_repo(u'g0/g0_3/g0_3_r1_private',
 
    g0 = fixture.create_repo_group('g0')
 
    g0_1 = fixture.create_repo_group('g0_1', parent_group_id=g0)
 
    g0_1_1 = fixture.create_repo_group('g0_1_1', parent_group_id=g0_1)
 
    g0_1_1_r1 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r1', repo_group=g0_1_1)
 
    g0_1_1_r2 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r2', repo_group=g0_1_1)
 
    g0_1_r1 = fixture.create_repo('g0/g0_1/g0_1_r1', repo_group=g0_1)
 
    g0_2 = fixture.create_repo_group('g0_2', parent_group_id=g0)
 
    g0_2_r1 = fixture.create_repo('g0/g0_2/g0_2_r1', repo_group=g0_2)
 
    g0_2_r2 = fixture.create_repo('g0/g0_2/g0_2_r2', repo_group=g0_2)
 
    g0_3 = fixture.create_repo_group('g0_3', parent_group_id=g0)
 
    g0_3_r1 = fixture.create_repo('g0/g0_3/g0_3_r1', repo_group=g0_3)
 
    g0_3_r2_private = fixture.create_repo('g0/g0_3/g0_3_r1_private',
 
                                          repo_group=g0_3, repo_private=True)
 
    return test_u1
 

	
kallithea/tests/models/test_comments.py
Show inline comments
 
@@ -29,7 +29,7 @@ class TestComments(base.TestController):
 
            self._check_comment_count(repo_id, revision,
 
                    expected_len_comments=0, expected_len_inline_comments=0)
 

	
 
            text = u'a comment'
 
            text = 'a comment'
 
            new_comment = ChangesetCommentsModel().create(
 
                    text=text,
 
                    repo=base.HG_REPO,
 
@@ -53,9 +53,9 @@ class TestComments(base.TestController):
 
            self._check_comment_count(repo_id, revision,
 
                    expected_len_comments=0, expected_len_inline_comments=0)
 

	
 
            text = u'an inline comment'
 
            f_path = u'vcs/tests/base.py'
 
            line_no = u'n50'
 
            text = 'an inline comment'
 
            f_path = 'vcs/tests/base.py'
 
            line_no = 'n50'
 
            new_comment = ChangesetCommentsModel().create(
 
                    text=text,
 
                    repo=base.HG_REPO,
 
@@ -87,9 +87,9 @@ class TestComments(base.TestController):
 
            self._check_comment_count(repo_id, revision,
 
                    expected_len_comments=0, expected_len_inline_comments=0)
 

	
 
            text = u'an inline comment'
 
            f_path = u'vcs/tests/base.py'
 
            line_no = u'n50'
 
            text = 'an inline comment'
 
            f_path = 'vcs/tests/base.py'
 
            line_no = 'n50'
 
            new_comment = ChangesetCommentsModel().create(
 
                    text=text,
 
                    repo=base.HG_REPO,
 
@@ -99,8 +99,8 @@ class TestComments(base.TestController):
 
                    line_no=line_no,
 
                    send_email=False)
 

	
 
            text2 = u'another inline comment, same file'
 
            line_no2 = u'o41'
 
            text2 = 'another inline comment, same file'
 
            line_no2 = 'o41'
 
            new_comment2 = ChangesetCommentsModel().create(
 
                    text=text2,
 
                    repo=base.HG_REPO,
 
@@ -110,9 +110,9 @@ class TestComments(base.TestController):
 
                    line_no=line_no2,
 
                    send_email=False)
 

	
 
            text3 = u'another inline comment, same file'
 
            f_path3 = u'vcs/tests/test_hg.py'
 
            line_no3 = u'n159'
 
            text3 = 'another inline comment, same file'
 
            f_path3 = 'vcs/tests/test_hg.py'
 
            line_no3 = 'n159'
 
            new_comment3 = ChangesetCommentsModel().create(
 
                    text=text3,
 
                    repo=base.HG_REPO,
 
@@ -167,9 +167,9 @@ class TestComments(base.TestController):
 
            self._check_comment_count(repo_id, revision,
 
                    expected_len_comments=0, expected_len_inline_comments=0)
 

	
 
            text = u'an inline comment'
 
            f_path = u'vcs/tests/base.py'
 
            line_no = u'n50'
 
            text = 'an inline comment'
 
            f_path = 'vcs/tests/base.py'
 
            line_no = 'n50'
 
            new_comment = ChangesetCommentsModel().create(
 
                    text=text,
 
                    repo=base.HG_REPO,
 
@@ -179,8 +179,8 @@ class TestComments(base.TestController):
 
                    line_no=line_no,
 
                    send_email=False)
 

	
 
            text2 = u'another inline comment, same file'
 
            line_no2 = u'o41'
 
            text2 = 'another inline comment, same file'
 
            line_no2 = 'o41'
 
            new_comment2 = ChangesetCommentsModel().create(
 
                    text=text2,
 
                    repo=base.HG_REPO,
 
@@ -190,9 +190,9 @@ class TestComments(base.TestController):
 
                    line_no=line_no2,
 
                    send_email=False)
 

	
 
            text3 = u'another inline comment, same file'
 
            f_path3 = u'vcs/tests/test_hg.py'
 
            line_no3 = u'n159'
 
            text3 = 'another inline comment, same file'
 
            f_path3 = 'vcs/tests/test_hg.py'
 
            line_no3 = 'n159'
 
            new_comment3 = ChangesetCommentsModel().create(
 
                    text=text3,
 
                    repo=base.HG_REPO,
kallithea/tests/models/test_notifications.py
Show inline comments
 
@@ -18,24 +18,24 @@ class TestNotifications(base.TestControl
 

	
 
    def setup_method(self, method):
 
        Session.remove()
 
        u1 = UserModel().create_or_update(username=u'u1',
 
                                        password=u'qweqwe',
 
                                        email=u'u1@example.com',
 
                                        firstname=u'u1', lastname=u'u1')
 
        u1 = UserModel().create_or_update(username='u1',
 
                                        password='qweqwe',
 
                                        email='u1@example.com',
 
                                        firstname='u1', lastname='u1')
 
        Session().commit()
 
        self.u1 = u1.user_id
 

	
 
        u2 = UserModel().create_or_update(username=u'u2',
 
                                        password=u'qweqwe',
 
                                        email=u'u2@example.com',
 
                                        firstname=u'u2', lastname=u'u3')
 
        u2 = UserModel().create_or_update(username='u2',
 
                                        password='qweqwe',
 
                                        email='u2@example.com',
 
                                        firstname='u2', lastname='u3')
 
        Session().commit()
 
        self.u2 = u2.user_id
 

	
 
        u3 = UserModel().create_or_update(username=u'u3',
 
                                        password=u'qweqwe',
 
                                        email=u'u3@example.com',
 
                                        firstname=u'u3', lastname=u'u3')
 
        u3 = UserModel().create_or_update(username='u3',
 
                                        password='qweqwe',
 
                                        email='u3@example.com',
 
                                        firstname='u3', lastname='u3')
 
        Session().commit()
 
        self.u3 = u3.user_id
 

	
 
@@ -46,12 +46,12 @@ class TestNotifications(base.TestControl
 
            def send_email(recipients, subject, body='', html_body='', headers=None, author=None):
 
                assert recipients == ['u2@example.com']
 
                assert subject == 'Test Message'
 
                assert body == u"hi there"
 
                assert body == "hi there"
 
                assert '>hi there<' in html_body
 
                assert author.username == 'u1'
 
            with mock.patch.object(kallithea.lib.celerylib.tasks, 'send_email', send_email):
 
                NotificationModel().create(created_by=self.u1,
 
                                                   subject=u'subj', body=u'hi there',
 
                                                   subject='subj', body='hi there',
 
                                                   recipients=usrs)
 

	
 
    @mock.patch.object(h, 'canonical_url', (lambda arg, **kwargs: 'http://%s/?%s' % (arg, '&'.join('%s=%s' % (k, v) for (k, v) in sorted(kwargs.items())))))
 
@@ -90,7 +90,7 @@ class TestNotifications(base.TestControl
 

	
 
                for type_, body, kwargs in [
 
                        (NotificationModel.TYPE_CHANGESET_COMMENT,
 
                         u'This is the new \'comment\'.\n\n - and here it ends indented.',
 
                         'This is the new \'comment\'.\n\n - and here it ends indented.',
 
                         dict(
 
                            short_id='cafe1234',
 
                            raw_id='cafe1234c0ffeecafe',
 
@@ -105,18 +105,18 @@ class TestNotifications(base.TestControl
 
                            cs_url='http://changeset.com',
 
                            cs_author=User.get(self.u2))),
 
                        (NotificationModel.TYPE_MESSAGE,
 
                         u'This is the \'body\' of the "test" message\n - nothing interesting here except indentation.',
 
                         'This is the \'body\' of the "test" message\n - nothing interesting here except indentation.',
 
                         dict()),
 
                        #(NotificationModel.TYPE_MENTION, '$body', None), # not used
 
                        (NotificationModel.TYPE_REGISTRATION,
 
                         u'Registration body',
 
                         'Registration body',
 
                         dict(
 
                            new_username='newbie',
 
                            registered_user_url='http://newbie.org',
 
                            new_email='new@email.com',
 
                            new_full_name='New Full Name')),
 
                        (NotificationModel.TYPE_PULL_REQUEST,
 
                         u'This PR is \'awesome\' because it does <stuff>\n - please approve indented!',
 
                         'This PR is \'awesome\' because it does <stuff>\n - please approve indented!',
 
                         dict(
 
                            pr_user_created='Requesting User (root)', # pr_owner should perhaps be used for @mention in description ...
 
                            is_mention=[False, True],
 
@@ -124,7 +124,7 @@ class TestNotifications(base.TestControl
 
                            org_repo_name='repo_org',
 
                            **pr_kwargs)),
 
                        (NotificationModel.TYPE_PULL_REQUEST_COMMENT,
 
                         u'Me too!\n\n - and indented on second line',
 
                         'Me too!\n\n - and indented on second line',
 
                         dict(
 
                            closing_pr=[False, True],
 
                            is_mention=[False, True],
 
@@ -133,7 +133,7 @@ class TestNotifications(base.TestControl
 
                            status_change=[None, 'Under Review'],
 
                            **pr_kwargs)),
 
                        ]:
 
                    kwargs['repo_name'] = u'repo/name'
 
                    kwargs['repo_name'] = 'repo/name'
 
                    params = [(type_, type_, body, kwargs)]
 
                    for param_name in ['is_mention', 'status_change', 'closing_pr']: # TODO: inline/general
 
                        if not isinstance(kwargs.get(param_name), list):
 
@@ -149,7 +149,7 @@ class TestNotifications(base.TestControl
 
                    for desc, type_, body, kwargs in params:
 
                        # desc is used as "global" variable
 
                        NotificationModel().create(created_by=self.u1,
 
                                                           subject=u'unused', body=body, email_kwargs=kwargs,
 
                                                           subject='unused', body=body, email_kwargs=kwargs,
 
                                                           recipients=[self.u2], type_=type_)
 

	
 
                # Email type TYPE_PASSWORD_RESET has no corresponding notification type - test it directly:
kallithea/tests/models/test_permissions.py
Show inline comments
 
@@ -24,21 +24,21 @@ class TestPermissions(base.TestControlle
 

	
 
    def setup_method(self, method):
 
        self.u1 = UserModel().create_or_update(
 
            username=u'u1', password=u'qweqwe',
 
            email=u'u1@example.com', firstname=u'u1', lastname=u'u1'
 
            username='u1', password='qweqwe',
 
            email='u1@example.com', firstname='u1', lastname='u1'
 
        )
 
        self.u2 = UserModel().create_or_update(
 
            username=u'u2', password=u'qweqwe',
 
            email=u'u2@example.com', firstname=u'u2', lastname=u'u2'
 
            username='u2', password='qweqwe',
 
            email='u2@example.com', firstname='u2', lastname='u2'
 
        )
 
        self.u3 = UserModel().create_or_update(
 
            username=u'u3', password=u'qweqwe',
 
            email=u'u3@example.com', firstname=u'u3', lastname=u'u3'
 
            username='u3', password='qweqwe',
 
            email='u3@example.com', firstname='u3', lastname='u3'
 
        )
 
        self.anon = User.get_default_user()
 
        self.a1 = UserModel().create_or_update(
 
            username=u'a1', password=u'qweqwe',
 
            email=u'a1@example.com', firstname=u'a1', lastname=u'a1', admin=True
 
            username='a1', password='qweqwe',
 
            email='a1@example.com', firstname='a1', lastname='a1', admin=True
 
        )
 
        Session().commit()
 

	
 
@@ -100,11 +100,11 @@ class TestPermissions(base.TestControlle
 
        assert u1_auth.permissions['repositories'][base.HG_REPO] == perms['repositories'][base.HG_REPO]
 

	
 
    def test_default_group_perms(self):
 
        self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True)
 
        self.g2 = fixture.create_repo_group(u'test2', skip_if_exists=True)
 
        self.g1 = fixture.create_repo_group('test1', skip_if_exists=True)
 
        self.g2 = fixture.create_repo_group('test2', skip_if_exists=True)
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        perms = {
 
            'repositories_groups': {u'test1': 'group.read', u'test2': 'group.read'},
 
            'repositories_groups': {'test1': 'group.read', 'test2': 'group.read'},
 
            'global': set(Permission.DEFAULT_USER_PERMISSIONS),
 
            'repositories': {base.HG_REPO: 'repository.read'}
 
        }
 
@@ -113,11 +113,11 @@ class TestPermissions(base.TestControlle
 
        assert u1_auth.permissions['global'] == perms['global']
 

	
 
    def test_default_admin_group_perms(self):
 
        self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True)
 
        self.g2 = fixture.create_repo_group(u'test2', skip_if_exists=True)
 
        self.g1 = fixture.create_repo_group('test1', skip_if_exists=True)
 
        self.g2 = fixture.create_repo_group('test2', skip_if_exists=True)
 
        a1_auth = AuthUser(user_id=self.a1.user_id)
 
        perms = {
 
            'repositories_groups': {u'test1': 'group.admin', u'test2': 'group.admin'},
 
            'repositories_groups': {'test1': 'group.admin', 'test2': 'group.admin'},
 
            'global': set(['hg.admin', 'hg.create.write_on_repogroup.true']),
 
            'repositories': {base.HG_REPO: 'repository.admin'}
 
        }
 
@@ -127,7 +127,7 @@ class TestPermissions(base.TestControlle
 

	
 
    def test_propagated_permission_from_users_group_by_explicit_perms_exist(self):
 
        # make group
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        UserGroupModel().add_user_to_group(self.ug1, self.u1)
 

	
 
        # set user permission none
 
@@ -147,7 +147,7 @@ class TestPermissions(base.TestControlle
 

	
 
    def test_propagated_permission_from_users_group(self):
 
        # make group
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        UserGroupModel().add_user_to_group(self.ug1, self.u3)
 

	
 
        # grant perm for group this should override default permission from user
 
@@ -168,7 +168,7 @@ class TestPermissions(base.TestControlle
 

	
 
    def test_propagated_permission_from_users_group_lower_weight(self):
 
        # make group
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        # add user to group
 
        UserGroupModel().add_user_to_group(self.ug1, self.u1)
 

	
 
@@ -198,14 +198,14 @@ class TestPermissions(base.TestControlle
 
        assert u1_auth.permissions['repositories_groups'] == perms['repositories_groups']
 

	
 
    def test_repo_in_group_permissions(self):
 
        self.g1 = fixture.create_repo_group(u'group1', skip_if_exists=True)
 
        self.g2 = fixture.create_repo_group(u'group2', skip_if_exists=True)
 
        self.g1 = fixture.create_repo_group('group1', skip_if_exists=True)
 
        self.g2 = fixture.create_repo_group('group2', skip_if_exists=True)
 
        # both perms should be read !
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.read', u'group2': u'group.read'}
 
        assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.read', 'group2': 'group.read'}
 

	
 
        a1_auth = AuthUser(user_id=self.anon.user_id)
 
        assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.read', u'group2': u'group.read'}
 
        assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.read', 'group2': 'group.read'}
 

	
 
        # Change perms to none for both groups
 
        RepoGroupModel().grant_user_permission(repo_group=self.g1,
 
@@ -216,10 +216,10 @@ class TestPermissions(base.TestControlle
 
                                               perm='group.none')
 

	
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
 
        assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'}
 

	
 
        a1_auth = AuthUser(user_id=self.anon.user_id)
 
        assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
 
        assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'}
 

	
 
        # add repo to group
 
        name = RepoGroup.url_sep().join([self.g1.group_name, 'test_perm'])
 
@@ -229,10 +229,10 @@ class TestPermissions(base.TestControlle
 
                                             cur_user=self.u1,)
 

	
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
 
        assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'}
 

	
 
        a1_auth = AuthUser(user_id=self.anon.user_id)
 
        assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
 
        assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'}
 

	
 
        # grant permission for u2 !
 
        RepoGroupModel().grant_user_permission(repo_group=self.g1, user=self.u2,
 
@@ -243,27 +243,27 @@ class TestPermissions(base.TestControlle
 
        assert self.u1 != self.u2
 
        # u1 and anon should have not change perms while u2 should !
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
 
        assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'}
 

	
 
        u2_auth = AuthUser(user_id=self.u2.user_id)
 
        assert u2_auth.permissions['repositories_groups'] == {u'group1': u'group.read', u'group2': u'group.read'}
 
        assert u2_auth.permissions['repositories_groups'] == {'group1': 'group.read', 'group2': 'group.read'}
 

	
 
        a1_auth = AuthUser(user_id=self.anon.user_id)
 
        assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.none', u'group2': u'group.none'}
 
        assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none', 'group2': 'group.none'}
 

	
 
    def test_repo_group_user_as_user_group_member(self):
 
        # create Group1
 
        self.g1 = fixture.create_repo_group(u'group1', skip_if_exists=True)
 
        self.g1 = fixture.create_repo_group('group1', skip_if_exists=True)
 
        a1_auth = AuthUser(user_id=self.anon.user_id)
 

	
 
        assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.read'}
 
        assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.read'}
 

	
 
        # set default permission to none
 
        RepoGroupModel().grant_user_permission(repo_group=self.g1,
 
                                               user=self.anon,
 
                                               perm='group.none')
 
        # make group
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        # add user to group
 
        UserGroupModel().add_user_to_group(self.ug1, self.u1)
 
        Session().commit()
 
@@ -275,10 +275,10 @@ class TestPermissions(base.TestControlle
 

	
 
        # check his permissions
 
        a1_auth = AuthUser(user_id=self.anon.user_id)
 
        assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.none'}
 
        assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none'}
 

	
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.none'}
 
        assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.none'}
 

	
 
        # grant ug1 read permissions for
 
        RepoGroupModel().grant_user_group_permission(repo_group=self.g1,
 
@@ -294,10 +294,10 @@ class TestPermissions(base.TestControlle
 

	
 
        a1_auth = AuthUser(user_id=self.anon.user_id)
 

	
 
        assert a1_auth.permissions['repositories_groups'] == {u'group1': u'group.none'}
 
        assert a1_auth.permissions['repositories_groups'] == {'group1': 'group.none'}
 

	
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.read'}
 
        assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.read'}
 

	
 
    def test_inherit_nice_permissions_from_default_user(self):
 
        user_model = UserModel()
 
@@ -388,7 +388,7 @@ class TestPermissions(base.TestControlle
 
    def test_inactive_user_group_does_not_affect_global_permissions(self):
 
        # Add user to inactive user group, set specific permissions on user
 
        # group and and verify it really is inactive.
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        user_group_model = UserGroupModel()
 
        user_group_model.add_user_to_group(self.ug1, self.u1)
 
        user_group_model.update(self.ug1, {'users_group_active': False})
 
@@ -420,7 +420,7 @@ class TestPermissions(base.TestControlle
 
    def test_inactive_user_group_does_not_affect_global_permissions_inverse(self):
 
        # Add user to inactive user group, set specific permissions on user
 
        # group and and verify it really is inactive.
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        user_group_model = UserGroupModel()
 
        user_group_model.add_user_to_group(self.ug1, self.u1)
 
        user_group_model.update(self.ug1, {'users_group_active': False})
 
@@ -450,14 +450,14 @@ class TestPermissions(base.TestControlle
 
                              'hg.create.write_on_repogroup.true'])
 

	
 
    def test_inactive_user_group_does_not_affect_repo_permissions(self):
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        user_group_model = UserGroupModel()
 
        user_group_model.add_user_to_group(self.ug1, self.u1)
 
        user_group_model.update(self.ug1, {'users_group_active': False})
 

	
 
        # note: make u2 repo owner rather than u1, because the owner always has
 
        # admin permissions
 
        self.test_repo = fixture.create_repo(name=u'myownrepo',
 
        self.test_repo = fixture.create_repo(name='myownrepo',
 
                                             repo_type='hg',
 
                                             cur_user=self.u2)
 

	
 
@@ -474,14 +474,14 @@ class TestPermissions(base.TestControlle
 
        assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.write'
 

	
 
    def test_inactive_user_group_does_not_affect_repo_permissions_inverse(self):
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        user_group_model = UserGroupModel()
 
        user_group_model.add_user_to_group(self.ug1, self.u1)
 
        user_group_model.update(self.ug1, {'users_group_active': False})
 

	
 
        # note: make u2 repo owner rather than u1, because the owner always has
 
        # admin permissions
 
        self.test_repo = fixture.create_repo(name=u'myownrepo',
 
        self.test_repo = fixture.create_repo(name='myownrepo',
 
                                             repo_type='hg',
 
                                             cur_user=self.u2)
 

	
 
@@ -498,12 +498,12 @@ class TestPermissions(base.TestControlle
 
        assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.admin'
 

	
 
    def test_inactive_user_group_does_not_affect_repo_group_permissions(self):
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        user_group_model = UserGroupModel()
 
        user_group_model.add_user_to_group(self.ug1, self.u1)
 
        user_group_model.update(self.ug1, {'users_group_active': False})
 

	
 
        self.g1 = fixture.create_repo_group(u'group1', skip_if_exists=True)
 
        self.g1 = fixture.create_repo_group('group1', skip_if_exists=True)
 

	
 
        # enable admin access for user group on repo group
 
        RepoGroupModel().grant_user_group_permission(self.g1,
 
@@ -515,15 +515,15 @@ class TestPermissions(base.TestControlle
 
                                               perm='group.write')
 
        Session().commit()
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.write'}
 
        assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.write'}
 

	
 
    def test_inactive_user_group_does_not_affect_repo_group_permissions_inverse(self):
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        user_group_model = UserGroupModel()
 
        user_group_model.add_user_to_group(self.ug1, self.u1)
 
        user_group_model.update(self.ug1, {'users_group_active': False})
 

	
 
        self.g1 = fixture.create_repo_group(u'group1', skip_if_exists=True)
 
        self.g1 = fixture.create_repo_group('group1', skip_if_exists=True)
 

	
 
        # enable only write access for user group on repo group
 
        RepoGroupModel().grant_user_group_permission(self.g1,
 
@@ -535,15 +535,15 @@ class TestPermissions(base.TestControlle
 
                                               perm='group.admin')
 
        Session().commit()
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories_groups'] == {u'group1': u'group.admin'}
 
        assert u1_auth.permissions['repositories_groups'] == {'group1': 'group.admin'}
 

	
 
    def test_inactive_user_group_does_not_affect_user_group_permissions(self):
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        user_group_model = UserGroupModel()
 
        user_group_model.add_user_to_group(self.ug1, self.u1)
 
        user_group_model.update(self.ug1, {'users_group_active': False})
 

	
 
        self.ug2 = fixture.create_user_group(u'G2')
 
        self.ug2 = fixture.create_user_group('G2')
 

	
 
        # enable admin access for user group on user group
 
        UserGroupModel().grant_user_group_permission(self.ug2,
 
@@ -555,16 +555,16 @@ class TestPermissions(base.TestControlle
 
                                               perm='usergroup.write')
 
        Session().commit()
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['user_groups'][u'G1'] == u'usergroup.read'
 
        assert u1_auth.permissions['user_groups'][u'G2'] == u'usergroup.write'
 
        assert u1_auth.permissions['user_groups']['G1'] == 'usergroup.read'
 
        assert u1_auth.permissions['user_groups']['G2'] == 'usergroup.write'
 

	
 
    def test_inactive_user_group_does_not_affect_user_group_permissions_inverse(self):
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        user_group_model = UserGroupModel()
 
        user_group_model.add_user_to_group(self.ug1, self.u1)
 
        user_group_model.update(self.ug1, {'users_group_active': False})
 

	
 
        self.ug2 = fixture.create_user_group(u'G2')
 
        self.ug2 = fixture.create_user_group('G2')
 

	
 
        # enable only write access for user group on user group
 
        UserGroupModel().grant_user_group_permission(self.ug2,
 
@@ -576,12 +576,12 @@ class TestPermissions(base.TestControlle
 
                                               perm='usergroup.admin')
 
        Session().commit()
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['user_groups'][u'G1'] == u'usergroup.read'
 
        assert u1_auth.permissions['user_groups'][u'G2'] == u'usergroup.admin'
 
        assert u1_auth.permissions['user_groups']['G1'] == 'usergroup.read'
 
        assert u1_auth.permissions['user_groups']['G2'] == 'usergroup.admin'
 

	
 
    def test_owner_permissions_doesnot_get_overwritten_by_group(self):
 
        # create repo as USER,
 
        self.test_repo = fixture.create_repo(name=u'myownrepo',
 
        self.test_repo = fixture.create_repo(name='myownrepo',
 
                                             repo_type='hg',
 
                                             cur_user=self.u1)
 

	
 
@@ -589,7 +589,7 @@ class TestPermissions(base.TestControlle
 
        u1_auth = AuthUser(user_id=self.u1.user_id)
 
        assert u1_auth.permissions['repositories']['myownrepo'] == 'repository.admin'
 
        # set his permission as user group, he should still be admin
 
        self.ug1 = fixture.create_user_group(u'G1')
 
        self.ug1 = fixture.create_user_group('G1')
 
        UserGroupModel().add_user_to_group(self.ug1, self.u1)
 
        RepoModel().grant_user_group_permission(self.test_repo,
 
                                                 group_name=self.ug1,
 
@@ -601,7 +601,7 @@ class TestPermissions(base.TestControlle
 

	
 
    def test_owner_permissions_doesnot_get_overwritten_by_others(self):
 
        # create repo as USER,
 
        self.test_repo = fixture.create_repo(name=u'myownrepo',
 
        self.test_repo = fixture.create_repo(name='myownrepo',
 
                                             repo_type='hg',
 
                                             cur_user=self.u1)
 

	
kallithea/tests/models/test_repo_groups.py
Show inline comments
 
@@ -14,7 +14,7 @@ from kallithea.tests.fixture import Fixt
 
fixture = Fixture()
 

	
 

	
 
def _update_repo_group(id_, group_name, desc=u'desc', parent_id=None):
 
def _update_repo_group(id_, group_name, desc='desc', parent_id=None):
 
    form_data = dict(
 
        group_name=group_name,
 
        group_description=desc,
 
@@ -37,9 +37,9 @@ def _update_repo(name, **kwargs):
 
class TestRepoGroups(base.TestController):
 

	
 
    def setup_method(self, method):
 
        self.g1 = fixture.create_repo_group(u'test1', skip_if_exists=True)
 
        self.g2 = fixture.create_repo_group(u'test2', skip_if_exists=True)
 
        self.g3 = fixture.create_repo_group(u'test3', skip_if_exists=True)
 
        self.g1 = fixture.create_repo_group('test1', skip_if_exists=True)
 
        self.g2 = fixture.create_repo_group('test2', skip_if_exists=True)
 
        self.g3 = fixture.create_repo_group('test3', skip_if_exists=True)
 

	
 
    def teardown_method(self, method):
 
        Session.remove()
 
@@ -56,7 +56,7 @@ class TestRepoGroups(base.TestController
 
        RepoGroupModel().delete(id_)
 

	
 
    def test_create_group(self):
 
        g = fixture.create_repo_group(u'newGroup')
 
        g = fixture.create_repo_group('newGroup')
 
        Session().commit()
 
        assert g.full_path == 'newGroup'
 

	
 
@@ -64,71 +64,71 @@ class TestRepoGroups(base.TestController
 

	
 
    def test_create_same_name_group(self):
 
        with pytest.raises(IntegrityError):
 
            fixture.create_repo_group(u'newGroup')
 
            fixture.create_repo_group('newGroup')
 
        Session().rollback()
 

	
 
    def test_same_subgroup(self):
 
        sg1 = fixture.create_repo_group(u'sub1', parent_group_id=self.g1.group_id)
 
        sg1 = fixture.create_repo_group('sub1', parent_group_id=self.g1.group_id)
 
        assert sg1.parent_group == self.g1
 
        assert sg1.full_path == 'test1/sub1'
 
        assert self.__check_path('test1', 'sub1')
 

	
 
        ssg1 = fixture.create_repo_group(u'subsub1', parent_group_id=sg1.group_id)
 
        ssg1 = fixture.create_repo_group('subsub1', parent_group_id=sg1.group_id)
 
        assert ssg1.parent_group == sg1
 
        assert ssg1.full_path == 'test1/sub1/subsub1'
 
        assert self.__check_path('test1', 'sub1', 'subsub1')
 

	
 
    def test_remove_group(self):
 
        sg1 = fixture.create_repo_group(u'deleteme')
 
        sg1 = fixture.create_repo_group('deleteme')
 
        self.__delete_group(sg1.group_id)
 

	
 
        assert RepoGroup.get(sg1.group_id) is None
 
        assert not self.__check_path('deteteme')
 

	
 
        sg1 = fixture.create_repo_group(u'deleteme', parent_group_id=self.g1.group_id)
 
        sg1 = fixture.create_repo_group('deleteme', parent_group_id=self.g1.group_id)
 
        self.__delete_group(sg1.group_id)
 

	
 
        assert RepoGroup.get(sg1.group_id) is None
 
        assert not self.__check_path('test1', 'deteteme')
 

	
 
    def test_rename_single_group(self):
 
        sg1 = fixture.create_repo_group(u'initial')
 
        sg1 = fixture.create_repo_group('initial')
 

	
 
        new_sg1 = _update_repo_group(sg1.group_id, u'after')
 
        new_sg1 = _update_repo_group(sg1.group_id, 'after')
 
        assert self.__check_path('after')
 
        assert RepoGroup.get_by_group_name(u'initial') is None
 
        assert RepoGroup.get_by_group_name('initial') is None
 

	
 
    def test_update_group_parent(self):
 

	
 
        sg1 = fixture.create_repo_group(u'initial', parent_group_id=self.g1.group_id)
 
        sg1 = fixture.create_repo_group('initial', parent_group_id=self.g1.group_id)
 

	
 
        new_sg1 = _update_repo_group(sg1.group_id, u'after', parent_id=self.g1.group_id)
 
        new_sg1 = _update_repo_group(sg1.group_id, 'after', parent_id=self.g1.group_id)
 
        assert self.__check_path('test1', 'after')
 
        assert RepoGroup.get_by_group_name(u'test1/initial') is None
 
        assert RepoGroup.get_by_group_name('test1/initial') is None
 

	
 
        new_sg1 = _update_repo_group(sg1.group_id, u'after', parent_id=self.g3.group_id)
 
        new_sg1 = _update_repo_group(sg1.group_id, 'after', parent_id=self.g3.group_id)
 
        assert self.__check_path('test3', 'after')
 
        assert RepoGroup.get_by_group_name(u'test3/initial') == None
 
        assert RepoGroup.get_by_group_name('test3/initial') == None
 

	
 
        new_sg1 = _update_repo_group(sg1.group_id, u'hello')
 
        new_sg1 = _update_repo_group(sg1.group_id, 'hello')
 
        assert self.__check_path('hello')
 

	
 
        assert RepoGroup.get_by_group_name(u'hello') == new_sg1
 
        assert RepoGroup.get_by_group_name('hello') == new_sg1
 

	
 
    def test_subgrouping_with_repo(self):
 

	
 
        g1 = fixture.create_repo_group(u'g1')
 
        g2 = fixture.create_repo_group(u'g2')
 
        g1 = fixture.create_repo_group('g1')
 
        g2 = fixture.create_repo_group('g2')
 
        # create new repo
 
        r = fixture.create_repo(u'john')
 
        r = fixture.create_repo('john')
 

	
 
        assert r.repo_name == 'john'
 
        # put repo into group
 
        r = _update_repo(u'john', repo_group=g1.group_id)
 
        r = _update_repo('john', repo_group=g1.group_id)
 
        Session().commit()
 
        assert r.repo_name == 'g1/john'
 

	
 
        _update_repo_group(g1.group_id, u'g1', parent_id=g2.group_id)
 
        _update_repo_group(g1.group_id, 'g1', parent_id=g2.group_id)
 
        assert self.__check_path('g2', 'g1')
 

	
 
        # test repo
 
@@ -136,13 +136,13 @@ class TestRepoGroups(base.TestController
 
                                                                r.just_name])
 

	
 
    def test_move_to_root(self):
 
        g1 = fixture.create_repo_group(u't11')
 
        g2 = fixture.create_repo_group(u't22', parent_group_id=g1.group_id)
 
        g1 = fixture.create_repo_group('t11')
 
        g2 = fixture.create_repo_group('t22', parent_group_id=g1.group_id)
 

	
 
        assert g2.full_path == 't11/t22'
 
        assert self.__check_path('t11', 't22')
 

	
 
        g2 = _update_repo_group(g2.group_id, u'g22', parent_id=None)
 
        g2 = _update_repo_group(g2.group_id, 'g22', parent_id=None)
 
        Session().commit()
 

	
 
        assert g2.group_name == 'g22'
 
@@ -152,14 +152,14 @@ class TestRepoGroups(base.TestController
 
        assert self.__check_path('g22')
 

	
 
    def test_rename_top_level_group_in_nested_setup(self):
 
        g1 = fixture.create_repo_group(u'L1')
 
        g2 = fixture.create_repo_group(u'L2', parent_group_id=g1.group_id)
 
        g3 = fixture.create_repo_group(u'L3', parent_group_id=g2.group_id)
 
        g1 = fixture.create_repo_group('L1')
 
        g2 = fixture.create_repo_group('L2', parent_group_id=g1.group_id)
 
        g3 = fixture.create_repo_group('L3', parent_group_id=g2.group_id)
 

	
 
        r = fixture.create_repo(u'L1/L2/L3/L3_REPO', repo_group=g3.group_id)
 
        r = fixture.create_repo('L1/L2/L3/L3_REPO', repo_group=g3.group_id)
 

	
 
        ## rename L1 all groups should be now changed
 
        _update_repo_group(g1.group_id, u'L1_NEW')
 
        _update_repo_group(g1.group_id, 'L1_NEW')
 
        Session().commit()
 
        assert g1.full_path == 'L1_NEW'
 
        assert g2.full_path == 'L1_NEW/L2'
 
@@ -167,14 +167,14 @@ class TestRepoGroups(base.TestController
 
        assert r.repo_name == 'L1_NEW/L2/L3/L3_REPO'
 

	
 
    def test_change_parent_of_top_level_group_in_nested_setup(self):
 
        g1 = fixture.create_repo_group(u'R1')
 
        g2 = fixture.create_repo_group(u'R2', parent_group_id=g1.group_id)
 
        g3 = fixture.create_repo_group(u'R3', parent_group_id=g2.group_id)
 
        g4 = fixture.create_repo_group(u'R1_NEW')
 
        g1 = fixture.create_repo_group('R1')
 
        g2 = fixture.create_repo_group('R2', parent_group_id=g1.group_id)
 
        g3 = fixture.create_repo_group('R3', parent_group_id=g2.group_id)
 
        g4 = fixture.create_repo_group('R1_NEW')
 

	
 
        r = fixture.create_repo(u'R1/R2/R3/R3_REPO', repo_group=g3.group_id)
 
        r = fixture.create_repo('R1/R2/R3/R3_REPO', repo_group=g3.group_id)
 
        ## rename L1 all groups should be now changed
 
        _update_repo_group(g1.group_id, u'R1', parent_id=g4.group_id)
 
        _update_repo_group(g1.group_id, 'R1', parent_id=g4.group_id)
 
        Session().commit()
 
        assert g1.full_path == 'R1_NEW/R1'
 
        assert g2.full_path == 'R1_NEW/R1/R2'
 
@@ -182,15 +182,15 @@ class TestRepoGroups(base.TestController
 
        assert r.repo_name == 'R1_NEW/R1/R2/R3/R3_REPO'
 

	
 
    def test_change_parent_of_top_level_group_in_nested_setup_with_rename(self):
 
        g1 = fixture.create_repo_group(u'X1')
 
        g2 = fixture.create_repo_group(u'X2', parent_group_id=g1.group_id)
 
        g3 = fixture.create_repo_group(u'X3', parent_group_id=g2.group_id)
 
        g4 = fixture.create_repo_group(u'X1_NEW')
 
        g1 = fixture.create_repo_group('X1')
 
        g2 = fixture.create_repo_group('X2', parent_group_id=g1.group_id)
 
        g3 = fixture.create_repo_group('X3', parent_group_id=g2.group_id)
 
        g4 = fixture.create_repo_group('X1_NEW')
 

	
 
        r = fixture.create_repo(u'X1/X2/X3/X3_REPO', repo_group=g3.group_id)
 
        r = fixture.create_repo('X1/X2/X3/X3_REPO', repo_group=g3.group_id)
 

	
 
        ## rename L1 all groups should be now changed
 
        _update_repo_group(g1.group_id, u'X1_PRIM', parent_id=g4.group_id)
 
        _update_repo_group(g1.group_id, 'X1_PRIM', parent_id=g4.group_id)
 
        Session().commit()
 
        assert g1.full_path == 'X1_NEW/X1_PRIM'
 
        assert g2.full_path == 'X1_NEW/X1_PRIM/X2'
kallithea/tests/models/test_repos.py
Show inline comments
 
@@ -17,65 +17,65 @@ class TestRepos(base.TestController):
 
        Session.remove()
 

	
 
    def test_remove_repo(self):
 
        repo = fixture.create_repo(name=u'test-repo-1')
 
        repo = fixture.create_repo(name='test-repo-1')
 
        Session().commit()
 

	
 
        RepoModel().delete(repo=repo)
 
        Session().commit()
 

	
 
        assert Repository.get_by_repo_name(repo_name=u'test-repo-1') is None
 
        assert Repository.get_by_repo_name(repo_name='test-repo-1') is None
 

	
 
    def test_remove_repo_repo_raises_exc_when_attached_forks(self):
 
        repo = fixture.create_repo(name=u'test-repo-1')
 
        repo = fixture.create_repo(name='test-repo-1')
 
        Session().commit()
 

	
 
        fixture.create_fork(repo.repo_name, u'test-repo-fork-1')
 
        fixture.create_fork(repo.repo_name, 'test-repo-fork-1')
 
        Session().commit()
 

	
 
        with pytest.raises(AttachedForksError):
 
            RepoModel().delete(repo=repo)
 
        # cleanup
 
        RepoModel().delete(repo=u'test-repo-fork-1')
 
        RepoModel().delete(repo=u'test-repo-1')
 
        RepoModel().delete(repo='test-repo-fork-1')
 
        RepoModel().delete(repo='test-repo-1')
 
        Session().commit()
 

	
 
    def test_remove_repo_delete_forks(self):
 
        repo = fixture.create_repo(name=u'test-repo-1')
 
        repo = fixture.create_repo(name='test-repo-1')
 
        Session().commit()
 

	
 
        fork = fixture.create_fork(repo.repo_name, u'test-repo-fork-1')
 
        fork = fixture.create_fork(repo.repo_name, 'test-repo-fork-1')
 
        Session().commit()
 

	
 
        # fork of fork
 
        fixture.create_fork(fork.repo_name, u'test-repo-fork-fork-1')
 
        fixture.create_fork(fork.repo_name, 'test-repo-fork-fork-1')
 
        Session().commit()
 

	
 
        RepoModel().delete(repo=repo, forks='delete')
 
        Session().commit()
 

	
 
        assert Repository.get_by_repo_name(repo_name=u'test-repo-1') is None
 
        assert Repository.get_by_repo_name(repo_name=u'test-repo-fork-1') is None
 
        assert Repository.get_by_repo_name(repo_name=u'test-repo-fork-fork-1') is None
 
        assert Repository.get_by_repo_name(repo_name='test-repo-1') is None
 
        assert Repository.get_by_repo_name(repo_name='test-repo-fork-1') is None
 
        assert Repository.get_by_repo_name(repo_name='test-repo-fork-fork-1') is None
 

	
 
    def test_remove_repo_detach_forks(self):
 
        repo = fixture.create_repo(name=u'test-repo-1')
 
        repo = fixture.create_repo(name='test-repo-1')
 
        Session().commit()
 

	
 
        fork = fixture.create_fork(repo.repo_name, u'test-repo-fork-1')
 
        fork = fixture.create_fork(repo.repo_name, 'test-repo-fork-1')
 
        Session().commit()
 

	
 
        # fork of fork
 
        fixture.create_fork(fork.repo_name, u'test-repo-fork-fork-1')
 
        fixture.create_fork(fork.repo_name, 'test-repo-fork-fork-1')
 
        Session().commit()
 

	
 
        RepoModel().delete(repo=repo, forks='detach')
 
        Session().commit()
 

	
 
        try:
 
            assert Repository.get_by_repo_name(repo_name=u'test-repo-1') is None
 
            assert Repository.get_by_repo_name(repo_name=u'test-repo-fork-1') is not None
 
            assert Repository.get_by_repo_name(repo_name=u'test-repo-fork-fork-1') is not None
 
            assert Repository.get_by_repo_name(repo_name='test-repo-1') is None
 
            assert Repository.get_by_repo_name(repo_name='test-repo-fork-1') is not None
 
            assert Repository.get_by_repo_name(repo_name='test-repo-fork-fork-1') is not None
 
        finally:
 
            RepoModel().delete(repo=u'test-repo-fork-fork-1')
 
            RepoModel().delete(repo=u'test-repo-fork-1')
 
            RepoModel().delete(repo='test-repo-fork-fork-1')
 
            RepoModel().delete(repo='test-repo-fork-1')
 
            Session().commit()
kallithea/tests/models/test_settings.py
Show inline comments
 
@@ -35,7 +35,7 @@ def test_list_valued_setting_update():
 
    setting = Setting.create_or_update(name, 'spam', type='list')
 
    Session().flush() # must flush so we can delete it below
 
    try:
 
        assert setting.app_settings_value == [u'spam']
 
        assert setting.app_settings_value == ['spam']
 
        # Assign back setting value.
 
        setting.app_settings_value = setting.app_settings_value
 
        # Quirk: value is stringified on write and listified on read.
kallithea/tests/models/test_user_group_permissions_on_repo_groups.py
Show inline comments
 
@@ -16,7 +16,7 @@ _get_repo_perms = None
 
_get_group_perms = None
 

	
 

	
 
def permissions_setup_func(group_name=u'g0', perm='group.read', recursive='all'):
 
def permissions_setup_func(group_name='g0', perm='group.read', recursive='all'):
 
    """
 
    Resets all permissions to perm attribute
 
    """
 
@@ -43,7 +43,7 @@ def setup_module():
 
    Session().commit()
 
    test_u2_id = test_u2.user_id
 

	
 
    gr1 = fixture.create_user_group(u'perms_group_1')
 
    gr1 = fixture.create_user_group('perms_group_1')
 
    Session().commit()
 
    test_u2_gr_id = gr1.users_group_id
 
    UserGroupModel().add_user_to_group(gr1, user=test_u2_id)
 
@@ -57,13 +57,13 @@ def setup_module():
 

	
 
def teardown_module():
 
    _destroy_project_tree(test_u2_id)
 
    fixture.destroy_user_group(u'perms_group_1')
 
    fixture.destroy_user_group('perms_group_1')
 

	
 

	
 
def test_user_permissions_on_group_without_recursive_mode():
 
    # set permission to g0 non-recursive mode
 
    recursive = 'none'
 
    group = u'g0'
 
    group = 'g0'
 
    permissions_setup_func(group, 'group.write', recursive=recursive)
 

	
 
    items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -82,7 +82,7 @@ def test_user_permissions_on_group_witho
 
def test_user_permissions_on_group_without_recursive_mode_subgroup():
 
    # set permission to g0 non-recursive mode
 
    recursive = 'none'
 
    group = u'g0/g0_1'
 
    group = 'g0/g0_1'
 
    permissions_setup_func(group, 'group.write', recursive=recursive)
 

	
 
    items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -103,7 +103,7 @@ def test_user_permissions_on_group_with_
 
    # set permission to g0 recursive mode, all children including
 
    # other repos and groups should have this permission now set !
 
    recursive = 'all'
 
    group = u'g0'
 
    group = 'g0'
 
    permissions_setup_func(group, 'group.write', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -120,7 +120,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_mode_inner_group():
 
    ## set permission to g0_3 group to none
 
    recursive = 'all'
 
    group = u'g0/g0_3'
 
    group = 'g0/g0_3'
 
    permissions_setup_func(group, 'group.none', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -137,7 +137,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_mode_deepest():
 
    ## set permission to g0/g0_1/g0_1_1 group to write
 
    recursive = 'all'
 
    group = u'g0/g0_1/g0_1_1'
 
    group = 'g0/g0_1/g0_1_1'
 
    permissions_setup_func(group, 'group.write', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -154,7 +154,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_mode_only_with_repos():
 
    ## set permission to g0/g0_2 group to admin
 
    recursive = 'all'
 
    group = u'g0/g0_2'
 
    group = 'g0/g0_2'
 
    permissions_setup_func(group, 'group.admin', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -171,7 +171,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_mode_on_repos():
 
    # set permission to g0/g0_1 with recursive mode on just repositories
 
    recursive = 'repos'
 
    group = u'g0/g0_1'
 
    group = 'g0/g0_1'
 
    perm = 'group.write'
 
    permissions_setup_func(group, perm, recursive=recursive)
 

	
 
@@ -195,7 +195,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_mode_on_repo_groups():
 
    # set permission to g0/g0_1 with recursive mode on just repository groups
 
    recursive = 'groups'
 
    group = u'g0/g0_1'
 
    group = 'g0/g0_1'
 
    perm = 'group.none'
 
    permissions_setup_func(group, perm, recursive=recursive)
 

	
kallithea/tests/models/test_user_groups.py
Show inline comments
 
@@ -18,12 +18,12 @@ class TestUserGroups(base.TestController
 

	
 
    @base.parametrize('pre_existing,regular_should_be,external_should_be,groups,expected', [
 
        ([], [], [], [], []),
 
        ([], [u'regular'], [], [], [u'regular']),  # no changes of regular
 
        ([u'some_other'], [], [], [u'some_other'], []),   # not added to regular group
 
        ([], [u'regular'], [u'container'], [u'container'], [u'regular', u'container']),
 
        ([], [u'regular'], [], [u'container', u'container2'], [u'regular', u'container', u'container2']),
 
        ([], [u'regular'], [u'other'], [], [u'regular']),  # remove not used
 
        ([u'some_other'], [u'regular'], [u'other', u'container'], [u'container', u'container2'], [u'regular', u'container', u'container2']),
 
        ([], ['regular'], [], [], ['regular']),  # no changes of regular
 
        (['some_other'], [], [], ['some_other'], []),   # not added to regular group
 
        ([], ['regular'], ['container'], ['container'], ['regular', 'container']),
 
        ([], ['regular'], [], ['container', 'container2'], ['regular', 'container', 'container2']),
 
        ([], ['regular'], ['other'], [], ['regular']),  # remove not used
 
        (['some_other'], ['regular'], ['other', 'container'], ['container', 'container2'], ['regular', 'container', 'container2']),
 
    ])
 
    def test_enforce_groups(self, pre_existing, regular_should_be,
 
                            external_should_be, groups, expected):
kallithea/tests/models/test_user_permissions_on_repo_groups.py
Show inline comments
 
@@ -11,7 +11,7 @@ _get_repo_perms = None
 
_get_group_perms = None
 

	
 

	
 
def permissions_setup_func(group_name=u'g0', perm='group.read', recursive='all',
 
def permissions_setup_func(group_name='g0', perm='group.read', recursive='all',
 
                           user_id=None):
 
    """
 
    Resets all permissions to perm attribute
 
@@ -56,7 +56,7 @@ def teardown_module():
 
def test_user_permissions_on_group_without_recursive_mode():
 
    # set permission to g0 non-recursive mode
 
    recursive = 'none'
 
    group = u'g0'
 
    group = 'g0'
 
    permissions_setup_func(group, 'group.write', recursive=recursive)
 

	
 
    items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -75,7 +75,7 @@ def test_user_permissions_on_group_witho
 
def test_user_permissions_on_group_without_recursive_mode_subgroup():
 
    # set permission to g0 non-recursive mode
 
    recursive = 'none'
 
    group = u'g0/g0_1'
 
    group = 'g0/g0_1'
 
    permissions_setup_func(group, 'group.write', recursive=recursive)
 

	
 
    items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -96,7 +96,7 @@ def test_user_permissions_on_group_with_
 
    # set permission to g0 recursive mode, all children including
 
    # other repos and groups should have this permission now set !
 
    recursive = 'all'
 
    group = u'g0'
 
    group = 'g0'
 
    permissions_setup_func(group, 'group.write', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -115,7 +115,7 @@ def test_user_permissions_on_group_with_
 
    # set permission to g0 recursive mode, all children including
 
    # other repos and groups should have this permission now set !
 
    recursive = 'all'
 
    group = u'g0'
 
    group = 'g0'
 
    default_user_id = User.get_default_user().user_id
 
    permissions_setup_func(group, 'group.write', recursive=recursive,
 
                           user_id=default_user_id)
 
@@ -142,7 +142,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_mode_inner_group():
 
    ## set permission to g0_3 group to none
 
    recursive = 'all'
 
    group = u'g0/g0_3'
 
    group = 'g0/g0_3'
 
    permissions_setup_func(group, 'group.none', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -159,7 +159,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_mode_deepest():
 
    ## set permission to g0_3 group to none
 
    recursive = 'all'
 
    group = u'g0/g0_1/g0_1_1'
 
    group = 'g0/g0_1/g0_1_1'
 
    permissions_setup_func(group, 'group.write', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -176,7 +176,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_mode_only_with_repos():
 
    ## set permission to g0_3 group to none
 
    recursive = 'all'
 
    group = u'g0/g0_2'
 
    group = 'g0/g0_2'
 
    permissions_setup_func(group, 'group.admin', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
 
@@ -194,7 +194,7 @@ def test_user_permissions_on_group_with_
 
    # set permission to g0/g0_1 recursive repos only mode, all children including
 
    # other repos should have this permission now set, inner groups are excluded!
 
    recursive = 'repos'
 
    group = u'g0/g0_1'
 
    group = 'g0/g0_1'
 
    perm = 'group.none'
 
    default_user_id = User.get_default_user().user_id
 

	
 
@@ -227,7 +227,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_repo_mode_inner_group():
 
    ## set permission to g0_3 group to none, with recursive repos only
 
    recursive = 'repos'
 
    group = u'g0/g0_3'
 
    group = 'g0/g0_3'
 
    perm = 'group.none'
 
    permissions_setup_func(group, perm, recursive=recursive)
 

	
 
@@ -253,7 +253,7 @@ def test_user_permissions_on_group_with_
 
    # other groups should have this permission now set. repositories should
 
    # remain intact as we use groups only mode !
 
    recursive = 'groups'
 
    group = u'g0/g0_1'
 
    group = 'g0/g0_1'
 
    default_user_id = User.get_default_user().user_id
 
    permissions_setup_func(group, 'group.write', recursive=recursive,
 
                           user_id=default_user_id)
 
@@ -278,7 +278,7 @@ def test_user_permissions_on_group_with_
 
def test_user_permissions_on_group_with_recursive_group_mode_inner_group():
 
    ## set permission to g0_3 group to none, with recursive mode for groups only
 
    recursive = 'groups'
 
    group = u'g0/g0_3'
 
    group = 'g0/g0_3'
 
    permissions_setup_func(group, 'group.none', recursive=recursive)
 

	
 
    repo_items = [x for x in _get_repo_perms(group, recursive)]
kallithea/tests/models/test_users.py
Show inline comments
 
@@ -21,21 +21,21 @@ class TestUser(base.TestController):
 
        Session.remove()
 

	
 
    def test_create_and_remove(self):
 
        usr = UserModel().create_or_update(username=u'test_user',
 
                                           password=u'qweqwe',
 
                                           email=u'u232@example.com',
 
                                           firstname=u'u1', lastname=u'u1')
 
        usr = UserModel().create_or_update(username='test_user',
 
                                           password='qweqwe',
 
                                           email='u232@example.com',
 
                                           firstname='u1', lastname='u1')
 
        Session().commit()
 
        assert User.get_by_username(u'test_user') == usr
 
        assert User.get_by_username(u'test_USER', case_insensitive=True) == usr
 
        assert User.get_by_username('test_user') == usr
 
        assert User.get_by_username('test_USER', case_insensitive=True) == usr
 
        # User.get_by_username without explicit request for case insensitivty
 
        # will use database case sensitivity. The following will thus return
 
        # None on for example PostgreSQL but find test_user on MySQL - we are
 
        # fine with leaving that as undefined as long as it doesn't crash.
 
        User.get_by_username(u'test_USER', case_insensitive=False)
 
        User.get_by_username('test_USER', case_insensitive=False)
 

	
 
        # make user group
 
        user_group = fixture.create_user_group(u'some_example_group')
 
        user_group = fixture.create_user_group('some_example_group')
 
        Session().commit()
 

	
 
        UserGroupModel().add_user_to_group(user_group, usr)
 
@@ -49,15 +49,15 @@ class TestUser(base.TestController):
 
        assert UserGroupMember.query().all() == []
 

	
 
    def test_additional_email_as_main(self):
 
        usr = UserModel().create_or_update(username=u'test_user',
 
                                           password=u'qweqwe',
 
                                     email=u'main_email@example.com',
 
                                     firstname=u'u1', lastname=u'u1')
 
        usr = UserModel().create_or_update(username='test_user',
 
                                           password='qweqwe',
 
                                     email='main_email@example.com',
 
                                     firstname='u1', lastname='u1')
 
        Session().commit()
 

	
 
        with pytest.raises(AttributeError):
 
            m = UserEmailMap()
 
            m.email = u'main_email@example.com'
 
            m.email = 'main_email@example.com'
 
            m.user = usr
 
            Session().add(m)
 
            Session().commit()
 
@@ -66,14 +66,14 @@ class TestUser(base.TestController):
 
        Session().commit()
 

	
 
    def test_extra_email_map(self):
 
        usr = UserModel().create_or_update(username=u'test_user',
 
                                           password=u'qweqwe',
 
                                     email=u'main_email@example.com',
 
                                     firstname=u'u1', lastname=u'u1')
 
        usr = UserModel().create_or_update(username='test_user',
 
                                           password='qweqwe',
 
                                     email='main_email@example.com',
 
                                     firstname='u1', lastname='u1')
 
        Session().commit()
 

	
 
        m = UserEmailMap()
 
        m.email = u'main_email2@example.com'
 
        m.email = 'main_email2@example.com'
 
        m.user = usr
 
        Session().add(m)
 
        Session().commit()
 
@@ -104,10 +104,10 @@ class TestUser(base.TestController):
 
class TestUsers(base.TestController):
 

	
 
    def setup_method(self, method):
 
        self.u1 = UserModel().create_or_update(username=u'u1',
 
                                        password=u'qweqwe',
 
                                        email=u'u1@example.com',
 
                                        firstname=u'u1', lastname=u'u1')
 
        self.u1 = UserModel().create_or_update(username='u1',
 
                                        password='qweqwe',
 
                                        email='u1@example.com',
 
                                        firstname='u1', lastname='u1')
 

	
 
    def teardown_method(self, method):
 
        perm = Permission.query().all()
kallithea/tests/other/test_auth_ldap.py
Show inline comments
 
@@ -22,8 +22,8 @@ class _AuthLdapMock():
 
        pass
 

	
 
    def authenticate_ldap(self, username, password):
 
        return 'spam dn', dict(test_ldap_firstname=[u'spam ldap first name'],
 
                               test_ldap_lastname=[u'spam ldap last name'],
 
        return 'spam dn', dict(test_ldap_firstname=['spam ldap first name'],
 
                               test_ldap_lastname=['spam ldap last name'],
 
                               test_ldap_email=['spam ldap email'])
 

	
 

	
 
@@ -39,8 +39,8 @@ def test_update_user_attributes_from_lda
 
    user_input = dict(username='test-user-{0}'.format(uniqifier),
 
                      password='spam password',
 
                      email='spam-email-{0}'.format(uniqifier),
 
                      firstname=u'spam first name',
 
                      lastname=u'spam last name',
 
                      firstname='spam first name',
 
                      lastname='spam last name',
 
                      active=True,
 
                      admin=False)
 
    user = create_test_user(user_input)
 
@@ -54,14 +54,14 @@ def test_update_user_attributes_from_lda
 
    # Verify that authenication succeeded and retrieved correct attributes
 
    # from LDAP.
 
    assert user_data is not None
 
    assert user_data.get('firstname') == u'spam ldap first name'
 
    assert user_data.get('lastname') == u'spam ldap last name'
 
    assert user_data.get('firstname') == 'spam ldap first name'
 
    assert user_data.get('lastname') == 'spam ldap last name'
 
    assert user_data.get('email') == 'spam ldap email'
 

	
 
    # Verify that authentication overwrote user attributes with the ones
 
    # retrieved from LDAP.
 
    assert user.firstname == u'spam ldap first name'
 
    assert user.lastname == u'spam ldap last name'
 
    assert user.firstname == 'spam ldap first name'
 
    assert user.lastname == 'spam ldap last name'
 
    assert user.email == 'spam ldap email'
 

	
 

	
 
@@ -83,16 +83,16 @@ def test_init_user_attributes_from_ldap(
 
    # Verify that authenication succeeded and retrieved correct attributes
 
    # from LDAP.
 
    assert user_data is not None
 
    assert user_data.get('firstname') == u'spam ldap first name'
 
    assert user_data.get('lastname') == u'spam ldap last name'
 
    assert user_data.get('firstname') == 'spam ldap first name'
 
    assert user_data.get('lastname') == 'spam ldap last name'
 
    assert user_data.get('email') == 'spam ldap email'
 

	
 
    # Verify that authentication created new user with attributes
 
    # retrieved from LDAP.
 
    new_user = User.get_by_username(username)
 
    assert new_user is not None
 
    assert new_user.firstname == u'spam ldap first name'
 
    assert new_user.lastname == u'spam ldap last name'
 
    assert new_user.firstname == 'spam ldap first name'
 
    assert new_user.lastname == 'spam ldap last name'
 
    assert new_user.email == 'spam ldap email'
 

	
 

	
 
@@ -126,14 +126,14 @@ def test_init_user_attributes_from_ldap_
 
    # Verify that authenication succeeded and retrieved correct attributes
 
    # from LDAP, with empty email.
 
    assert user_data is not None
 
    assert user_data.get('firstname') == u'spam ldap first name'
 
    assert user_data.get('lastname') == u'spam ldap last name'
 
    assert user_data.get('firstname') == 'spam ldap first name'
 
    assert user_data.get('lastname') == 'spam ldap last name'
 
    assert user_data.get('email') == ''
 

	
 
    # Verify that authentication created new user with attributes
 
    # retrieved from LDAP, with email == None.
 
    new_user = User.get_by_username(username)
 
    assert new_user is not None
 
    assert new_user.firstname == u'spam ldap first name'
 
    assert new_user.lastname == u'spam ldap last name'
 
    assert new_user.firstname == 'spam ldap first name'
 
    assert new_user.lastname == 'spam ldap last name'
 
    assert new_user.email is None
kallithea/tests/other/test_libs.py
Show inline comments
 
@@ -142,20 +142,20 @@ class TestLibs(base.TestController):
 
        assert expected == set(extract_mentioned_usernames(sample))
 

	
 
    @base.parametrize('age_args,expected', [
 
        (dict(), u'just now'),
 
        (dict(seconds= -1), u'1 second ago'),
 
        (dict(seconds= -60 * 2), u'2 minutes ago'),
 
        (dict(hours= -1), u'1 hour ago'),
 
        (dict(hours= -24), u'1 day ago'),
 
        (dict(hours= -24 * 5), u'5 days ago'),
 
        (dict(months= -1), u'1 month ago'),
 
        (dict(months= -1, days= -2), u'1 month and 2 days ago'),
 
        (dict(months= -1, days= -20), u'1 month and 19 days ago'),
 
        (dict(years= -1, months= -1), u'1 year and 1 month ago'),
 
        (dict(years= -1, months= -10), u'1 year and 10 months ago'),
 
        (dict(years= -2, months= -4), u'2 years and 4 months ago'),
 
        (dict(years= -2, months= -11), u'2 years and 11 months ago'),
 
        (dict(years= -3, months= -2), u'3 years and 2 months ago'),
 
        (dict(), 'just now'),
 
        (dict(seconds= -1), '1 second ago'),
 
        (dict(seconds= -60 * 2), '2 minutes ago'),
 
        (dict(hours= -1), '1 hour ago'),
 
        (dict(hours= -24), '1 day ago'),
 
        (dict(hours= -24 * 5), '5 days ago'),
 
        (dict(months= -1), '1 month ago'),
 
        (dict(months= -1, days= -2), '1 month and 2 days ago'),
 
        (dict(months= -1, days= -20), '1 month and 19 days ago'),
 
        (dict(years= -1, months= -1), '1 year and 1 month ago'),
 
        (dict(years= -1, months= -10), '1 year and 10 months ago'),
 
        (dict(years= -2, months= -4), '2 years and 4 months ago'),
 
        (dict(years= -2, months= -11), '2 years and 11 months ago'),
 
        (dict(years= -3, months= -2), '3 years and 2 months ago'),
 
    ])
 
    def test_age(self, age_args, expected):
 
        from kallithea.lib.utils2 import age
 
@@ -166,21 +166,21 @@ class TestLibs(base.TestController):
 
            assert age(n + delt(**age_args), now=n) == expected
 

	
 
    @base.parametrize('age_args,expected', [
 
        (dict(), u'just now'),
 
        (dict(seconds= -1), u'1 second ago'),
 
        (dict(seconds= -60 * 2), u'2 minutes ago'),
 
        (dict(hours= -1), u'1 hour ago'),
 
        (dict(hours= -24), u'1 day ago'),
 
        (dict(hours= -24 * 5), u'5 days ago'),
 
        (dict(months= -1), u'1 month ago'),
 
        (dict(months= -1, days= -2), u'1 month ago'),
 
        (dict(months= -1, days= -20), u'1 month ago'),
 
        (dict(years= -1, months= -1), u'13 months ago'),
 
        (dict(years= -1, months= -10), u'22 months ago'),
 
        (dict(years= -2, months= -4), u'2 years ago'),
 
        (dict(years= -2, months= -11), u'3 years ago'),
 
        (dict(years= -3, months= -2), u'3 years ago'),
 
        (dict(years= -4, months= -8), u'5 years ago'),
 
        (dict(), 'just now'),
 
        (dict(seconds= -1), '1 second ago'),
 
        (dict(seconds= -60 * 2), '2 minutes ago'),
 
        (dict(hours= -1), '1 hour ago'),
 
        (dict(hours= -24), '1 day ago'),
 
        (dict(hours= -24 * 5), '5 days ago'),
 
        (dict(months= -1), '1 month ago'),
 
        (dict(months= -1, days= -2), '1 month ago'),
 
        (dict(months= -1, days= -20), '1 month ago'),
 
        (dict(years= -1, months= -1), '13 months ago'),
 
        (dict(years= -1, months= -10), '22 months ago'),
 
        (dict(years= -2, months= -4), '2 years ago'),
 
        (dict(years= -2, months= -11), '3 years ago'),
 
        (dict(years= -3, months= -2), '3 years ago'),
 
        (dict(years= -4, months= -8), '5 years ago'),
 
    ])
 
    def test_age_short(self, age_args, expected):
 
        from kallithea.lib.utils2 import age
 
@@ -191,15 +191,15 @@ class TestLibs(base.TestController):
 
            assert age(n + delt(**age_args), show_short_version=True, now=n) == expected
 

	
 
    @base.parametrize('age_args,expected', [
 
        (dict(), u'just now'),
 
        (dict(seconds=1), u'in 1 second'),
 
        (dict(seconds=60 * 2), u'in 2 minutes'),
 
        (dict(hours=1), u'in 1 hour'),
 
        (dict(hours=24), u'in 1 day'),
 
        (dict(hours=24 * 5), u'in 5 days'),
 
        (dict(months=1), u'in 1 month'),
 
        (dict(months=1, days=1), u'in 1 month and 1 day'),
 
        (dict(years=1, months=1), u'in 1 year and 1 month')
 
        (dict(), 'just now'),
 
        (dict(seconds=1), 'in 1 second'),
 
        (dict(seconds=60 * 2), 'in 2 minutes'),
 
        (dict(hours=1), 'in 1 hour'),
 
        (dict(hours=24), 'in 1 day'),
 
        (dict(hours=24 * 5), 'in 5 days'),
 
        (dict(months=1), 'in 1 month'),
 
        (dict(months=1, days=1), 'in 1 month and 1 day'),
 
        (dict(years=1, months=1), 'in 1 year and 1 month')
 
    ])
 
    def test_age_in_future(self, age_args, expected):
 
        from kallithea.lib.utils2 import age
kallithea/tests/other/test_mail.py
Show inline comments
 
@@ -175,7 +175,7 @@ class TestMail(base.TestController):
 
        subject = 'subject'
 
        body = 'body'
 
        html_body = 'html_body'
 
        author = User(name='foo', lastname=u'(fubar) "baz"')
 
        author = User(name='foo', lastname='(fubar) "baz"')
 
        headers = {'extra': 'yes'}
 

	
 
        config_mock = {
kallithea/tests/other/test_validators.py
Show inline comments
 
@@ -54,26 +54,26 @@ class TestRepoGroups(base.TestController
 
    def test_ValidUserGroup(self):
 
        validator = v.ValidUserGroup()
 
        with pytest.raises(formencode.Invalid):
 
            validator.to_python(u'default')
 
            validator.to_python('default')
 
        with pytest.raises(formencode.Invalid):
 
            validator.to_python(u'.,')
 
            validator.to_python('.,')
 

	
 
        gr = fixture.create_user_group(u'test')
 
        gr2 = fixture.create_user_group(u'tes2')
 
        gr = fixture.create_user_group('test')
 
        gr2 = fixture.create_user_group('tes2')
 
        Session().commit()
 
        with pytest.raises(formencode.Invalid):
 
            validator.to_python(u'test')
 
            validator.to_python('test')
 
        assert gr.users_group_id is not None
 
        validator = v.ValidUserGroup(edit=True,
 
                                    old_data={'users_group_id':
 
                                              gr2.users_group_id})
 

	
 
        with pytest.raises(formencode.Invalid):
 
            validator.to_python(u'test')
 
            validator.to_python('test')
 
        with pytest.raises(formencode.Invalid):
 
            validator.to_python(u'TesT')
 
            validator.to_python('TesT')
 
        with pytest.raises(formencode.Invalid):
 
            validator.to_python(u'TEST')
 
            validator.to_python('TEST')
 
        UserGroupModel().delete(gr)
 
        UserGroupModel().delete(gr2)
 
        Session().commit()
 
@@ -83,7 +83,7 @@ class TestRepoGroups(base.TestController
 
        model = RepoGroupModel()
 
        with pytest.raises(formencode.Invalid):
 
            validator.to_python({'group_name': base.HG_REPO, })
 
        gr = model.create(group_name=u'test_gr', group_description=u'desc',
 
        gr = model.create(group_name='test_gr', group_description='desc',
 
                          parent=None,
 
                          just_db=True,
 
                          owner=base.TEST_USER_ADMIN_LOGIN)
 
@@ -147,8 +147,8 @@ class TestRepoGroups(base.TestController
 
        with pytest.raises(formencode.Invalid):
 
            validator.to_python({'repo_name': base.HG_REPO})
 

	
 
        gr = RepoGroupModel().create(group_name=u'group_test',
 
                                      group_description=u'desc',
 
        gr = RepoGroupModel().create(group_name='group_test',
 
                                      group_description='desc',
 
                                      parent=None,
 
                                      owner=base.TEST_USER_ADMIN_LOGIN)
 
        with pytest.raises(formencode.Invalid):
kallithea/tests/other/test_vcs_operations.py
Show inline comments
 
@@ -65,8 +65,8 @@ class HttpVcsTest(object):
 

	
 
class SshVcsTest(object):
 
    public_keys = {
 
        base.TEST_USER_REGULAR_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost',
 
        base.TEST_USER_ADMIN_LOGIN: u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUq== kallithea@localhost',
 
        base.TEST_USER_REGULAR_LOGIN: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUQ== kallithea@localhost',
 
        base.TEST_USER_ADMIN_LOGIN: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQC6Ycnc2oUZHQnQwuqgZqTTdMDZD7ataf3JM7oG2Fw8JR6cdmz4QZLe5mfDwaFwG2pWHLRpVqzfrD/Pn3rIO++bgCJH5ydczrl1WScfryV1hYMJ/4EzLGM657J1/q5EI+b9SntKjf4ax+KP322L0TNQGbZUHLbfG2MwHMrYBQpHUq== kallithea@localhost',
 
    }
 

	
 
    @classmethod
 
@@ -76,7 +76,7 @@ class SshVcsTest(object):
 
            ssh_key = user.ssh_keys[0]
 
        else:
 
            sshkeymodel = SshKeyModel()
 
            ssh_key = sshkeymodel.create(user, u'test key', cls.public_keys[user.username])
 
            ssh_key = sshkeymodel.create(user, 'test key', cls.public_keys[user.username])
 
            Session().commit()
 

	
 
        return cls._ssh_param(repo_name, user, ssh_key, client_ip)
 
@@ -263,9 +263,9 @@ class TestVCSOperations(base.TestControl
 
    @pytest.fixture(scope="module")
 
    def testfork(self):
 
        # create fork so the repo stays untouched
 
        git_fork_name = u'%s_fork%s' % (base.GIT_REPO, next(_RandomNameSequence()))
 
        git_fork_name = '%s_fork%s' % (base.GIT_REPO, next(_RandomNameSequence()))
 
        fixture.create_fork(base.GIT_REPO, git_fork_name)
 
        hg_fork_name = u'%s_fork%s' % (base.HG_REPO, next(_RandomNameSequence()))
 
        hg_fork_name = '%s_fork%s' % (base.HG_REPO, next(_RandomNameSequence()))
 
        fixture.create_fork(base.HG_REPO, hg_fork_name)
 
        return {'git': git_fork_name, 'hg': hg_fork_name}
 

	
 
@@ -319,7 +319,7 @@ class TestVCSOperations(base.TestControl
 
        Session().commit()
 

	
 
        # Create an empty server repo using the API
 
        repo_name = u'new_%s_%s' % (vt.repo_type, next(_RandomNameSequence()))
 
        repo_name = 'new_%s_%s' % (vt.repo_type, next(_RandomNameSequence()))
 
        usr = User.get_by_username(base.TEST_USER_ADMIN_LOGIN)
 
        params = {
 
            "id": 7,
 
@@ -337,7 +337,7 @@ class TestVCSOperations(base.TestControl
 
        result = json.loads(response.read())
 
        # Expect something like:
 
        # {u'result': {u'msg': u'Created new repository `new_XXX`', u'task': None, u'success': True}, u'id': 7, u'error': None}
 
        assert result[u'result'][u'success']
 
        assert result['result']['success']
 

	
 
        # Create local clone of the empty server repo
 
        local_clone_dir = _get_tmp_dir()
 
@@ -362,15 +362,15 @@ class TestVCSOperations(base.TestControl
 
        # <UserLog('id:new_git_XXX:push:aed9d4c1732a1927da3be42c47eb9afdc200d427,d38b083a07af10a9f44193486959a96a23db78da,4841ff9a2b385bec995f4679ef649adb3f437622')>
 
        action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)]
 
        assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == ([
 
            (u'started_following_repo', 0),
 
            (u'user_created_repo', 0),
 
            (u'pull', 0),
 
            (u'push', 3)]
 
            ('started_following_repo', 0),
 
            ('user_created_repo', 0),
 
            ('pull', 0),
 
            ('push', 3)]
 
            if vt.repo_type == 'git' else [
 
            (u'started_following_repo', 0),
 
            (u'user_created_repo', 0),
 
            ('started_following_repo', 0),
 
            ('user_created_repo', 0),
 
            # (u'pull', 0), # Mercurial outgoing hook is not called for empty clones
 
            (u'push', 3)])
 
            ('push', 3)])
 

	
 
    @parametrize_vcs_test
 
    def test_push_new_file(self, webserver, testfork, vt):
 
@@ -393,7 +393,7 @@ class TestVCSOperations(base.TestControl
 

	
 
        action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)]
 
        assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == \
 
            [(u'pull', 0), (u'push', 3)]
 
            [('pull', 0), ('push', 3)]
 

	
 
    @parametrize_vcs_test
 
    def test_pull(self, webserver, testfork, vt):
 
@@ -412,7 +412,7 @@ class TestVCSOperations(base.TestControl
 
            assert 'new changesets' in stdout
 

	
 
        action_parts = [ul.action for ul in UserLog.query().order_by(UserLog.user_log_id)]
 
        assert action_parts == [u'pull']
 
        assert action_parts == ['pull']
 

	
 
        # Test handling of URLs with extra '/' around repo_name
 
        stdout, stderr = Command(dest_dir).execute(vt.repo_type, 'pull', clone_url.replace('/' + vt.repo_name, '/./%s/' % vt.repo_name), ignoreReturnCode=True)
 
@@ -502,7 +502,7 @@ class TestVCSOperations(base.TestControl
 

	
 
        action_parts = [ul.action.split(':', 1) for ul in UserLog.query().order_by(UserLog.user_log_id)]
 
        assert [(t[0], (t[1].count(',') + 1) if len(t) == 2 else 0) for t in action_parts] == \
 
            [(u'pull', 0)]
 
            [('pull', 0)]
 

	
 
    @parametrize_vcs_test
 
    def test_push_back_to_wrong_url(self, webserver, vt):
kallithea/tests/vcs/base.py
Show inline comments
 
@@ -27,8 +27,8 @@ class _BackendTestMixin(object):
 
    def _get_commits(cls):
 
        commits = [
 
            {
 
                'message': u'Initial commit',
 
                'author': u'Joe Doe <joe.doe@example.com>',
 
                'message': 'Initial commit',
 
                'author': 'Joe Doe <joe.doe@example.com>',
 
                'date': datetime.datetime(2010, 1, 1, 20),
 
                'added': [
 
                    FileNode('foobar', content='Foobar'),
 
@@ -37,8 +37,8 @@ class _BackendTestMixin(object):
 
                ],
 
            },
 
            {
 
                'message': u'Changes...',
 
                'author': u'Jane Doe <jane.doe@example.com>',
 
                'message': 'Changes...',
 
                'author': 'Jane Doe <jane.doe@example.com>',
 
                'date': datetime.datetime(2010, 1, 1, 21),
 
                'added': [
 
                    FileNode('some/new.txt', content='news...'),
kallithea/tests/vcs/test_branches.py
Show inline comments
 
@@ -46,8 +46,8 @@ class BranchesTestCaseMixin(_BackendTest
 
        self.imc.add(vcs.nodes.FileNode('docs/index.txt',
 
            content='Documentation\n'))
 
        foobar_tip = self.imc.commit(
 
            message=u'New branch: foobar',
 
            author=u'joe',
 
            message='New branch: foobar',
 
            author='joe',
 
            branch='foobar',
 
        )
 
        assert 'foobar' in self.repo.branches
 
@@ -59,23 +59,23 @@ class BranchesTestCaseMixin(_BackendTest
 
        self.imc.add(vcs.nodes.FileNode('docs/index.txt',
 
            content='Documentation\n'))
 
        foobar_tip = self.imc.commit(
 
            message=u'New branch: foobar',
 
            author=u'joe',
 
            message='New branch: foobar',
 
            author='joe',
 
            branch='foobar',
 
            parents=[tip],
 
        )
 
        self.imc.change(vcs.nodes.FileNode('docs/index.txt',
 
            content='Documentation\nand more...\n'))
 
        newtip = self.imc.commit(
 
            message=u'At default branch',
 
            author=u'joe',
 
            message='At default branch',
 
            author='joe',
 
            branch=foobar_tip.branch,
 
            parents=[foobar_tip],
 
        )
 

	
 
        newest_tip = self.imc.commit(
 
            message=u'Merged with %s' % foobar_tip.raw_id,
 
            author=u'joe',
 
            message='Merged with %s' % foobar_tip.raw_id,
 
            author='joe',
 
            branch=self.backend_class.DEFAULT_BRANCH_NAME,
 
            parents=[newtip, foobar_tip],
 
        )
 
@@ -85,16 +85,16 @@ class BranchesTestCaseMixin(_BackendTest
 

	
 
    def test_branch_with_slash_in_name(self):
 
        self.imc.add(vcs.nodes.FileNode('extrafile', content='Some data\n'))
 
        self.imc.commit(u'Branch with a slash!', author=u'joe',
 
        self.imc.commit('Branch with a slash!', author='joe',
 
            branch='issue/123')
 
        assert 'issue/123' in self.repo.branches
 

	
 
    def test_branch_with_slash_in_name_and_similar_without(self):
 
        self.imc.add(vcs.nodes.FileNode('extrafile', content='Some data\n'))
 
        self.imc.commit(u'Branch with a slash!', author=u'joe',
 
        self.imc.commit('Branch with a slash!', author='joe',
 
            branch='issue/123')
 
        self.imc.add(vcs.nodes.FileNode('extrafile II', content='Some data\n'))
 
        self.imc.commit(u'Branch without a slash...', author=u'joe',
 
        self.imc.commit('Branch without a slash...', author='joe',
 
            branch='123')
 
        assert 'issue/123' in self.repo.branches
 
        assert '123' in self.repo.branches
kallithea/tests/vcs/test_changesets.py
Show inline comments
 
@@ -21,7 +21,7 @@ class TestBaseChangeset(object):
 
        changeset.date = datetime.datetime(2011, 1, 30, 1, 45)
 
        changeset.message = 'Message of a commit'
 
        changeset.author = 'Joe Doe <joe.doe@example.com>'
 
        changeset.added = [FileNode('foo/bar/baz'), FileNode(u'foobar'), FileNode(u'blåbærgrød')]
 
        changeset.added = [FileNode('foo/bar/baz'), FileNode('foobar'), FileNode('blåbærgrød')]
 
        changeset.changed = []
 
        changeset.removed = []
 
        assert changeset.as_dict() == {
 
@@ -34,7 +34,7 @@ class TestBaseChangeset(object):
 
                'name': 'Joe Doe',
 
                'email': 'joe.doe@example.com',
 
            },
 
            'added': ['foo/bar/baz', 'foobar', u'bl\xe5b\xe6rgr\xf8d'],
 
            'added': ['foo/bar/baz', 'foobar', 'bl\xe5b\xe6rgr\xf8d'],
 
            'changed': [],
 
            'removed': [],
 
        }
 
@@ -59,8 +59,8 @@ class _ChangesetsWithCommitsTestCaseixin
 
        self.imc.add(vcs.nodes.FileNode('docs/index.txt',
 
            content='Documentation\n'))
 
        foobar_tip = self.imc.commit(
 
            message=u'New branch: foobar',
 
            author=u'joe',
 
            message='New branch: foobar',
 
            author='joe',
 
            branch='foobar',
 
        )
 
        assert 'foobar' in self.repo.branches
 
@@ -75,23 +75,23 @@ class _ChangesetsWithCommitsTestCaseixin
 
        self.imc.add(vcs.nodes.FileNode('docs/index.txt',
 
            content='Documentation\n'))
 
        foobar_tip = self.imc.commit(
 
            message=u'New branch: foobar',
 
            author=u'joe',
 
            message='New branch: foobar',
 
            author='joe',
 
            branch='foobar',
 
            parents=[tip],
 
        )
 
        self.imc.change(vcs.nodes.FileNode('docs/index.txt',
 
            content='Documentation\nand more...\n'))
 
        newtip = self.imc.commit(
 
            message=u'At default branch',
 
            author=u'joe',
 
            message='At default branch',
 
            author='joe',
 
            branch=foobar_tip.branch,
 
            parents=[foobar_tip],
 
        )
 

	
 
        newest_tip = self.imc.commit(
 
            message=u'Merged with %s' % foobar_tip.raw_id,
 
            author=u'joe',
 
            message='Merged with %s' % foobar_tip.raw_id,
 
            author='joe',
 
            branch=self.backend_class.DEFAULT_BRANCH_NAME,
 
            parents=[newtip, foobar_tip],
 
        )
 
@@ -104,14 +104,14 @@ class _ChangesetsWithCommitsTestCaseixin
 
        self.imc.add(vcs.nodes.FileNode('docs/index.txt',
 
            content='Documentation\n'))
 
        doc_changeset = self.imc.commit(
 
            message=u'New branch: docs',
 
            author=u'joe',
 
            message='New branch: docs',
 
            author='joe',
 
            branch='docs',
 
        )
 
        self.imc.add(vcs.nodes.FileNode('newfile', content=''))
 
        self.imc.commit(
 
            message=u'Back in default branch',
 
            author=u'joe',
 
            message='Back in default branch',
 
            author='joe',
 
            parents=[tip],
 
        )
 
        default_branch_changesets = self.repo.get_changesets(
 
@@ -145,8 +145,8 @@ class _ChangesetsTestCaseMixin(_BackendT
 
        start_date = datetime.datetime(2010, 1, 1, 20)
 
        for x in range(5):
 
            yield {
 
                'message': u'Commit %d' % x,
 
                'author': u'Joe Doe <joe.doe@example.com>',
 
                'message': 'Commit %d' % x,
 
                'author': 'Joe Doe <joe.doe@example.com>',
 
                'date': start_date + datetime.timedelta(hours=12 * x),
 
                'added': [
 
                    FileNode('file_%d.txt' % x, content='Foobar %d' % x),
 
@@ -247,15 +247,15 @@ class _ChangesetsTestCaseMixin(_BackendT
 

	
 
    def test_author(self):
 
        tip = self.repo.get_changeset()
 
        assert tip.author == u'Joe Doe <joe.doe@example.com>'
 
        assert tip.author == 'Joe Doe <joe.doe@example.com>'
 

	
 
    def test_author_name(self):
 
        tip = self.repo.get_changeset()
 
        assert tip.author_name == u'Joe Doe'
 
        assert tip.author_name == 'Joe Doe'
 

	
 
    def test_author_email(self):
 
        tip = self.repo.get_changeset()
 
        assert tip.author_email == u'joe.doe@example.com'
 
        assert tip.author_email == 'joe.doe@example.com'
 

	
 
    def test_get_changesets_raise_changesetdoesnotexist_for_wrong_start(self):
 
        with pytest.raises(ChangesetDoesNotExistError):
 
@@ -297,8 +297,8 @@ class _ChangesetsChangesTestCaseMixin(_B
 
    def _get_commits(cls):
 
        return [
 
            {
 
                'message': u'Initial',
 
                'author': u'Joe Doe <joe.doe@example.com>',
 
                'message': 'Initial',
 
                'author': 'Joe Doe <joe.doe@example.com>',
 
                'date': datetime.datetime(2010, 1, 1, 20),
 
                'added': [
 
                    FileNode('foo/bar', content='foo'),
 
@@ -308,8 +308,8 @@ class _ChangesetsChangesTestCaseMixin(_B
 
                ],
 
            },
 
            {
 
                'message': u'Massive changes',
 
                'author': u'Joe Doe <joe.doe@example.com>',
 
                'message': 'Massive changes',
 
                'author': 'Joe Doe <joe.doe@example.com>',
 
                'date': datetime.datetime(2010, 1, 1, 22),
 
                'added': [FileNode('fallout', content='War never changes')],
 
                'changed': [
 
@@ -330,8 +330,8 @@ class _ChangesetsChangesTestCaseMixin(_B
 
        ])
 
        assert list(changeset.changed) == []
 
        assert list(changeset.removed) == []
 
        assert u'foo/ba\u0142' in changeset.as_dict()['added']
 
        assert u'foo/ba\u0142' in changeset.__json__(with_file_list=True)['added']
 
        assert 'foo/ba\u0142' in changeset.as_dict()['added']
 
        assert 'foo/ba\u0142' in changeset.__json__(with_file_list=True)['added']
 

	
 
    def test_head_added(self):
 
        changeset = self.repo.get_changeset()
 
@@ -355,7 +355,7 @@ class _ChangesetsChangesTestCaseMixin(_B
 
    def test_get_filemode_non_ascii(self):
 
        changeset = self.repo.get_changeset()
 
        assert 33188 == changeset.get_file_mode('foo/bał')
 
        assert 33188 == changeset.get_file_mode(u'foo/bał')
 
        assert 33188 == changeset.get_file_mode('foo/bał')
 

	
 

	
 
class TestGitChangesetsWithCommits(_ChangesetsWithCommitsTestCaseixin):
kallithea/tests/vcs/test_filenodes_unicode_path.py
Show inline comments
 
@@ -8,7 +8,7 @@ from kallithea.tests.vcs.base import _Ba
 

	
 
class FileNodeUnicodePathTestsMixin(_BackendTestMixin):
 

	
 
    fname = u'ąśðąęłąć.txt'
 
    fname = 'ąśðąęłąć.txt'
 

	
 
    @classmethod
 
    def _get_commits(cls):
kallithea/tests/vcs/test_hg.py
Show inline comments
 
@@ -27,7 +27,7 @@ class TestMercurialRepository(object):
 

	
 
    def test_unicode_path_repo(self):
 
        with pytest.raises(VCSError):
 
            MercurialRepository(u'iShouldFail')
 
            MercurialRepository('iShouldFail')
 

	
 
    def test_repo_clone(self):
 
        self.__check_for_existing_repo()
kallithea/tests/vcs/test_inmemchangesets.py
Show inline comments
 
@@ -36,7 +36,7 @@ class InMemoryChangesetTestMixin(_Backen
 
            for node in self.nodes]
 
        for node in to_add:
 
            self.imc.add(node)
 
        message = u'Added: %s' % ', '.join((node.path for node in self.nodes))
 
        message = 'Added: %s' % ', '.join((node.path for node in self.nodes))
 
        author = str(self.__class__)
 
        changeset = self.imc.commit(message=message, author=author)
 

	
 
@@ -58,7 +58,7 @@ class InMemoryChangesetTestMixin(_Backen
 
        to_add = [FileNode(node.path, content=node.content)
 
            for node in self.nodes]
 
        self.imc.add(*to_add)
 
        message = u'Added: %s' % ', '.join((node.path for node in self.nodes))
 
        message = 'Added: %s' % ', '.join((node.path for node in self.nodes))
 
        author = str(self.__class__)
 
        changeset = self.imc.commit(message=message, author=author)
 

	
 
@@ -78,7 +78,7 @@ class InMemoryChangesetTestMixin(_Backen
 
    def test_add_actually_adds_all_nodes_at_second_commit_too(self):
 
        self.imc.add(FileNode('foo/bar/image.png', content='\0'))
 
        self.imc.add(FileNode('foo/README.txt', content='readme!'))
 
        changeset = self.imc.commit(u'Initial', u'joe.doe@example.com')
 
        changeset = self.imc.commit('Initial', 'joe.doe@example.com')
 
        assert isinstance(changeset.get_node('foo'), DirNode)
 
        assert isinstance(changeset.get_node('foo/bar'), DirNode)
 
        assert changeset.get_node('foo/bar/image.png').content == b'\0'
 
@@ -93,7 +93,7 @@ class InMemoryChangesetTestMixin(_Backen
 
            FileNode('foobar/barbaz', content='foo'),
 
        ]
 
        self.imc.add(*to_add)
 
        changeset = self.imc.commit(u'Another', u'joe.doe@example.com')
 
        changeset = self.imc.commit('Another', 'joe.doe@example.com')
 
        changeset.get_node('foo/bar/foobaz/bar').content == b'foo'
 
        changeset.get_node('foo/bar/another/bar').content == b'foo'
 
        changeset.get_node('foo/baz.txt').content == b'foo'
 
@@ -104,11 +104,11 @@ class InMemoryChangesetTestMixin(_Backen
 
        rev_count = len(self.repo.revisions)
 
        to_add = [
 
            FileNode('żółwik/zwierzątko', content='ćććć'),
 
            FileNode(u'żółwik/zwierzątko_uni', content=u'ćććć'),
 
            FileNode('żółwik/zwierzątko_uni', content='ćććć'),
 
        ]
 
        for node in to_add:
 
            self.imc.add(node)
 
        message = u'Added: %s' % ', '.join((node.path for node in self.nodes))
 
        message = 'Added: %s' % ', '.join((node.path for node in self.nodes))
 
        author = str(self.__class__)
 
        changeset = self.imc.commit(message=message, author=author)
 

	
 
@@ -134,7 +134,7 @@ class InMemoryChangesetTestMixin(_Backen
 
    def test_check_integrity_raise_already_exist(self):
 
        node = FileNode('foobar', content='baz')
 
        self.imc.add(node)
 
        self.imc.commit(message=u'Added foobar', author=str(self))
 
        self.imc.commit(message='Added foobar', author=str(self))
 
        self.imc.add(node)
 
        with pytest.raises(NodeAlreadyExistsError):
 
            self.imc.commit(message='new message',
 
@@ -143,12 +143,12 @@ class InMemoryChangesetTestMixin(_Backen
 
    def test_change(self):
 
        self.imc.add(FileNode('foo/bar/baz', content='foo'))
 
        self.imc.add(FileNode('foo/fbar', content='foobar'))
 
        tip = self.imc.commit(u'Initial', u'joe.doe@example.com')
 
        tip = self.imc.commit('Initial', 'joe.doe@example.com')
 

	
 
        # Change node's content
 
        node = FileNode('foo/bar/baz', content='My **changed** content')
 
        self.imc.change(node)
 
        self.imc.commit(u'Changed %s' % node.path, u'joe.doe@example.com')
 
        self.imc.commit('Changed %s' % node.path, 'joe.doe@example.com')
 

	
 
        newtip = self.repo.get_changeset()
 
        assert tip != newtip
 
@@ -158,21 +158,21 @@ class InMemoryChangesetTestMixin(_Backen
 
    def test_change_non_ascii(self):
 
        to_add = [
 
            FileNode('żółwik/zwierzątko', content='ćććć'),
 
            FileNode(u'żółwik/zwierzątko_uni', content=u'ćććć'),
 
            FileNode('żółwik/zwierzątko_uni', content='ćććć'),
 
        ]
 
        for node in to_add:
 
            self.imc.add(node)
 

	
 
        tip = self.imc.commit(u'Initial', u'joe.doe@example.com')
 
        tip = self.imc.commit('Initial', 'joe.doe@example.com')
 

	
 
        # Change node's content
 
        node = FileNode('żółwik/zwierzątko', content='My **changed** content')
 
        self.imc.change(node)
 
        self.imc.commit(u'Changed %s' % node.path, u'joe.doe@example.com')
 
        self.imc.commit('Changed %s' % node.path, 'joe.doe@example.com')
 

	
 
        node = FileNode(u'żółwik/zwierzątko_uni', content=u'My **changed** content')
 
        node = FileNode('żółwik/zwierzątko_uni', content='My **changed** content')
 
        self.imc.change(node)
 
        self.imc.commit(u'Changed %s' % node.path, u'joe.doe@example.com')
 
        self.imc.commit('Changed %s' % node.path, 'joe.doe@example.com')
 

	
 
        newtip = self.repo.get_changeset()
 
        assert tip != newtip
 
@@ -189,7 +189,7 @@ class InMemoryChangesetTestMixin(_Backen
 
    def test_check_integrity_change_raise_node_does_not_exist(self):
 
        node = FileNode('foobar', content='baz')
 
        self.imc.add(node)
 
        self.imc.commit(message=u'Added foobar', author=str(self))
 
        self.imc.commit(message='Added foobar', author=str(self))
 
        node = FileNode('not-foobar', content='')
 
        self.imc.change(node)
 
        with pytest.raises(NodeDoesNotExistError):
 
@@ -198,7 +198,7 @@ class InMemoryChangesetTestMixin(_Backen
 
    def test_change_raise_node_already_changed(self):
 
        node = FileNode('foobar', content='baz')
 
        self.imc.add(node)
 
        self.imc.commit(message=u'Added foobar', author=str(self))
 
        self.imc.commit(message='Added foobar', author=str(self))
 
        node = FileNode('foobar', content='more baz')
 
        self.imc.change(node)
 
        with pytest.raises(NodeAlreadyChangedError):
 
@@ -211,14 +211,14 @@ class InMemoryChangesetTestMixin(_Backen
 
        self.imc.change(node)
 
        with pytest.raises(NodeNotChangedError):
 
            self.imc.commit(
 
                message=u'Trying to mark node as changed without touching it',
 
                message='Trying to mark node as changed without touching it',
 
                author=str(self),
 
            )
 

	
 
    def test_change_raise_node_already_removed(self):
 
        node = FileNode('foobar', content='baz')
 
        self.imc.add(node)
 
        self.imc.commit(message=u'Added foobar', author=str(self))
 
        self.imc.commit(message='Added foobar', author=str(self))
 
        self.imc.remove(FileNode('foobar'))
 
        with pytest.raises(NodeAlreadyRemovedError):
 
            self.imc.change(node)
 
@@ -230,7 +230,7 @@ class InMemoryChangesetTestMixin(_Backen
 
        node = self.nodes[0]
 
        assert node.content == tip.get_node(node.path).content
 
        self.imc.remove(node)
 
        self.imc.commit(message=u'Removed %s' % node.path, author=str(self))
 
        self.imc.commit(message='Removed %s' % node.path, author=str(self))
 

	
 
        newtip = self.repo.get_changeset()
 
        assert tip != newtip
 
@@ -241,10 +241,10 @@ class InMemoryChangesetTestMixin(_Backen
 
    def test_remove_last_file_from_directory(self):
 
        node = FileNode('omg/qwe/foo/bar', content='foobar')
 
        self.imc.add(node)
 
        self.imc.commit(u'added', u'joe doe')
 
        self.imc.commit('added', 'joe doe')
 

	
 
        self.imc.remove(node)
 
        tip = self.imc.commit(u'removed', u'joe doe')
 
        tip = self.imc.commit('removed', 'joe doe')
 
        with pytest.raises(NodeDoesNotExistError):
 
            tip.get_node('omg/qwe/foo/bar')
 

	
 
@@ -263,7 +263,7 @@ class InMemoryChangesetTestMixin(_Backen
 
        self.imc.remove(node)
 
        with pytest.raises(NodeDoesNotExistError):
 
            self.imc.commit(
 
                message=u'Trying to remove not existing node',
 
                message='Trying to remove not existing node',
 
                author=str(self),
 
            )
 

	
 
@@ -302,7 +302,7 @@ class InMemoryChangesetTestMixin(_Backen
 
            content = 'foobar\n' * x
 
            node = FileNode(fname, content=content)
 
            self.imc.add(node)
 
            commit = self.imc.commit(u"Commit no. %s" % (x + 1), author=u'vcs')
 
            commit = self.imc.commit("Commit no. %s" % (x + 1), author='vcs')
 
            assert last != commit
 
            last = commit
 

	
 
@@ -316,8 +316,8 @@ class InMemoryChangesetTestMixin(_Backen
 
        node = FileNode('foobar.txt', content='Foobared!')
 
        self.imc.add(node)
 
        date = datetime.datetime(1985, 1, 30, 1, 45)
 
        commit = self.imc.commit(u"Committed at time when I was born ;-)",
 
            author=u'lb <lb@example.com>', date=date)
 
        commit = self.imc.commit("Committed at time when I was born ;-)",
 
            author='lb <lb@example.com>', date=date)
 

	
 
        assert commit.date == date
 

	
kallithea/tests/vcs/test_repository.py
Show inline comments
 
@@ -85,7 +85,7 @@ class RepositoryGetDiffTest(_BackendTest
 
                'removed': [FileNode('foobar')],
 
            },
 
            {
 
                'message': u'Commit that contains glob pattern in filename',
 
                'message': 'Commit that contains glob pattern in filename',
 
                'author': 'Jane Doe <jane.doe@example.com>',
 
                'date': datetime.datetime(2010, 1, 1, 22),
 
                'added': [
kallithea/tests/vcs/test_utils.py
Show inline comments
 
@@ -191,8 +191,8 @@ class TestAuthorExtractors(object):
 
                   ('justname', '')),
 
                  ('Mr Double Name withemail@example.com ',
 
                   ('Mr Double Name', 'withemail@example.com')),
 
                  (u'John Doe <джондо à éẋàṁṗłê.ç°ḿ>',
 
                   (u'John Doe <\u0434\u0436\u043e\u043d\u0434\u043e \xe0 \xe9\u1e8b\xe0\u1e41\u1e57\u0142\xea.\xe7\xb0\u1e3f>', '')),
 
                  ('John Doe <джондо à éẋàṁṗłê.ç°ḿ>',
 
                   ('John Doe <\u0434\u0436\u043e\u043d\u0434\u043e \xe0 \xe9\u1e8b\xe0\u1e41\u1e57\u0142\xea.\xe7\xb0\u1e3f>', '')),
 
                  ]
 

	
 
    def test_author_email(self):
kallithea/tests/vcs/test_workdirs.py
Show inline comments
 
@@ -12,8 +12,8 @@ class WorkdirTestCaseMixin(_BackendTestM
 
    def _get_commits(cls):
 
        commits = [
 
            {
 
                'message': u'Initial commit',
 
                'author': u'Joe Doe <joe.doe@example.com>',
 
                'message': 'Initial commit',
 
                'author': 'Joe Doe <joe.doe@example.com>',
 
                'date': datetime.datetime(2010, 1, 1, 20),
 
                'added': [
 
                    FileNode('foobar', content='Foobar'),
 
@@ -22,8 +22,8 @@ class WorkdirTestCaseMixin(_BackendTestM
 
                ],
 
            },
 
            {
 
                'message': u'Changes...',
 
                'author': u'Jane Doe <jane.doe@example.com>',
 
                'message': 'Changes...',
 
                'author': 'Jane Doe <jane.doe@example.com>',
 
                'date': datetime.datetime(2010, 1, 1, 21),
 
                'added': [
 
                    FileNode('some/new.txt', content='news...'),
 
@@ -43,8 +43,8 @@ class WorkdirTestCaseMixin(_BackendTestM
 
        self.imc.add(FileNode('docs/index.txt',
 
            content='Documentation\n'))
 
        self.imc.commit(
 
            message=u'New branch: foobar',
 
            author=u'joe',
 
            message='New branch: foobar',
 
            author='joe',
 
            branch='foobar',
 
        )
 
        assert self.repo.workdir.get_branch() == self.default_branch
 
@@ -54,8 +54,8 @@ class WorkdirTestCaseMixin(_BackendTestM
 
        self.imc.add(FileNode('docs/index.txt',
 
            content='Documentation\n'))
 
        head = self.imc.commit(
 
            message=u'New branch: foobar',
 
            author=u'joe',
 
            message='New branch: foobar',
 
            author='joe',
 
            branch='foobar',
 
        )
 
        assert self.repo.workdir.get_branch() == self.default_branch
 
@@ -73,7 +73,7 @@ class WorkdirTestCaseMixin(_BackendTestM
 
            self.repo.workdir.checkout_branch(branch='foobranch')
 
        # create new branch 'foobranch'.
 
        self.imc.add(FileNode('file1', content='blah'))
 
        self.imc.commit(message=u'asd', author=u'john', branch='foobranch')
 
        self.imc.commit(message='asd', author='john', branch='foobranch')
 
        # go back to the default branch
 
        self.repo.workdir.checkout_branch()
 
        assert self.repo.workdir.get_branch() == self.backend_class.DEFAULT_BRANCH_NAME
scripts/update-copyrights.py
Show inline comments
 
@@ -55,7 +55,7 @@ def sortkey(x):
 
    return (x[0] and -int(x[0][-1]),
 
            x[0] and int(x[0][0]),
 
            -len(x[0]),
 
            x[1].decode('utf-8').lower().replace(u'\xe9', u'e').replace(u'\u0142', u'l')
 
            x[1].decode('utf-8').lower().replace('\xe9', 'e').replace('\u0142', 'l')
 
        )
 

	
 

	
0 comments (0 inline, 0 general)