You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2019/11/13 23:14:14 UTC
[allura] 05/05: [#8340] misc other coverage
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8340
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 5229706e21e34845931d56874068cbdbf8bba87c
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Wed Nov 13 18:13:32 2019 -0500
[#8340] misc other coverage
---
Allura/allura/config/app_cfg.py | 1 -
Allura/allura/lib/helpers.py | 44 +---------------------------
Allura/allura/tests/functional/test_admin.py | 4 +++
Allura/allura/tests/test_helpers.py | 5 ----
4 files changed, 5 insertions(+), 49 deletions(-)
diff --git a/Allura/allura/config/app_cfg.py b/Allura/allura/config/app_cfg.py
index 222fa54..f5b1464 100644
--- a/Allura/allura/config/app_cfg.py
+++ b/Allura/allura/config/app_cfg.py
@@ -103,7 +103,6 @@ class AlluraJinjaRenderer(JinjaRenderer):
cache_size=config.get('jinja_cache_size', -1),
extensions=['jinja2.ext.do', 'jinja2.ext.i18n'])
jinja2_env.install_gettext_translations(tg.i18n)
- jinja2_env.filters['filesizeformat'] = helpers.do_filesizeformat
jinja2_env.filters['datetimeformat'] = helpers.datetimeformat
jinja2_env.filters['filter'] = lambda s, t=None: filter(t and jinja2_env.tests[t], s)
jinja2_env.filters['nl2br'] = helpers.nl2br_jinja_filter
diff --git a/Allura/allura/lib/helpers.py b/Allura/allura/lib/helpers.py
index 82285f9..8066a8b 100644
--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -58,7 +58,7 @@ from tg.decorators import before_validate
from formencode.variabledecode import variable_decode
import formencode
from jinja2 import Markup
-from jinja2.filters import contextfilter, escape
+from jinja2.filters import contextfilter, escape, do_filesizeformat
from paste.deploy.converters import asbool, aslist, asint
from webhelpers import date, feedgenerator, html, number, misc, text
@@ -233,14 +233,6 @@ def make_neighborhoods(ids):
return _make_xs('Neighborhood', ids)
-def make_projects(ids):
- return _make_xs('Project', ids)
-
-
-def make_users(ids):
- return _make_xs('User', ids)
-
-
def make_roles(ids):
return _make_xs('ProjectRole', ids)
@@ -745,40 +737,6 @@ def render_any_markup(name, txt, code_mode=False, linenumbers_style=TABLE):
txt = '<pre>%s</pre>' % txt
return Markup(txt)
-# copied from jinja2 dev
-# latest release, 2.6, implements this incorrectly
-# can remove and use jinja2 implementation after upgrading to 2.7
-
-
-def do_filesizeformat(value, binary=False):
- """Format the value like a 'human-readable' file size (i.e. 13 kB,
-4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega,
-Giga, etc.), if the second parameter is set to `True` the binary
-prefixes are used (Mebi, Gibi).
-"""
- bytes = float(value)
- base = binary and 1024 or 1000
- prefixes = [
- (binary and 'KiB' or 'kB'),
- (binary and 'MiB' or 'MB'),
- (binary and 'GiB' or 'GB'),
- (binary and 'TiB' or 'TB'),
- (binary and 'PiB' or 'PB'),
- (binary and 'EiB' or 'EB'),
- (binary and 'ZiB' or 'ZB'),
- (binary and 'YiB' or 'YB')
- ]
- if bytes == 1:
- return '1 Byte'
- elif bytes < base:
- return '%d Bytes' % bytes
- else:
- for i, prefix in enumerate(prefixes):
- unit = base ** (i + 2)
- if bytes < unit:
- return '%.1f %s' % ((base * bytes / unit), prefix)
- return '%.1f %s' % ((base * bytes / unit), prefix)
-
def nl2br_jinja_filter(value):
result = '<br>\n'.join(escape(line) for line in value.split('\n'))
diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 3b2c4df..534863e 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -951,6 +951,10 @@ class TestProjectAdmin(TestController):
assert url.endswith('/admin/ext/foo'), url
assert_equals('here the foo settings go', foo_page.body)
+ def test_nbhd_invitations(self):
+ r = self.app.get('/admin/invitations')
+ r.mustcontain('Neighborhood Invitation(s) for test')
+
class TestExport(TestController):
diff --git a/Allura/allura/tests/test_helpers.py b/Allura/allura/tests/test_helpers.py
index 3abde3b..23bfe6c 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -107,11 +107,6 @@ def test_find_project():
assert proj is None
-def test_make_users():
- r = h.make_users([None]).next()
- assert r.username == '*anonymous', r
-
-
def test_make_roles():
h.set_context('test', 'wiki', neighborhood='Projects')
pr = M.ProjectRole.anonymous()