Repository: allura
Updated Branches:
refs/heads/master 4bfdd443f -> 32ebab900
Fix various pep8 issues & formatting improvements
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/32ebab90
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/32ebab90
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/32ebab90
Branch: refs/heads/master
Commit: 32ebab900c40bb2ab46e25386d9159f84fd499d4
Parents: 4bfdd44
Author: Dave Brondsema <dave@brondsema.net>
Authored: Wed Sep 7 16:06:32 2016 -0400
Committer: Dave Brondsema <dave@brondsema.net>
Committed: Fri Sep 9 14:10:57 2016 -0400
----------------------------------------------------------------------
Allura/allura/app.py | 12 ++-
Allura/allura/config/middleware.py | 6 +-
Allura/allura/lib/app_globals.py | 3 +-
Allura/allura/lib/solr.py | 37 ++++----
Allura/allura/lib/utils.py | 19 ++---
Allura/allura/model/artifact.py | 24 +++---
Allura/allura/model/auth.py | 12 +--
Allura/allura/tests/functional/test_admin.py | 89 +++++++-------------
Allura/docs/conf.py | 60 ++++++-------
.../forgeblog/tests/functional/test_feeds.py | 19 +++--
ForgeImporters/docs/conf.py | 69 ++++++++-------
.../forgesvn/tests/model/test_repository.py | 28 +++---
ForgeTracker/forgetracker/tracker_main.py | 12 +--
.../forgewiki/tests/functional/test_root.py | 3 +-
14 files changed, 179 insertions(+), 214 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/allura/app.py
----------------------------------------------------------------------
diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index db3cb8d..f155514 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -204,6 +204,7 @@ class SitemapEntry(object):
extra_html_attrs=self.extra_html_attrs,
)
+
class Application(object):
"""
@@ -543,7 +544,7 @@ class Application(object):
project_id = project._id
# De-index all the artifacts belonging to this tool in one fell swoop
index_tasks.solr_del_tool.post(project_id, self.config.options['mount_point'])
-
+
for d in model.Discussion.query.find({
'project_id': project_id,
'app_config_id': self.config._id}):
@@ -731,7 +732,7 @@ class Application(object):
Set exportable to True for applications implementing this.
"""
- raise NotImplementedError, 'bulk_export'
+ raise NotImplementedError('bulk_export')
def doap(self, parent):
"""App's representation for DOAP API.
@@ -977,10 +978,13 @@ class DefaultAdminController(BaseController, AdminControllerMixin):
group_ids = [group_ids]
for acl in old_acl:
- if (acl['permission'] == perm) and (str(acl['role_id']) not in group_ids) and acl['access'] != model.ACE.DENY:
+ if (acl['permission'] == perm
+ and str(acl['role_id']) not in group_ids
+ and acl['access'] != model.ACE.DENY):
del_group_ids.append(str(acl['role_id']))
- get_role = lambda _id: model.ProjectRole.query.get(_id=ObjectId(_id))
+ def get_role(_id):
+ return model.ProjectRole.query.get(_id=ObjectId(_id))
groups = map(get_role, group_ids)
new_groups = map(get_role, new_group_ids)
del_groups = map(get_role, del_group_ids)
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index 7f2fb4c..a7356e2 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -20,7 +20,7 @@
"""WSGI middleware initialization for the allura application."""
import mimetypes
-import pylons.middleware
+import pylons.middleware # needed within tg.error :(
import tg
import tg.error
import pkg_resources
@@ -94,9 +94,7 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
"""
# Run all the initialization code here
- mimetypes.init(
- [pkg_resources.resource_filename('allura', 'etc/mime.types')]
- + mimetypes.knownfiles)
+ mimetypes.init([pkg_resources.resource_filename('allura', 'etc/mime.types')] + mimetypes.knownfiles)
# Configure MongoDB
ming.configure(**app_conf)
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 2e0307d..1921412 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -20,7 +20,6 @@
"""The application's Globals object"""
-__all__ = ['Globals']
import logging
import cgi
import hashlib
@@ -65,6 +64,8 @@ from allura.lib.security import Credentials
from allura.lib.solr import MockSOLR, make_solr_from_config
from allura.model.session import artifact_orm_session
+__all__ = ['Globals']
+
log = logging.getLogger(__name__)
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/allura/lib/solr.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/solr.py b/Allura/allura/lib/solr.py
index e8d9f7b..e7ed325 100644
--- a/Allura/allura/lib/solr.py
+++ b/Allura/allura/lib/solr.py
@@ -22,23 +22,23 @@ from paste.deploy.converters import asbool
import pysolr
escape_rules = {'+': r'\+',
- '-': r'\-',
- '&': r'\&',
- '|': r'\|',
- '!': r'\!',
- '(': r'\(',
- ')': r'\)',
- '{': r'\{',
- '}': r'\}',
- '[': r'\[',
- ']': r'\]',
- '^': r'\^',
- '~': r'\~',
- '*': r'\*',
- '?': r'\?',
- ':': r'\:',
- '"': r'\"',
- ';': r'\;'}
+ '-': r'\-',
+ '&': r'\&',
+ '|': r'\|',
+ '!': r'\!',
+ '(': r'\(',
+ ')': r'\)',
+ '{': r'\{',
+ '}': r'\}',
+ '[': r'\[',
+ ']': r'\]',
+ '^': r'\^',
+ '~': r'\~',
+ '*': r'\*',
+ '?': r'\?',
+ ':': r'\:',
+ '"': r'\"',
+ ';': r'\;'}
def escape_solr_arg(term):
@@ -143,7 +143,8 @@ class MockSOLR(object):
pass
def search(self, q, fq=None, **kw):
- if q is None: q = '' # shlex will hang on None
+ if q is None:
+ q = '' # shlex will hang on None
if isinstance(q, unicode):
q = q.encode('latin-1')
# Parse query
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 6d05764..4ee7ca7 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -36,14 +36,10 @@ import collections
import tg
import pylons
import json
-import webob.multidict
from formencode import Invalid
from tg.decorators import before_validate
-from pylons import response
-from pylons import tmpl_context as c
from pylons.controllers.util import etag_cache
from paste.deploy.converters import asbool, asint
-from paste.httpheaders import CACHE_CONTROL, EXPIRES
from webhelpers.html import literal
from webob import exc
from pygments.formatters import HtmlFormatter
@@ -111,7 +107,7 @@ class lazy_logger(object):
def __getattr__(self, name):
if name.startswith('_'):
- raise AttributeError, name
+ raise AttributeError(name)
return getattr(self._logger, name)
@@ -342,7 +338,7 @@ class AntiSpam(object):
timestamp = self.timestamp
try:
client_ip = ip_address(self.request)
- except (TypeError, AttributeError), err:
+ except (TypeError, AttributeError):
client_ip = '127.0.0.1'
plain = '%d:%s:%s' % (
timestamp, client_ip, pylons.config.get('spinner_secret', 'abcdef'))
@@ -362,17 +358,17 @@ class AntiSpam(object):
if now is None:
now = time.time()
if obj.timestamp > now + 5:
- raise ValueError, 'Post from the future'
+ raise ValueError('Post from the future')
if now - obj.timestamp > 24 * 60 * 60:
- raise ValueError, 'Post from the distant past'
+ raise ValueError('Post from the distant past')
if obj.spinner != obj.make_spinner(obj.timestamp):
- raise ValueError, 'Bad spinner value'
+ raise ValueError('Bad spinner value')
for k in new_params.keys():
new_params[obj.dec(k)] = new_params.pop(k)
for fldno in range(obj.num_honey):
value = new_params.pop('honey%s' % fldno)
if value:
- raise ValueError, 'Value in honeypot field: %s' % value
+ raise ValueError('Value in honeypot field: %s' % value)
return new_params
@classmethod
@@ -519,7 +515,7 @@ def take_while_true(source):
def serve_file(fp, filename, content_type, last_modified=None,
- cache_expires=None, size=None, embed=True, etag=None):
+ cache_expires=None, size=None, embed=True, etag=None):
'''Sets the response headers and serves as a wsgi iter'''
if not etag and filename and last_modified:
etag = u'{0}?{1}'.format(filename, last_modified).encode('utf-8')
@@ -673,7 +669,6 @@ def unique_attachments(attachments):
return result
-
def is_ajax(request):
if request.headers.get('X-Requested-With', None) == 'XMLHttpRequest':
return True
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index a98394e..ff4bd76 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -131,7 +131,7 @@ class Artifact(MappedClass, SearchIndexable):
@classmethod
def attachment_class(cls):
- raise NotImplementedError, 'attachment_class'
+ raise NotImplementedError('attachment_class')
@LazyProperty
def ref(self):
@@ -185,7 +185,7 @@ class Artifact(MappedClass, SearchIndexable):
app = ac.project.app_instance(ac) if ac else None
if app:
artifact.set_context(app.repo)
- if artifact not in related_artifacts and (getattr(artifact, 'deleted', False) == False):
+ if artifact not in related_artifacts and (getattr(artifact, 'deleted', False) is False):
related_artifacts.append(artifact)
return sorted(related_artifacts, key=lambda a: a.url())
@@ -317,7 +317,7 @@ class Artifact(MappedClass, SearchIndexable):
Subclasses must implement this.
"""
- raise NotImplementedError, 'url' # pragma no cover
+ raise NotImplementedError('url') # pragma no cover
def shorthand_id(self):
"""How to refer to this artifact within the app instance context.
@@ -438,7 +438,9 @@ class Artifact(MappedClass, SearchIndexable):
"""
pkg = cls.__module__.split('.', 1)[0]
opt = u'{}.rate_limits'.format(pkg)
- count_in_app = lambda: cls.query.find(dict(app_config_id=app_config._id)).count()
+
+ def count_in_app():
+ return cls.query.find(dict(app_config_id=app_config._id)).count()
provider = plugin.ProjectRegistrationProvider.get()
start = provider.registration_date(app_config.project)
@@ -452,8 +454,10 @@ class Artifact(MappedClass, SearchIndexable):
class Snapshot(Artifact):
-
- """A snapshot of an :class:`Artifact <allura.model.artifact.Artifact>`, used in :class:`VersionedArtifact <allura.model.artifact.VersionedArtifact>`"""
+ """
+ A snapshot of an :class:`Artifact <allura.model.artifact.Artifact>`,
+ used in :class:`VersionedArtifact <allura.model.artifact.VersionedArtifact>`
+ """
class __mongometa__:
session = artifact_orm_session
name = 'artifact_snapshot'
@@ -493,7 +497,7 @@ class Snapshot(Artifact):
return result
def original(self):
- raise NotImplemented, 'original' # pragma no cover
+ raise NotImplemented('original') # pragma no cover
def shorthand_id(self):
return '%s#%s' % (self.original().shorthand_id(), self.version)
@@ -589,7 +593,7 @@ class VersionedArtifact(Artifact):
self.__class__.__name__),
version=n)
if ss is None:
- raise IndexError, n
+ raise IndexError(n)
return ss
def revert(self, version):
@@ -880,7 +884,7 @@ class Feed(MappedClass):
@classmethod
def post(cls, artifact, title=None, description=None, author=None,
- author_link=None, author_name=None, pubdate=None, link=None, **kw):
+ author_link=None, author_name=None, pubdate=None, link=None, **kw):
"""
Create a Feed item. Returns the item.
But if anon doesn't have read access, create does not happen and None is
@@ -921,7 +925,7 @@ class Feed(MappedClass):
@classmethod
def update(cls, artifact, title=None, description=None, author=None,
- author_link=None, author_name=None, pubdate=None, link=None, delete=False, **kw):
+ author_link=None, author_name=None, pubdate=None, link=None, delete=False, **kw):
"""
For a blog post which is present already but to be updated.
"""
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index 32b419a..94bbcf0 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -427,9 +427,9 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
"""
if self.can_send_user_message():
return 0
- return self.sent_user_message_times[0] + \
- timedelta(seconds=g.user_message_time_interval) - \
- datetime.utcnow()
+ return (self.sent_user_message_times[0] +
+ timedelta(seconds=g.user_message_time_interval) -
+ datetime.utcnow())
def send_user_message(self, user, subject, message, cc):
"""Send a user message (email) to ``user``.
@@ -618,7 +618,8 @@ class User(MappedClass, ActivityNode, ActivityObject, SearchIndexable):
def url(self):
'''
Return the URL (relative to root domain) for this user's user-project.
- This includes any special handling via the :class:`~allura.lib.plugin.AuthenticationProvider` to determine the proper user-project name
+ This includes any special handling via the :class:`~allura.lib.plugin.AuthenticationProvider` to determine
+ the proper user-project name
'''
return '/%s/' % plugin.AuthenticationProvider.get(request).user_project_shortname(self)
@@ -829,7 +830,8 @@ class ProjectRole(MappedClass):
:var user_id: used if this role is for a single user
:var project_id:
:var name:
- :var roles: a list of other :class:`ProjectRole` ``ObjectId`` values. These roles are delegated through the current role.
+ :var roles: a list of other :class:`ProjectRole` ``ObjectId`` values. These roles are delegated through the
+ current role.
"""
class __mongometa__:
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/allura/tests/functional/test_admin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index a4edc44..f5f49e9 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -15,12 +15,10 @@
# specific language governing permissions and limitations
# under the License.
-import re
import os
import allura
import pkg_resources
import StringIO
-from contextlib import contextmanager
import logging
import tg
@@ -469,10 +467,8 @@ class TestProjectAdmin(TestController):
'new.mount_label': 'sub-del-undel'})
r = self.app.get('/p/test/admin/overview')
assert 'This project has been deleted and is not visible to non-admin users' not in r
- assert r.html.find(
- 'input', {'name': 'removal', 'value': ''}).has_key('checked')
- assert not r.html.find(
- 'input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
+ assert r.html.find('input', {'name': 'removal', 'value': ''}).has_key('checked')
+ assert not r.html.find('input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
with audits('delete project'):
self.app.post('/admin/update', params=dict(
name='Test Project',
@@ -482,10 +478,8 @@ class TestProjectAdmin(TestController):
delete='on'))
r = self.app.get('/p/test/admin/overview')
assert 'This project has been deleted and is not visible to non-admin users' in r
- assert not r.html.find(
- 'input', {'name': 'removal', 'value': ''}).has_key('checked')
- assert r.html.find(
- 'input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
+ assert not r.html.find('input', {'name': 'removal', 'value': ''}).has_key('checked')
+ assert r.html.find('input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
# make sure subprojects get deleted too
r = self.app.get('/p/test/sub-del-undel/admin/overview')
assert 'This project has been deleted and is not visible to non-admin users' in r
@@ -498,10 +492,8 @@ class TestProjectAdmin(TestController):
undelete='on'))
r = self.app.get('/p/test/admin/overview')
assert 'This project has been deleted and is not visible to non-admin users' not in r
- assert r.html.find(
- 'input', {'name': 'removal', 'value': ''}).has_key('checked')
- assert not r.html.find(
- 'input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
+ assert r.html.find('input', {'name': 'removal', 'value': ''}).has_key('checked')
+ assert not r.html.find('input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
def test_project_delete_not_allowed(self):
# turn off project delete option
@@ -519,12 +511,10 @@ class TestProjectAdmin(TestController):
'new.mount_label': 'sub-no-del'})
# root project doesn't have delete option
r = self.app.get('/p/test/admin/overview')
- assert not r.html.find(
- 'input', {'name': 'removal', 'value': 'deleted'})
+ assert not r.html.find('input', {'name': 'removal', 'value': 'deleted'})
# subprojects can still be deleted
r = self.app.get('/p/test/sub-no-del/admin/overview')
- assert r.html.find(
- 'input', {'name': 'removal', 'value': 'deleted'})
+ assert r.html.find('input', {'name': 'removal', 'value': 'deleted'})
# attempt to delete root project won't do anything
self.app.post('/admin/update', params=dict(
name='Test Project',
@@ -546,8 +536,7 @@ class TestProjectAdmin(TestController):
delete='on'))
r = self.app.get('/p/test/sub-no-del/admin/overview')
assert 'This project has been deleted and is not visible to non-admin users' in r
- assert r.html.find(
- 'input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
+ assert r.html.find('input', {'name': 'removal', 'value': 'deleted'}).has_key('checked')
finally:
if old_allow_project_delete == ():
del config['allow_project_delete']
@@ -666,16 +655,14 @@ class TestProjectAdmin(TestController):
def test_project_groups(self):
r = self.app.get('/admin/groups/')
- dev_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+ dev_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[2]
developer_id = dev_holder['data-group']
with audits('add user test-user to Developer'):
r = self.app.post('/admin/groups/add_user', params={
'role_id': developer_id,
'username': 'test-user'})
r = self.app.get('/admin/groups/')
- dev_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+ dev_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[2]
users = dev_holder.find('ul', {'class': 'users'}).findAll(
'li', {'class': 'deleter'})
assert 'test-user' in users[0]['data-user']
@@ -793,9 +780,7 @@ class TestProjectAdmin(TestController):
def test_project_multi_groups(self):
r = self.app.get('/admin/groups/')
- user_id = M.User.by_username('test-admin')._id
- admin_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
+ admin_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[1]
admin_id = admin_holder['data-group']
with audits('add user test-user to Admin'):
r = self.app.post('/admin/groups/add_user', params={
@@ -805,8 +790,7 @@ class TestProjectAdmin(TestController):
r = self.app.post('/admin/groups/add_user', params={
'role_id': admin_id,
'username': 'test-user'})
- assert r.json[
- 'error'] == 'Test User (test-user) is already in the group Admin.'
+ assert r.json['error'] == 'Test User (test-user) is already in the group Admin.'
r = self.app.get('/admin/groups/')
assert 'test-user' in str(r), r.showbrowser()
with audits('remove user test-user from Admin'):
@@ -827,13 +811,11 @@ class TestProjectAdmin(TestController):
r = self.app.post('/admin/groups/create',
params={'name': 'RoleNew1'})
r = self.app.get('/admin/groups/')
- role_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[4]
+ role_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[4]
assert 'RoleNew1' in str(role_holder)
role_id = role_holder['data-group']
r = self.app.get('/admin/groups/' + role_id + '/', validate_chunk=True)
- r = self.app.post('/admin/groups/'
- + str(role_id) + '/update', params={'_id': role_id, 'name': 'Developer'})
+ r = self.app.post('/admin/groups/' + str(role_id) + '/update', params={'_id': role_id, 'name': 'Developer'})
assert 'error' in self.webflash(r)
assert 'already exists' in self.webflash(r)
@@ -844,8 +826,7 @@ class TestProjectAdmin(TestController):
assert 'rleNew2' in r
# add test-user to role
- role_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[4]
+ role_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[4]
rleNew2_id = role_holder['data-group']
with audits('add user test-user to rleNew2'):
r = self.app.post('/admin/groups/add_user', params={
@@ -869,10 +850,8 @@ class TestProjectAdmin(TestController):
def test_change_perms(self):
r = self.app.get('/admin/groups/')
- dev_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
- mem_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
+ dev_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+ mem_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[3]
mem_id = mem_holder['data-group']
# neither group has update permission
assert dev_holder.findAll('ul')[1].findAll('li')[2]['class'] == "no"
@@ -883,10 +862,8 @@ class TestProjectAdmin(TestController):
'permission': 'create',
'allow': 'true'})
r = self.app.get('/admin/groups/')
- dev_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
- mem_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
+ dev_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+ mem_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[3]
# Member now has update permission
assert mem_holder.findAll('ul')[1].findAll('li')[2]['class'] == "yes"
# Developer has inherited update permission from Member
@@ -898,24 +875,19 @@ class TestProjectAdmin(TestController):
'permission': 'create',
'allow': 'false'})
r = self.app.get('/admin/groups/')
- dev_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[2]
- mem_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
+ dev_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[2]
+ mem_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[3]
# neither group has update permission
assert dev_holder.findAll('ul')[1].findAll('li')[2]['class'] == "no"
assert mem_holder.findAll('ul')[1].findAll('li')[2]['class'] == "no"
def test_permission_inherit(self):
r = self.app.get('/admin/groups/')
- admin_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
+ admin_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[1]
admin_id = admin_holder['data-group']
- mem_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[3]
+ mem_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[3]
mem_id = mem_holder['data-group']
- anon_holder = r.html.find(
- 'table', {'id': 'usergroup_admin'}).findAll('tr')[5]
+ anon_holder = r.html.find('table', {'id': 'usergroup_admin'}).findAll('tr')[5]
anon_id = anon_holder['data-group']
# first remove create from Admin so we can see it inherit
r = self.app.post('/admin/groups/change_perm', params={
@@ -1042,7 +1014,6 @@ class TestExport(TestController):
r = self.app.get('/admin/')
assert_in('Export', r)
-
@mock.patch('allura.model.session.project_doc_session')
def test_export_page_contains_exportable_tools(self, session):
session.return_value = {'result': [{"total_size": 10000}]}
@@ -1139,8 +1110,8 @@ class TestRestExport(TestRestApiBase):
def test_export_no_exportable_tools(self, bulk_export, exportable_tools, MonQTask):
MonQTask.query.get.return_value = None
exportable_tools.return_value = []
- r = self.api_post('/rest/p/test/admin/export',
- tools='tickets, discussion', status=400)
+ self.api_post('/rest/p/test/admin/export',
+ tools='tickets, discussion', status=400)
assert_equals(bulk_export.post.call_count, 0)
@mock.patch('allura.model.project.MonQTask')
@@ -1152,7 +1123,7 @@ class TestRestExport(TestRestApiBase):
mock.Mock(options=mock.Mock(mount_point='tickets')),
mock.Mock(options=mock.Mock(mount_point='discussion')),
]
- r = self.api_post('/rest/p/test/admin/export', status=400)
+ self.api_post('/rest/p/test/admin/export', status=400)
assert_equals(bulk_export.post.call_count, 0)
@mock.patch('allura.model.project.MonQTask')
@@ -1164,8 +1135,8 @@ class TestRestExport(TestRestApiBase):
mock.Mock(options=mock.Mock(mount_point='tickets')),
mock.Mock(options=mock.Mock(mount_point='discussion')),
]
- r = self.api_post('/rest/p/test/admin/export',
- tools='tickets, discussion', status=503)
+ self.api_post('/rest/p/test/admin/export',
+ tools='tickets, discussion', status=503)
assert_equals(bulk_export.post.call_count, 0)
@mock.patch('allura.model.project.MonQTask')
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/Allura/docs/conf.py
----------------------------------------------------------------------
diff --git a/Allura/docs/conf.py b/Allura/docs/conf.py
index 361397a..37db57e 100644
--- a/Allura/docs/conf.py
+++ b/Allura/docs/conf.py
@@ -51,7 +51,7 @@ templates_path = ['_templates']
source_suffix = '.rst'
# The encoding of source files.
-#source_encoding = 'utf-8'
+# source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
@@ -65,40 +65,40 @@ copyright = '2012-2016 The Apache Software Foundation'
# built documents.
#
# The short X.Y version.
-#version = '0.1'
+# version = '0.1'
# The full version, including alpha/beta/rc tags.
-#release = '0.1'
+# release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
-#language = None
+# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
-#today = ''
+# today = ''
# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
+# today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
-#unused_docs = []
+# unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
+# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
+# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
-#add_module_names = True
+# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
-#show_authors = False
+# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
@@ -107,7 +107,7 @@ pygments_style = 'sphinx'
unused_docs = 'getting_started/scm_host_ssh.rst'
# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
+# modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------
@@ -116,6 +116,7 @@ on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if not on_rtd: # only import and set the theme if we're building docs locally
import sphinx_rtd_theme
+
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
@@ -129,7 +130,7 @@ if not on_rtd: # only import and set the theme if we're building docs locally
# }
# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
+# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
@@ -140,12 +141,12 @@ html_short_title = 'Documentation'
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
-#html_logo = None
+# html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
-#html_favicon = None
+# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
@@ -154,18 +155,18 @@ html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
-#html_use_smartypants = True
+# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
+# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
-#html_additional_pages = {}
+# html_additional_pages = {}
# If false, no module index is generated.
html_use_modindex = False
@@ -174,7 +175,7 @@ html_use_modindex = False
html_use_index = False
# If true, the index is split into individual pages for each letter.
-#html_split_index = False
+# html_split_index = False
# If true, links to the reST sources are added to the pages.
html_show_sourcelink = False
@@ -182,22 +183,21 @@ html_show_sourcelink = False
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
+# html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = ''
+# html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'alluradoc'
-
# -- Options for LaTeX output --------------------------------------------
# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
+# latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
+# latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
@@ -208,20 +208,20 @@ latex_documents = [
# The name of an image file (relative to this directory) to place at the top of
# the title page.
-#latex_logo = None
+# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
-#latex_use_parts = False
+# latex_use_parts = False
# Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
+# latex_preamble = ''
# Documents to append as an appendix to all manuals.
-#latex_appendices = []
+# latex_appendices = []
# If false, no module index is generated.
-#latex_use_modindex = True
+# latex_use_modindex = True
# Example configuration for intersphinx: refer to the Python standard library.
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/ForgeBlog/forgeblog/tests/functional/test_feeds.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/functional/test_feeds.py b/ForgeBlog/forgeblog/tests/functional/test_feeds.py
index f587ebd..8bf84ca 100644
--- a/ForgeBlog/forgeblog/tests/functional/test_feeds.py
+++ b/ForgeBlog/forgeblog/tests/functional/test_feeds.py
@@ -18,7 +18,7 @@
import datetime
-from nose.tools import assert_equal, assert_in
+from nose.tools import assert_in
from ming.orm.ormsession import ThreadLocalORMSession
from alluratest.controller import TestController
from allura import model as M
@@ -39,7 +39,7 @@ class TestFeeds(TestController):
def _update(self, url='', delete=False, **kw):
if delete:
d = {
- 'delete':'Delete'
+ 'delete': 'Delete'
}
else:
d = {
@@ -48,7 +48,7 @@ class TestFeeds(TestController):
'labels': '',
'state': 'published'}
d.update(kw)
- r = self.app.post('/blog/' + str(self._blog_date()) + "/" + url + "/save", params = d)
+ r = self.app.post('/blog/' + str(self._blog_date()) + "/" + url + "/save", params=d)
return r
def _blog_date(self):
@@ -75,7 +75,8 @@ class TestFeeds(TestController):
assert 'Nothing to see' in response
self._post(title='test', text='*sometext*')
response = self.app.get('/blog/feed')
- assert '<div class="markdown_content"><p><em>sometext</em></p></div>' in response
+ assert_in('<div class="markdown_content"><p><em>sometext</em></p></div>',
+ response)
def test_related_artifacts(self):
self._post(title='one')
@@ -99,13 +100,13 @@ class TestFeeds(TestController):
# Check if the feed changed.
response = self.app.get('/blog/%s/hello-world/feed.rss' % d)
assert "Everything is here" in response
- assert not "Nothing to see here" in response
+ assert "Nothing to see here" not in response
# Change the status to draft.
response = self.app.get('/blog/')
assert "Everything is here" in response
- r = self._update(url='hello-world', status="draft")
+ self._update(url='hello-world', status="draft")
response = self.app.get('/blog/')
- assert not "Everything is here" in response
+ assert "Everything is here" not in response
def test_post_delete_feed_delete(self):
# Post a blogpost.
@@ -121,6 +122,6 @@ class TestFeeds(TestController):
self._update(url="deletion-post", delete=True)
# Check feed is deleted.
response = self.app.get("/blog/")
- assert not '/blog/%s/deletion-post/edit' % d in response
+ assert '/blog/%s/deletion-post/edit' % d not in response
response = self.app.get("/blog/feed.rss")
- assert not url in response
+ assert url not in response
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/ForgeImporters/docs/conf.py
----------------------------------------------------------------------
diff --git a/ForgeImporters/docs/conf.py b/ForgeImporters/docs/conf.py
index 57a8678..d92ba0b 100644
--- a/ForgeImporters/docs/conf.py
+++ b/ForgeImporters/docs/conf.py
@@ -47,7 +47,7 @@ templates_path = ['_templates']
source_suffix = '.rst'
# The encoding of source files.
-#source_encoding = 'utf-8'
+# source_encoding = 'utf-8'
# The master toctree document.
master_doc = 'index'
@@ -61,46 +61,46 @@ copyright = '2012-2016 The Apache Software Foundation'
# built documents.
#
# The short X.Y version.
-#version = '0.1'
+# version = '0.1'
# The full version, including alpha/beta/rc tags.
-#release = '0.1'
+# release = '0.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
-#language = None
+# language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
-#today = ''
+# today = ''
# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
+# today_fmt = '%B %d, %Y'
# List of documents that shouldn't be included in the build.
-#unused_docs = []
+# unused_docs = []
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = ['_build']
# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
+# default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
+# add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
-#add_module_names = True
+# add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
-#show_authors = False
+# show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
+# modindex_common_prefix = []
# -- Options for HTML output ---------------------------------------------
@@ -112,26 +112,26 @@ html_theme = 'sphinxdoc'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
-#html_theme_options = {}
+# html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
+# html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = 'ForgeImporters for Allura documentation'
# A shorter title for the navigation bar. Default is the same as html_title.
-#html_short_title = None
+# html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
-#html_logo = None
+# html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
-#html_favicon = None
+# html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
@@ -140,50 +140,49 @@ html_static_path = ['_static']
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+# html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
-#html_use_smartypants = True
+# html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
+# html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
-#html_additional_pages = {}
+# html_additional_pages = {}
# If false, no module index is generated.
-#html_use_modindex = True
+# html_use_modindex = True
# If false, no index is generated.
-#html_use_index = True
+# html_use_index = True
# If true, the index is split into individual pages for each letter.
-#html_split_index = False
+# html_split_index = False
# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
+# html_show_sourcelink = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
+# html_use_opensearch = ''
# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = ''
+# html_file_suffix = ''
# Output file base name for HTML help builder.
htmlhelp_basename = 'alluradoc'
-
# -- Options for LaTeX output --------------------------------------------
# The paper size ('letter' or 'a4').
-#latex_paper_size = 'letter'
+# latex_paper_size = 'letter'
# The font size ('10pt', '11pt' or '12pt').
-#latex_font_size = '10pt'
+# latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
@@ -194,20 +193,20 @@ latex_documents = [
# The name of an image file (relative to this directory) to place at the top of
# the title page.
-#latex_logo = None
+# latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
-#latex_use_parts = False
+# latex_use_parts = False
# Additional stuff for the LaTeX preamble.
-#latex_preamble = ''
+# latex_preamble = ''
# Documents to append as an appendix to all manuals.
-#latex_appendices = []
+# latex_appendices = []
# If false, no module index is generated.
-#latex_use_modindex = True
+# latex_use_modindex = True
# Example configuration for intersphinx: refer to the Python standard library.
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 375e33e..1023394 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -82,18 +82,15 @@ class TestNewRepo(unittest.TestCase):
assert self.rev.tree._id == self.rev.tree_id
assert self.rev.shorthand_id() == '[r6]'
assert self.rev.symbolic_ids == ([], [])
- assert self.rev.url() == (
- '/p/test/src/6/')
+ assert self.rev.url() == '/p/test/src/6/'
all_cis = list(self.repo.log(self.rev._id))
assert len(all_cis) == 6
self.rev.tree.ls()
- assert self.rev.tree.readme() == (
- 'README', 'This is readme\nAnother Line\n')
+ assert self.rev.tree.readme() == ('README', 'This is readme\nAnother Line\n')
assert self.rev.tree.path() == '/'
- assert self.rev.tree.url() == (
- '/p/test/src/6/tree/')
+ assert self.rev.tree.url() == '/p/test/src/6/tree/'
self.rev.tree.by_name['README']
- assert self.rev.tree.is_blob('README') == True
+ assert self.rev.tree.is_blob('README') is True
assert self.rev.tree['a']['b']['c'].ls() == []
self.assertRaises(KeyError, lambda: self.rev.tree['a']['b']['d'])
@@ -828,18 +825,13 @@ class TestRepo(_TestWithRepo):
assert i['name_s'] == 'test1', i
def test_scm_host_url(self):
- assert (
- self.repo.clone_url('rw', 'nobody')
- == 'svn+ssh://nobody@localhost:8022/scm-repo/p/test/test1/'),\
- self.repo.clone_url('rw', 'nobody')
- assert (
- self.repo.clone_url('https', 'nobody')
- == 'https://nobody@localhost:8022/scm-repo/p/test/test1/'),\
- self.repo.clone_url('https', 'nobody')
+ assert_equal(self.repo.clone_url('rw', 'nobody'),
+ 'svn+ssh://nobody@localhost:8022/scm-repo/p/test/test1/')
+ assert_equal(self.repo.clone_url('https', 'nobody'),
+ 'https://nobody@localhost:8022/scm-repo/p/test/test1/')
with h.push_config(self.repo.app.config.options, external_checkout_url='https://$username@foo.com/'):
- assert_equal(
- self.repo.clone_url('https', 'user'),
- 'https://user@foo.com/')
+ assert_equal(self.repo.clone_url('https', 'user'),
+ 'https://user@foo.com/')
def test_guess_type(self):
assert self.repo.guess_type('foo.txt') == ('text/plain', None)
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 9fcab09..98011ef 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -15,7 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-#-*- python -*-
import logging
import re
from datetime import datetime, timedelta
@@ -81,7 +80,6 @@ from forgetracker.widgets.ticket_form import TicketForm, TicketCustomField
from forgetracker.widgets.bin_form import BinForm
from forgetracker.widgets.ticket_search import TicketSearchResults, MassEdit, MassEditForm, MassMoveForm
from forgetracker.widgets.admin_custom_fields import TrackerFieldAdmin, TrackerFieldDisplay
-from forgetracker.import_support import ImportSupport
log = logging.getLogger(__name__)
@@ -550,8 +548,6 @@ class ForgeTrackerApp(Application):
return milestones
-### Controllers ###
-
def mongo_columns():
columns = [dict(name='ticket_num',
sort_name='ticket_num',
@@ -674,7 +670,7 @@ class RootController(BaseController, FeedController):
count = c.app.globals.bin_count(bin_id)['hits']
except ValueError:
log.info('Ticket bin %s search failed for project %s' %
- (label, c.project.shortname))
+ (label, c.project.shortname))
bin_counts.append(dict(label=label, count=count))
return dict(bin_counts=bin_counts)
@@ -1544,7 +1540,7 @@ class TicketController(BaseController, FeedController):
thread = self.ticket.discussion_thread
if changes.get_changed() or post_text or notification_text:
thread.add_post(text=post_text, is_meta=True,
- notification_text=notification_text)
+ notification_text=notification_text)
self.ticket.commit()
if comment:
thread.post(text=comment, notify=False)
@@ -1701,7 +1697,7 @@ class TrackerAdminController(DefaultAdminController):
@require_post()
def allow_default_field(self, **post_data):
for column in self.app.globals['show_in_search'].keys():
- if post_data.has_key(column) and post_data[column] == 'on':
+ if post_data.get(column) == 'on':
self.app.globals['show_in_search'][column] = True
else:
self.app.globals['show_in_search'][column] = False
@@ -1908,7 +1904,7 @@ class MilestoneController(BaseController):
def __init__(self, root, field, milestone):
for fld in c.app.globals.milestone_fields:
name_no_underscore = fld.name[1:]
- if fld.name[1:] == field:
+ if name_no_underscore == field:
break
else:
raise exc.HTTPNotFound()
http://git-wip-us.apache.org/repos/asf/allura/blob/32ebab90/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 0402b40..a220def 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -47,7 +47,8 @@ class TestRootController(TestController):
pass
def _find_edit_form(self, resp):
- cond = lambda f: f.id == 'page_edit_form'
+ def cond(f):
+ return f.id == 'page_edit_form'
return self.find_form(resp, cond)
def test_root_index(self):
|