You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by rj...@apache.org on 2014/02/13 06:08:08 UTC
svn commit: r1567849 [15/17] - in /bloodhound/vendor/trac: 1.0-stable/
current/ current/contrib/ current/contrib/cgi-bin/
current/contrib/workflow/ current/doc/ current/doc/utils/
current/sample-plugins/ current/sample-plugins/permissions/ current/samp...
Modified: bloodhound/vendor/trac/current/trac/web/tests/chrome.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/web/tests/chrome.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/web/tests/chrome.py (original)
+++ bloodhound/vendor/trac/current/trac/web/tests/chrome.py Thu Feb 13 05:08:02 2014
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2013 Edgewall Software
+# Copyright (C) 2005-2013 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
@@ -11,23 +11,31 @@
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/log/.
-from trac.core import Component, implements
-from trac.test import EnvironmentStub
+import os
+import shutil
+import tempfile
+import unittest
+
+from trac.core import Component, TracError, implements
+from trac.test import EnvironmentStub, locale_en
+from trac.tests import compat
from trac.tests.contentgen import random_sentence
+from trac.util import create_file
from trac.web.chrome import (
Chrome, INavigationContributor, add_link, add_meta, add_notice, add_script,
add_script_data, add_stylesheet, add_warning)
from trac.web.href import Href
-import unittest
class Request(object):
locale = None
+ args = {}
def __init__(self, **kwargs):
self.chrome = {}
for k, v in kwargs.items():
setattr(self, k, v)
+
class ChromeTestCase(unittest.TestCase):
def setUp(self):
@@ -76,14 +84,18 @@ class ChromeTestCase(unittest.TestCase):
add_script(req, 'common/js/trac.js')
add_script(req, 'common/js/trac.js')
add_script(req, 'http://example.com/trac.js')
+ add_script(req, '//example.com/trac.js')
scripts = req.chrome['scripts']
- self.assertEqual(2, len(scripts))
+ self.assertEqual(3, len(scripts))
self.assertEqual('text/javascript', scripts[0]['type'])
self.assertEqual('/trac.cgi/chrome/common/js/trac.js',
scripts[0]['href'])
self.assertEqual('text/javascript', scripts[1]['type'])
self.assertEqual('http://example.com/trac.js',
scripts[1]['href'])
+ self.assertEqual('text/javascript', scripts[2]['type'])
+ self.assertEqual('//example.com/trac.js',
+ scripts[2]['href'])
def test_add_script_data(self):
req = Request(href=Href('/trac.cgi'))
@@ -97,14 +109,18 @@ class ChromeTestCase(unittest.TestCase):
add_stylesheet(req, 'common/css/trac.css')
add_stylesheet(req, 'common/css/trac.css')
add_stylesheet(req, 'https://example.com/trac.css')
+ add_stylesheet(req, '//example.com/trac.css')
links = req.chrome['links']['stylesheet']
- self.assertEqual(2, len(links))
+ self.assertEqual(3, len(links))
self.assertEqual('text/css', links[0]['type'])
self.assertEqual('/trac.cgi/chrome/common/css/trac.css',
links[0]['href'])
self.assertEqual('text/css', links[1]['type'])
self.assertEqual('https://example.com/trac.css',
links[1]['href'])
+ self.assertEqual('text/css', links[2]['type'])
+ self.assertEqual('//example.com/trac.css',
+ links[2]['href'])
def test_add_stylesheet_media(self):
req = Request(base_path='/trac.cgi', href=Href('/trac.cgi'))
@@ -152,8 +168,8 @@ class ChromeTestCase(unittest.TestCase):
# Verify that no logo data is put in the HDF if no logo is configured
self.env.config.set('header_logo', 'src', '')
info = Chrome(self.env).prepare_request(req)
- assert 'src' not in info['logo']
- assert 'src_abs' not in info['logo']
+ self.assertNotIn('src', info['logo'])
+ self.assertNotIn('src_abs', info['logo'])
# Test with a relative path to the logo image
self.env.config.set('header_logo', 'src', 'foo.png')
@@ -204,8 +220,8 @@ class ChromeTestCase(unittest.TestCase):
# No icon set in config, so no icon links
self.env.config.set('project', 'icon', '')
links = chrome.prepare_request(req)['links']
- assert 'icon' not in links
- assert 'shortcut icon' not in links
+ self.assertNotIn('icon', links)
+ self.assertNotIn('shortcut icon', links)
# Relative URL for icon config option
self.env.config.set('project', 'icon', 'foo.ico')
@@ -304,9 +320,60 @@ class ChromeTestCase(unittest.TestCase):
self.assertEqual('test1', items[0]['name'])
self.assertEqual('test2', items[1]['name'])
+ def test_add_jquery_ui_timezone_list_has_z(self):
+ chrome = Chrome(self.env)
+
+ req = Request(href=Href('/trac.cgi'), lc_time='iso8601')
+ chrome.add_jquery_ui(req)
+ self.assertIn({'value': 'Z', 'label': '+00:00'},
+ req.chrome['script_data']['jquery_ui']['timezone_list'])
+
+ req = Request(href=Href('/trac.cgi'), lc_time=locale_en)
+ chrome.add_jquery_ui(req)
+ self.assertIn({'value': 'Z', 'label': '+00:00'},
+ req.chrome['script_data']['jquery_ui']['timezone_list'])
+
+
+class ChromeTestCase2(unittest.TestCase):
+
+ def setUp(self):
+ self.env = EnvironmentStub(path=tempfile.mkdtemp())
+ self.chrome = Chrome(self.env)
+
+ def tearDown(self):
+ shutil.rmtree(self.env.path)
+
+ def test_malicious_filename_raises(self):
+ req = Request(path_info='/chrome/site/../conf/trac.ini')
+ self.assertTrue(self.chrome.match_request(req))
+ self.assertRaises(TracError, self.chrome.process_request, req)
+
+ def test_empty_shared_htdocs_dir_raises_file_not_found(self):
+ req = Request(path_info='/chrome/shared/trac_logo.png')
+ self.assertEqual('', self.chrome.shared_htdocs_dir)
+ self.assertTrue(self.chrome.match_request(req))
+ from trac.web.api import HTTPNotFound
+ self.assertRaises(HTTPNotFound, self.chrome.process_request, req)
+
+ def test_shared_htdocs_dir_file_is_found(self):
+ from trac.web.api import RequestDone
+ def send_file(path, mimetype):
+ raise RequestDone
+ req = Request(path_info='/chrome/shared/trac_logo.png',
+ send_file=send_file)
+ shared_htdocs_dir = os.path.join(self.env.path, 'chrome', 'shared')
+ os.makedirs(shared_htdocs_dir)
+ create_file(os.path.join(shared_htdocs_dir, 'trac_logo.png'))
+ self.env.config.set('inherit', 'htdocs_dir', shared_htdocs_dir)
+ self.assertTrue(self.chrome.match_request(req))
+ self.assertRaises(RequestDone, self.chrome.process_request, req)
+
def suite():
- return unittest.makeSuite(ChromeTestCase, 'test')
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(ChromeTestCase))
+ suite.addTest(unittest.makeSuite(ChromeTestCase2))
+ return suite
if __name__ == '__main__':
unittest.main(defaultTest='suite')
Modified: bloodhound/vendor/trac/current/trac/web/tests/href.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/web/tests/href.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/web/tests/href.py (original)
+++ bloodhound/vendor/trac/current/trac/web/tests/href.py Thu Feb 13 05:08:02 2014
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2005-2009 Edgewall Software
+# Copyright (C) 2005-2013 Edgewall Software
# Copyright (C) 2005-2007 Christopher Lenz <cm...@gmx.de>
# All rights reserved.
#
@@ -16,6 +16,7 @@ import doctest
import unittest
import trac.web.href
+from trac.tests import compat
class HrefTestCase(unittest.TestCase):
@@ -36,9 +37,9 @@ class HrefTestCase(unittest.TestCase):
self.assertEqual('/base/sub/other/', href('sub', 'other', ''))
self.assertEqual('/base/with%20special%26chars',
href('with special&chars'))
- assert href('page', param='value', other='other value', more=None) in [
+ self.assertIn(href('page', param='value', other='other value', more=None), [
'/base/page?param=value&other=other+value',
- '/base/page?other=other+value¶m=value']
+ '/base/page?other=other+value¶m=value'])
self.assertEqual('/base/page?param=multiple¶m=values',
href('page', param=['multiple', 'values']))
@@ -73,9 +74,10 @@ class HrefTestCase(unittest.TestCase):
self.assertEqual('/sub/other/', href('sub', 'other', ''))
self.assertEqual('/with%20special%26chars',
href('with special&chars'))
- assert href('page', param='value', other='other value', more=None) in [
- '/page?param=value&other=other+value',
- '/page?other=other+value¶m=value']
+ self.assertIn(
+ href('page', param='value', other='other value', more=None),
+ ['/page?param=value&other=other+value',
+ '/page?other=other+value¶m=value'])
self.assertEqual('/page?param=multiple¶m=values',
href('page', param=['multiple', 'values']))
@@ -96,9 +98,9 @@ class HrefTestCase(unittest.TestCase):
href(param=MyList(['test', 'other'])))
self.assertEqual('/base?param=test¶m=other',
href(param=MyTuple(['test', 'other'])))
- assert href(MyDict(param='value', other='other value')) in [
+ self.assertIn(href(MyDict(param='value', other='other value')), [
'/base?param=value&other=other+value',
- '/base?other=other+value¶m=value']
+ '/base?other=other+value¶m=value'])
self.assertEqual('/base?param=value&other=other+value',
href(MyList([('param', 'value'), ('other', 'other value')])))
self.assertEqual('/base?param=value&other=other+value',
@@ -108,7 +110,7 @@ class HrefTestCase(unittest.TestCase):
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(trac.web.href))
- suite.addTest(unittest.makeSuite(HrefTestCase, 'test'))
+ suite.addTest(unittest.makeSuite(HrefTestCase))
return suite
if __name__ == '__main__':
Modified: bloodhound/vendor/trac/current/trac/web/tests/main.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/web/tests/main.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/web/tests/main.py (original)
+++ bloodhound/vendor/trac/current/trac/web/tests/main.py Thu Feb 13 05:08:02 2014
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2010 Edgewall Software
+# Copyright (C) 2010-2013 Edgewall Software
# All rights reserved.
#
# This software is licensed as described in the file COPYING, which
@@ -11,12 +11,83 @@
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://trac.edgewall.org/log/.
-from trac.util import create_file
-from trac.web.main import get_environments
-
+import os.path
import tempfile
import unittest
-import os.path
+
+from trac.core import Component, ComponentMeta, TracError, implements
+from trac.test import EnvironmentStub, Mock
+from trac.util import create_file
+from trac.web.auth import IAuthenticator
+from trac.web.main import RequestDispatcher, get_environments
+
+
+class AuthenticateTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.env = EnvironmentStub(disable=['trac.web.auth.LoginModule'])
+ self.request_dispatcher = RequestDispatcher(self.env)
+ self.req = Mock(chrome={'warnings': []})
+ # Make sure we have no external components hanging around in the
+ # component registry
+ self.old_registry = ComponentMeta._registry
+ ComponentMeta._registry = {}
+
+ def tearDown(self):
+ # Restore the original component registry
+ ComponentMeta._registry = self.old_registry
+
+ def test_authenticate_returns_first_successful(self):
+ class SuccessfulAuthenticator1(Component):
+ implements(IAuthenticator)
+ def authenticate(self, req):
+ return 'user1'
+ class SuccessfulAuthenticator2(Component):
+ implements(IAuthenticator)
+ def authenticate(self, req):
+ return 'user2'
+ self.assertEqual(2, len(self.request_dispatcher.authenticators))
+ self.assertIsInstance(self.request_dispatcher.authenticators[0],
+ SuccessfulAuthenticator1)
+ self.assertIsInstance(self.request_dispatcher.authenticators[1],
+ SuccessfulAuthenticator2)
+ self.assertEqual('user1',
+ self.request_dispatcher.authenticate(self.req))
+
+ def test_authenticate_skips_unsuccessful(self):
+ class UnsuccessfulAuthenticator(Component):
+ implements(IAuthenticator)
+ def authenticate(self, req):
+ return None
+ class SuccessfulAuthenticator(Component):
+ implements(IAuthenticator)
+ def authenticate(self, req):
+ return 'user'
+ self.assertEqual(2, len(self.request_dispatcher.authenticators))
+ self.assertIsInstance(self.request_dispatcher.authenticators[0],
+ UnsuccessfulAuthenticator)
+ self.assertIsInstance(self.request_dispatcher.authenticators[1],
+ SuccessfulAuthenticator)
+ self.assertEqual('user',
+ self.request_dispatcher.authenticate(self.req))
+
+ def test_authenticate_raises(self):
+ class RaisingAuthenticator(Component):
+ implements(IAuthenticator)
+ def authenticate(self, req):
+ raise TracError("Bad attempt")
+ class SuccessfulAuthenticator(Component):
+ implements(IAuthenticator)
+ def authenticate(self, req):
+ return 'user'
+ self.assertEqual(2, len(self.request_dispatcher.authenticators))
+ self.assertIsInstance(self.request_dispatcher.authenticators[0],
+ RaisingAuthenticator)
+ self.assertIsInstance(self.request_dispatcher.authenticators[1],
+ SuccessfulAuthenticator)
+ self.assertEqual('anonymous',
+ self.request_dispatcher.authenticate(self.req))
+ self.assertEqual(1, len(self.req.chrome['warnings']))
class EnvironmentsTestCase(unittest.TestCase):
@@ -51,32 +122,33 @@ class EnvironmentsTestCase(unittest.Test
for project in projects)
def test_default_tracignore(self):
- self.assertEquals(self.env_paths(['mydir1', 'mydir2']),
- get_environments(self.environ))
+ self.assertEqual(self.env_paths(['mydir1', 'mydir2']),
+ get_environments(self.environ))
def test_empty_tracignore(self):
create_file(self.tracignore)
- self.assertEquals(self.env_paths(['mydir1', 'mydir2', '.hidden_dir']),
- get_environments(self.environ))
+ self.assertEqual(self.env_paths(['mydir1', 'mydir2', '.hidden_dir']),
+ get_environments(self.environ))
def test_qmark_pattern_tracignore(self):
create_file(self.tracignore, 'mydir?')
- self.assertEquals(self.env_paths(['.hidden_dir']),
- get_environments(self.environ))
+ self.assertEqual(self.env_paths(['.hidden_dir']),
+ get_environments(self.environ))
def test_star_pattern_tracignore(self):
create_file(self.tracignore, 'my*\n.hidden_dir')
- self.assertEquals({}, get_environments(self.environ))
+ self.assertEqual({}, get_environments(self.environ))
def test_combined_tracignore(self):
create_file(self.tracignore, 'my*i?1\n\n#mydir2')
- self.assertEquals(self.env_paths(['mydir2', '.hidden_dir']),
- get_environments(self.environ))
+ self.assertEqual(self.env_paths(['mydir2', '.hidden_dir']),
+ get_environments(self.environ))
def suite():
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(EnvironmentsTestCase, 'test'))
+ suite.addTest(unittest.makeSuite(AuthenticateTestCase))
+ suite.addTest(unittest.makeSuite(EnvironmentsTestCase))
return suite
Modified: bloodhound/vendor/trac/current/trac/web/tests/session.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/web/tests/session.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/web/tests/session.py (original)
+++ bloodhound/vendor/trac/current/trac/web/tests/session.py Thu Feb 13 05:08:02 2014
@@ -1,3 +1,16 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2005-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
from __future__ import with_statement
from Cookie import SimpleCookie as Cookie
@@ -6,6 +19,7 @@ from datetime import datetime
import unittest
from trac.test import EnvironmentStub, Mock
+from trac.tests import compat
from trac.web.session import DetachedSession, Session, PURGE_AGE, \
UPDATE_INTERVAL, SessionAdmin
from trac.core import TracError
@@ -88,8 +102,8 @@ class SessionTestCase(unittest.TestCase)
req = Mock(authname='anonymous', base_path='/', incookie=incookie,
outcookie=outcookie)
session = Session(self.env, req)
- self.assertEquals('123456', session.sid)
- self.failIf(outcookie.has_key('trac_session'))
+ self.assertEqual('123456', session.sid)
+ self.assertNotIn('trac_session', outcookie)
def test_authenticated_session(self):
"""
@@ -105,7 +119,7 @@ class SessionTestCase(unittest.TestCase)
self.assertEqual('john', session.sid)
session['foo'] = 'bar'
session.save()
- self.assertEquals(0, outcookie['trac_session']['expires'])
+ self.assertEqual(0, outcookie['trac_session']['expires'])
def test_session_promotion(self):
"""
@@ -351,7 +365,7 @@ class SessionTestCase(unittest.TestCase)
req = Mock(authname='anonymous', base_path='/', incookie=incookie,
outcookie=Cookie())
session = Session(self.env, req)
- self.assert_('foo' not in session)
+ self.assertTrue('foo' not in session)
session['foo'] = 'baz'
session.save()
@@ -572,8 +586,8 @@ class SessionTestCase(unittest.TestCase)
def suite():
- return unittest.makeSuite(SessionTestCase, 'test')
+ return unittest.makeSuite(SessionTestCase)
if __name__ == '__main__':
- unittest.main()
+ unittest.main(defaultTest='suite')
Modified: bloodhound/vendor/trac/current/trac/web/tests/wikisyntax.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/web/tests/wikisyntax.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/web/tests/wikisyntax.py (original)
+++ bloodhound/vendor/trac/current/trac/web/tests/wikisyntax.py Thu Feb 13 05:08:02 2014
@@ -1,3 +1,16 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2006-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
import unittest
from trac.wiki.tests import formatter
Modified: bloodhound/vendor/trac/current/trac/web/wsgi.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/web/wsgi.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/web/wsgi.py (original)
+++ bloodhound/vendor/trac/current/trac/web/wsgi.py Thu Feb 13 05:08:02 2014
@@ -85,6 +85,7 @@ class WSGIGateway(object):
self.headers_set = []
self.headers_sent = []
+ self.use_chunked = False
def run(self, application):
"""Start the gateway with the given WSGI application."""
@@ -98,8 +99,8 @@ class WSGIGateway(object):
for chunk in response:
if chunk:
self._write(chunk)
- if not self.headers_sent:
- self._write('')
+ if not self.headers_sent or self.use_chunked:
+ self._write('') # last chunk '\r\n0\r\n' if use_chunked
finally:
if hasattr(response, 'close'):
response.close()
@@ -212,12 +213,27 @@ class WSGIServerGateway(WSGIGateway):
try:
if not self.headers_sent:
+ # Worry at the last minute about Content-Length. If not
+ # yet set, use either chunked encoding or close connection
status, headers = self.headers_sent = self.headers_set
+ if any(n.lower() == 'content-length' for n, v in headers):
+ self.use_chunked = False
+ else:
+ self.use_chunked = (
+ self.environ['SERVER_PROTOCOL'] >= 'HTTP/1.1' and
+ self.handler.protocol_version >= 'HTTP/1.1')
+ if self.use_chunked:
+ headers.append(('Transfer-Encoding', 'chunked'))
+ else:
+ headers.append(('Connection', 'close'))
self.handler.send_response(int(status[:3]))
for name, value in headers:
self.handler.send_header(name, value)
self.handler.end_headers()
- self.handler.wfile.write(data)
+ if self.use_chunked:
+ self.handler.wfile.write('%x\r\n%s\r\n' % (len(data), data))
+ else:
+ self.handler.wfile.write(data)
except (IOError, socket.error), e:
if e.args[0] in (errno.EPIPE, errno.ECONNRESET, 10053, 10054):
# client disconnect
Modified: bloodhound/vendor/trac/current/trac/wiki/__init__.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/__init__.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/__init__.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/__init__.py Thu Feb 13 05:08:02 2014
@@ -1,3 +1,16 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2005-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.com/license.html.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/.
+
from trac.wiki.api import *
from trac.wiki.formatter import *
from trac.wiki.intertrac import *
Modified: bloodhound/vendor/trac/current/trac/wiki/default-pages/WikiStart
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/default-pages/WikiStart?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/default-pages/WikiStart (original)
+++ bloodhound/vendor/trac/current/trac/wiki/default-pages/WikiStart Thu Feb 13 05:08:02 2014
@@ -1,4 +1,4 @@
-= Welcome to Trac 1.0.1 =
+= Welcome to Trac 1.0.2 =
Trac is a '''minimalistic''' approach to '''web-based''' management of
'''software projects'''. Its goal is to simplify effective tracking and handling of software issues, enhancements and overall progress.
Modified: bloodhound/vendor/trac/current/trac/wiki/formatter.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/formatter.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/formatter.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/formatter.py Thu Feb 13 05:08:02 2014
@@ -69,7 +69,8 @@ def split_url_into_path_query_fragment(t
idx = target.find('?')
if idx >= 0:
target, query = target[:idx], target[idx:]
- return (target, query, fragment)
+ return target, query, fragment
+
def concat_path_query_fragment(path, query, fragment=None):
"""Assemble `path`, `query` and `fragment` into a proper URL.
@@ -97,6 +98,7 @@ def concat_path_query_fragment(path, que
f = fragment
return p + q + ('' if f == '#' else f)
+
def _markup_to_unicode(markup):
stream = None
if isinstance(markup, Element):
@@ -150,9 +152,9 @@ class WikiProcessor(object):
}
self.inline_check = {'html': self._html_is_inline,
- 'htmlcomment': True, 'comment': True,
- 'span': True, 'Span': True,
- }.get(name)
+ 'htmlcomment': True, 'comment': True,
+ 'span': True, 'Span': True,
+ }.get(name)
self._sanitizer = TracHTMLSanitizer(formatter.wiki.safe_schemes)
@@ -172,7 +174,6 @@ class WikiProcessor(object):
break
if not self.processor:
# Find a matching mimeview renderer
- from trac.mimeview.api import Mimeview
mimeview = Mimeview(formatter.env)
for renderer in mimeview.renderers:
if renderer.get_quality_ratio(self.name) > 1:
@@ -438,7 +439,7 @@ class Formatter(object):
'MM_STRIKE': ('<del>', '</del>'),
'MM_SUBSCRIPT': ('<sub>', '</sub>'),
'MM_SUPERSCRIPT': ('<sup>', '</sup>'),
- }
+ }
def _get_open_tag(self, tag):
"""Retrieve opening tag for direct or indirect `tag`."""
@@ -477,12 +478,12 @@ class Formatter(object):
If `close_tag` is not specified, it's an indirect tag (0.12)
"""
- tmp = ''
+ tmp = ''
for i in xrange(len(self._open_tags) - 1, -1, -1):
tag = self._open_tags[i]
tmp += self._get_close_tag(tag)
if (open_tag == tag,
- (open_tag, close_tag) == tag)[bool(close_tag)]:
+ (open_tag, close_tag) == tag)[bool(close_tag)]:
del self._open_tags[i]
for j in xrange(i, len(self._open_tags)):
tmp += self._get_open_tag(self._open_tags[j])
@@ -549,7 +550,7 @@ class Formatter(object):
# -- Post- IWikiSyntaxProvider rules
- # WikiCreole line brekas
+ # WikiCreole line breaks
def _linebreak_wc_formatter(self, match, fullmatch):
return '<br />'
@@ -575,7 +576,7 @@ class Formatter(object):
ns = fullmatch.group('snsbr')
target = unquote_label(fullmatch.group('stgtbr'))
match = match[1:-1]
- return '<%s>' % \
+ return u'<%s>' % \
self._make_link(ns, target, match, match, fullmatch)
def _shref_formatter(self, match, fullmatch):
@@ -764,10 +765,10 @@ class Formatter(object):
try:
return macro.ensure_inline(macro.process(args))
except Exception, e:
- self.env.log.error('Macro %s(%s) failed: %s' %
- (name, args, exception_to_unicode(e, traceback=True)))
+ self.env.log.error('Macro %s(%s) failed:%s', name, args,
+ exception_to_unicode(e, traceback=True))
return system_message('Error: Macro %s(%s) failed' % (name, args),
- e)
+ to_unicode(e))
# Headings
@@ -1005,7 +1006,7 @@ class Formatter(object):
if separator[-1] == '=':
numpipes -= 1
cell = 'th'
- colspan = numpipes/2
+ colspan = numpipes / 2
if is_last is not None:
if is_last and is_last[-1] == '\\':
self.continue_table_row = 1
@@ -1505,7 +1506,7 @@ class HtmlFormatter(object):
class InlineHtmlFormatter(object):
"""Format parsed wiki text to inline elements HTML.
- Block level content will be disguarded or compacted.
+ Block level content will be discarded or compacted.
"""
flavor = 'oneliner'
Modified: bloodhound/vendor/trac/current/trac/wiki/intertrac.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/intertrac.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/intertrac.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/intertrac.py Thu Feb 13 05:08:02 2014
@@ -20,7 +20,6 @@ from genshi.builder import Element, Frag
from trac.config import ConfigSection
from trac.core import *
-from trac.perm import PermissionError
from trac.util.html import find_element
from trac.util.translation import _, N_
from trac.web.api import IRequestHandler
@@ -90,8 +89,10 @@ class InterTracDispatcher(Component):
link_frag = extract_link(self.env, web_context(req), link)
if isinstance(link_frag, (Element, Fragment)):
elt = find_element(link_frag, 'href')
- if elt is None: # most probably no permissions to view
- raise PermissionError(_("Can't view %(link)s:", link=link))
+ if elt is None:
+ raise TracError(
+ _("Can't view %(link)s. Resource doesn't exist or "
+ "you don't have the required permission.", link=link))
href = elt.attrib.get('href')
else:
href = req.href(link.rstrip(':'))
Modified: bloodhound/vendor/trac/current/trac/wiki/macros.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/macros.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/macros.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/macros.py Thu Feb 13 05:08:02 2014
@@ -71,7 +71,7 @@ class WikiMacroBase(Component):
def parse_macro(self, parser, name, content):
raise NotImplementedError
- def expand_macro(self, formatter, name, content):
+ def expand_macro(self, formatter, name, content, args=None):
raise NotImplementedError(
"pre-0.11 Wiki macro %s by provider %s no longer supported" %
(name, self.__class__))
@@ -477,21 +477,22 @@ class ImageMacro(WikiMacroBase):
Examples:
{{{
- [[Image(photo.jpg)]] # simplest
- [[Image(photo.jpg, 120px)]] # with image width size
- [[Image(photo.jpg, right)]] # aligned by keyword
- [[Image(photo.jpg, nolink)]] # without link to source
- [[Image(photo.jpg, align=right)]] # aligned by attribute
+ [[Image(photo.jpg)]] # simplest
+ [[Image(photo.jpg, 120px)]] # with image width size
+ [[Image(photo.jpg, right)]] # aligned by keyword
+ [[Image(photo.jpg, nolink)]] # without link to source
+ [[Image(photo.jpg, align=right)]] # aligned by attribute
}}}
- You can use image from other page, other ticket or other module.
+ You can use an image from a wiki page, ticket or other module.
{{{
- [[Image(OtherPage:foo.bmp)]] # if current module is wiki
- [[Image(base/sub:bar.bmp)]] # from hierarchical wiki page
- [[Image(#3:baz.bmp)]] # if in a ticket, point to #3
- [[Image(ticket:36:boo.jpg)]]
- [[Image(source:/images/bee.jpg)]] # straight from the repository!
- [[Image(htdocs:foo/bar.png)]] # image file in project htdocs dir.
+ [[Image(OtherPage:foo.bmp)]] # from a wiki page
+ [[Image(base/sub:bar.bmp)]] # from hierarchical wiki page
+ [[Image(#3:baz.bmp)]] # from another ticket
+ [[Image(ticket:36:boo.jpg)]] # from another ticket (long form)
+ [[Image(source:/img/bee.jpg)]] # from the repository
+ [[Image(htdocs:foo/bar.png)]] # from project htdocs dir
+ [[Image(shared:foo/bar.png)]] # from shared htdocs dir (since 1.0.2)
}}}
''Adapted from the Image.py macro created by Shun-ichi Goto
@@ -501,6 +502,8 @@ class ImageMacro(WikiMacroBase):
def is_inline(self, content):
return True
+ _split_filespec_re = re.compile(r''':(?!(?:[^"':]|[^"']:[^'"])+["'])''')
+
def expand_macro(self, formatter, name, content):
# args will be null if the macro is called without parenthesis.
if not content:
@@ -534,7 +537,7 @@ class ImageMacro(WikiMacroBase):
except Exception:
browser_links = []
while args:
- arg = args.pop(0).strip()
+ arg = stripws(args.pop(0))
if size_re.match(arg):
# 'width' keyword
attr['width'] = arg
@@ -578,7 +581,8 @@ class ImageMacro(WikiMacroBase):
attr[str(key)] = val # will be used as a __call__ kwd
# parse filespec argument to get realm and id if contained.
- parts = filespec.split(':')
+ parts = [i.strip('''['"]''')
+ for i in self._split_filespec_re.split(filespec)]
url = raw_url = desc = None
attachment = None
if (parts and parts[0] in ('http', 'https', 'ftp')): # absolute
@@ -626,6 +630,9 @@ class ImageMacro(WikiMacroBase):
elif id == 'htdocs':
raw_url = url = formatter.href.chrome('site', filename)
desc = os.path.basename(filename)
+ elif id == 'shared':
+ raw_url = url = formatter.href.chrome('shared', filename)
+ desc = os.path.basename(filename)
else:
realm = 'wiki'
if realm:
@@ -732,10 +739,10 @@ class TracIniMacro(WikiMacroBase):
options whose section and name start with the filters are output.
""")
- def expand_macro(self, formatter, name, args):
+ def expand_macro(self, formatter, name, content):
from trac.config import ConfigSection, Option
section_filter = key_filter = ''
- args, kw = parse_args(args)
+ args, kw = parse_args(content)
if args:
section_filter = args.pop(0).strip()
if args:
@@ -761,19 +768,11 @@ class TracIniMacro(WikiMacroBase):
def default_cell(option):
default = option.default
- if default is True:
- default = 'true'
- elif default is False:
- default = 'false'
- elif default == 0:
- default = '0.0' if isinstance(default, float) else '0'
- elif default:
- default = ', '.join(to_unicode(val) for val in default) \
- if isinstance(default, (list, tuple)) \
- else to_unicode(default)
+ if default is not None and default != '':
+ return tag.td(tag.code(option.dumps(default)),
+ class_='default')
else:
return tag.td(_("(no default)"), class_='nodefault')
- return tag.td(tag.code(default), class_='default')
return tag.div(class_='tracini')(
(tag.h3(tag.code('[%s]' % section), id='%s-section' % section),
@@ -782,9 +781,11 @@ class TracIniMacro(WikiMacroBase):
tag.tr(tag.td(tag.tt(option.name)),
tag.td(format_to_oneliner(
self.env, formatter.context, getdoc(option))),
- default_cell(option))
- for option in sorted(options.get(section, {}).itervalues(),
- key=lambda o: o.name)
+ default_cell(option),
+ class_='odd' if idx % 2 else 'even')
+ for idx, option in \
+ enumerate(sorted(options.get(section, {}).itervalues(),
+ key=lambda o: o.name))
if option.name.startswith(key_filter))))
for section, section_doc in sorted(sections.iteritems()))
@@ -798,11 +799,11 @@ class KnownMimeTypesMacro(WikiMacroBase)
Can be given an optional argument which is interpreted as mime-type filter.
""")
- def expand_macro(self, formatter, name, args):
+ def expand_macro(self, formatter, name, content):
from trac.mimeview.api import Mimeview
mime_map = Mimeview(self.env).mime_map
mime_type_filter = ''
- args, kw = parse_args(args)
+ args, kw = parse_args(content)
if args:
mime_type_filter = args.pop(0).strip().rstrip('*')
@@ -865,7 +866,7 @@ class TracGuideTocMacro(WikiMacroBase):
('TracNotification', 'Notification'),
]
- def expand_macro(self, formatter, name, args):
+ def expand_macro(self, formatter, name, content):
curpage = formatter.resource.id
# scoped TOC (e.g. TranslateRu/TracGuide or 0.11/TracGuide ...)
Modified: bloodhound/vendor/trac/current/trac/wiki/model.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/model.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/model.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/model.py Thu Feb 13 05:08:02 2014
@@ -84,7 +84,8 @@ class WikiPage(object):
:since 1.0: the `db` parameter is no longer needed and will be removed
in version 1.1.1
"""
- assert self.exists, "Cannot delete non-existent page"
+ if not self.exists:
+ raise TracError(_("Cannot delete non-existent page"))
with self.env.db_transaction as db:
if version is None:
@@ -168,7 +169,8 @@ class WikiPage(object):
Renaming a page this way will eventually leave dangling references
to the old page - which litterally doesn't exist anymore.
"""
- assert self.exists, "Cannot rename non-existent page"
+ if not self.exists:
+ raise TracError(_("Cannot rename non-existent page"))
if not validate_page_name(new_name):
raise TracError(_("Invalid Wiki page name '%(name)s'",
@@ -189,7 +191,7 @@ class WikiPage(object):
Attachment.reparent_all(self.env, 'wiki', old_name, 'wiki',
new_name)
- self.name = new_name
+ self.name = self.resource.id = new_name
self.env.log.info('Renamed page %s to %s', old_name, new_name)
for listener in WikiSystem(self.env).change_listeners:
Modified: bloodhound/vendor/trac/current/trac/wiki/templates/wiki_delete.html
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/templates/wiki_delete.html?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/templates/wiki_delete.html (original)
+++ bloodhound/vendor/trac/current/trac/wiki/templates/wiki_delete.html Thu Feb 13 05:08:02 2014
@@ -95,10 +95,11 @@
<strong>This is an irreversible operation.</strong>
</p>
<div class="buttons">
+ <input type="submit" class="trac-disable-on-submit"
+ value="${what == 'multiple' and _('Delete those versions')
+ or what == 'single' and _('Delete this version')
+ or _('Delete page')}" />
<input type="submit" name="cancel" value="${_('Cancel')}" />
- <input type="submit" value="${what == 'multiple' and _('Delete those versions')
- or what == 'single' and _('Delete this version')
- or _('Delete page')}" />
</div>
</form>
</div>
Modified: bloodhound/vendor/trac/current/trac/wiki/templates/wiki_edit.html
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/templates/wiki_edit.html?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/templates/wiki_edit.html (original)
+++ bloodhound/vendor/trac/current/trac/wiki/templates/wiki_edit.html Thu Feb 13 05:08:02 2014
@@ -39,9 +39,6 @@
$("#sidebyside").change(function() {
$("#edit input[type=submit][name=preview]").click();
});
- <py:if test="not sidebyside and (action == 'preview' or diff)">
- $("#info").scrollToTop();
- </py:if>
<py:if test="sidebyside">/*<![CDATA[*/
function editorHeight() {
return $("#text").closest("fieldset").innerHeight();
@@ -96,16 +93,6 @@
↓
</div>
<h1 i18n:msg="name">Editing ${name_of(page.resource)}</h1>
- <div py:if="merge" class="system-message">
- <p>Someone else has modified that page since you started your edits.</p><br />
- <p i18n:msg=""><b>If you save right away, you risk to revert those changes</b>
- (highlighted below as deletions).</p><br />
- <p i18n:msg="">Please review all those changes and manually merge them with your
- own changes. <br />
- If you're unsure about what you're doing, please press <tt>Cancel</tt>
- (losing your changes) and start editing the latest version of the page
- again.</p>
- </div>
<!--!
@@ -131,10 +118,26 @@
(the #preview will float at the right of the edit form's textarea)
-->
- <py:if test="not sidebyside"><xi:include href="wiki_edit_form.html" /></py:if>
<py:choose test="action">
+ <py:when test="'collision'">
+ <div class="system-message">
+ Sorry, this page has been modified by somebody else since you started
+ editing. Your changes cannot be saved.
+ </div>
+ </py:when>
+ <py:if test="not sidebyside"><xi:include href="wiki_edit_form.html" /></py:if>
+ <div py:if="merge" class="system-message">
+ <p>Someone else has modified that page since you started your edits.</p><br />
+ <p i18n:msg=""><b>If you save right away, you risk to revert those changes</b>
+ (highlighted below as deletions).</p><br />
+ <p i18n:msg="">Please review all those changes and manually merge them with your
+ own changes. <br />
+ If you're unsure about what you're doing, please press <tt>Cancel</tt>
+ (losing your changes) and start editing the latest version of the page
+ again.</p>
+ </div>
<py:when test="'preview'">
- <table id="info" summary="Revision info">
+ <table id="info" summary="Revision info" class="${'trac-scroll' if not sidebyside else None}">
<tbody>
<tr><th scope="col" i18n:msg="version, author">
Change information for future version ${page.version+1} (modified by $author):
@@ -158,7 +161,7 @@
<xi:include href="diff_div.html" py:with="no_id=True" />
</div>
<div py:otherwise="" class="wikipage" xml:space="preserve">
- ${wiki_to_html(context.child(page.resource), page.text)}
+ ${wiki_to_html(context, page.text)}
</div>
</div>
<div py:if="not sidebyside and page.text" class="trac-nav">
@@ -167,12 +170,6 @@
</div>
</div>
</py:when>
- <py:when test="'collision'">
- <div class="system-message">
- Sorry, this page has been modified by somebody else since you started
- editing. Your changes cannot be saved.
- </div>
- </py:when>
</py:choose>
<py:if test="sidebyside"><xi:include href="wiki_edit_form.html" /></py:if>
Modified: bloodhound/vendor/trac/current/trac/wiki/templates/wiki_edit_form.html
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/templates/wiki_edit_form.html?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/templates/wiki_edit_form.html (original)
+++ bloodhound/vendor/trac/current/trac/wiki/templates/wiki_edit_form.html Thu Feb 13 05:08:02 2014
@@ -26,7 +26,8 @@
</label>
<input type="checkbox" name="sidebyside" id="sidebyside" checked="$sidebyside" />
</div>
- <p><textarea id="text" class="wikitext${' trac-resizable' if not sidebyside else None}"
+ <p><textarea id="text" class="${classes('wikitext', 'trac-autofocus',
+ 'trac-resizable' if not sidebyside else None)}"
name="text" cols="80" rows="$edit_rows">
$page.text</textarea>
</p>
@@ -43,7 +44,7 @@ $page.text</textarea>
<input id="author" type="text" name="author" size="30" value="$author" />
</label>
<p py:if="author == 'anonymous'" class="hint">
- <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}">Preferences</a>.</i18n:msg>
+ <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}" class="trac-target-new">Preferences</a>.</i18n:msg>
</p>
</div>
<div class="field">
@@ -68,7 +69,7 @@ $page.text</textarea>
<py:otherwise>
<input type="submit" name="preview" value="${_('Preview Page')}" accesskey="p" />
<input type="submit" name="diff" value="${_('Review Changes')}" accesskey="r" />
- <input type="submit" id="save" name="save" value="${_('Submit changes')}" />
+ <input type="submit" id="save" name="save" class="trac-disable-on-submit" value="${_('Submit changes')}" />
</py:otherwise>
<input type="submit" name="cancel" value="${_('Cancel')}" />
</div>
Modified: bloodhound/vendor/trac/current/trac/wiki/templates/wiki_rename.html
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/templates/wiki_rename.html?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/templates/wiki_rename.html (original)
+++ bloodhound/vendor/trac/current/trac/wiki/templates/wiki_rename.html Thu Feb 13 05:08:02 2014
@@ -20,7 +20,7 @@
The complete history of the page will be moved to the new location.
</p>
<div class="field">
- <label>New name: <input type="text" name="new_name" size="40" value="$new_name"/></label>
+ <label>New name: <input type="text" name="new_name" class="trac-autofocus" size="40" value="$new_name"/></label>
</div>
<div class="field">
<label>
@@ -29,8 +29,8 @@
</label>
</div>
<div class="buttons">
+ <input type="submit" name="submit" class="trac-disable-on-submit" value="${_('Rename page')}"/>
<input type="submit" name="cancel" value="${_('Cancel')}"/>
- <input type="submit" name="submit" value="${_('Rename page')}"/>
</div>
</form>
</div>
Modified: bloodhound/vendor/trac/current/trac/wiki/templates/wiki_view.html
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/templates/wiki_view.html?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/templates/wiki_view.html (original)
+++ bloodhound/vendor/trac/current/trac/wiki/templates/wiki_view.html Thu Feb 13 05:08:02 2014
@@ -6,6 +6,7 @@
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:with="modify_perm = 'WIKI_MODIFY' in perm(page.resource);
+ create_perm = 'WIKI_CREATE' in perm(page.resource);
admin_perm = 'WIKI_ADMIN' in perm(page.resource);
is_not_latest = page.exists and page.version != latest_version">
<xi:include href="layout.html" />
@@ -78,21 +79,21 @@
<py:with vars="delete_perm = 'WIKI_DELETE' in perm(page.resource);
rename_perm = 'WIKI_RENAME' in perm(page.resource)">
- <py:if test="admin_perm or (not page.readonly and (modify_perm or delete_perm))">
+ <py:if test="admin_perm or (not page.readonly and (modify_perm or create_perm or delete_perm))">
<div class="buttons">
- <py:if test="modify_perm">
+ <py:if test="modify_perm or create_perm">
<form method="get" action="${href.wiki(page.name)}" id="modifypage">
<div>
<input type="hidden" name="action" value="edit" />
<py:choose>
- <py:when test="is_not_latest">
+ <py:when test="is_not_latest and modify_perm">
<input type="hidden" name="version" value="${page.version}"/>
<input type="submit" value="${_('Revert to this version')}"/>
</py:when>
- <py:when test="page.exists">
+ <py:when test="page.exists and modify_perm">
<input type="submit" value="${_('Edit this page')}" accesskey="e" />
</py:when>
- <py:otherwise>
+ <py:when test="not page.exists and create_perm">
<input type="submit" value="${_('Create this page')}" accesskey="e" />
<div py:if="templates" id="template">
<label for="template">Using the template:</label>
@@ -103,7 +104,7 @@
selected="${t == default_template or None}">$t</option>
</select>
</div>
- </py:otherwise>
+ </py:when>
</py:choose>
</div>
</form>
Modified: bloodhound/vendor/trac/current/trac/wiki/tests/__init__.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/tests/__init__.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/tests/__init__.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/tests/__init__.py Thu Feb 13 05:08:02 2014
@@ -1,3 +1,16 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2005-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
import doctest
import unittest
Modified: bloodhound/vendor/trac/current/trac/wiki/tests/formatter.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/tests/formatter.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/tests/formatter.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/tests/formatter.py Thu Feb 13 05:08:02 2014
@@ -1,3 +1,16 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2004-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
import difflib
import os
import re
@@ -14,7 +27,7 @@ except ImportError:
from datetime import datetime
-from trac.core import *
+from trac.core import Component, TracError, implements
from trac.test import Mock, MockPerm, EnvironmentStub, locale_en
from trac.util.datefmt import utc
from trac.util.html import html
@@ -88,6 +101,14 @@ class WikiProcessorSampleMacro(WikiMacro
''.join('<dt>%s</dt><dd>%s</dd>' % kv for kv in args.items()) \
+ content
+class ValueErrorWithUtf8Macro(WikiMacroBase):
+ def expand_macro(self, formatter, name, content, args):
+ raise ValueError(content.encode('utf-8'))
+
+class TracErrorWithUnicodeMacro(WikiMacroBase):
+ def expand_macro(self, formatter, name, content, args):
+ raise TracError(unicode(content))
+
class SampleResolver(Component):
"""A dummy macro returning a div block, used by the unit test."""
@@ -182,7 +203,7 @@ class WikiTestCase(unittest.TestCase):
v = v.replace('\r', '').replace(u'\u200b', '') # FIXME: keep ZWSP
v = strip_line_ws(v, leading=False)
try:
- self.assertEquals(self.correct, v)
+ self.assertEqual(self.correct, v)
except AssertionError, e:
msg = to_unicode(e)
match = re.match(r"u?'(.*)' != u?'(.*)'", msg)
Modified: bloodhound/vendor/trac/current/trac/wiki/tests/functional.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/tests/functional.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/tests/functional.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/tests/functional.py Thu Feb 13 05:08:02 2014
@@ -1,22 +1,71 @@
-#!/usr/bin/python
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2008-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
from trac.tests.functional import *
from trac.mimeview.rst import has_docutils
from trac.util import get_pkginfo
+try:
+ from configobj import ConfigObj
+except ImportError:
+ ConfigObj = None
+
+
class TestWiki(FunctionalTwillTestCaseSetup):
def runTest(self):
- """Create a wiki page and attach a file"""
- # TODO: this should be split into multiple tests
- pagename = random_unique_camel()
- self._tester.create_wiki_page(pagename)
- self._tester.attach_file_to_wiki(pagename)
+ """Create a wiki page."""
+ self._tester.create_wiki_page()
+
+
+class TestWikiAddAttachment(FunctionalTwillTestCaseSetup):
+ def runTest(self):
+ """Add attachment to a wiki page. Test that the attachment
+ button reads 'Attach file' when no files have been attached, and
+ 'Attach another file' when there are existing attachments.
+ Feature added in http://trac.edgewall.org/ticket/10281"""
+ name = self._tester.create_wiki_page()
+ self._tester.go_to_wiki(name)
+ tc.find("Attach file")
+ filename = self._tester.attach_file_to_wiki(name)
+
+ self._tester.go_to_wiki(name)
+ tc.find("Attach another file")
+ tc.find('Attachments <span class="trac-count">\(1\)</span>')
+ tc.find(filename)
+ tc.find('Download all attachments as:\s+<a rel="nofollow" '
+ 'href="/zip-attachment/wiki/%s/">.zip</a>' % name)
+
+
+class TestWikiHistory(FunctionalTwillTestCaseSetup):
+ """Create wiki page and navigate to page history."""
+ def runTest(self):
+ pagename = self._tester.create_wiki_page()
+ self._tester.edit_wiki_page(pagename)
+ tc.follow(r"\bHistory\b")
+ tc.url(self._tester.url + r'/wiki/%s\?action=history' % pagename)
+ version_link = '<td class="version">[ \t\n]*' \
+ '<a href="/wiki/%(pagename)s\?version=%%(version)s" ' \
+ 'title="View this version">%%(version)s[ \t\n]*</a>' \
+ % {'pagename': pagename}
+ tc.find(version_link % {'version': 1})
+ tc.find(version_link % {'version': 2})
class TestWikiRename(FunctionalTwillTestCaseSetup):
def runTest(self):
"""Test for simple wiki rename"""
- pagename = random_unique_camel()
- self._tester.create_wiki_page(pagename)
+ pagename = self._tester.create_wiki_page()
attachment = self._tester.attach_file_to_wiki(pagename)
base_url = self._tester.url
page_url = base_url + "/wiki/" + pagename
@@ -60,6 +109,10 @@ class TestWikiRename(FunctionalTwillTest
# check redirection page
tc.url(page_url)
tc.find("See.*/wiki/" + newpagename)
+ tc.find("The page %s has been renamed to %s."
+ % (pagename, newpagename))
+ tc.find("The page %s has been recreated with a redirect to %s."
+ % (pagename, newpagename))
# check whether attachment exists on the new page but not on old page
tc.go(base_url + '/attachment/wiki/' + newpagename + '/' + attachment)
tc.notfind("Error: Invalid Attachment")
@@ -73,6 +126,8 @@ class TestWikiRename(FunctionalTwillTest
tc.formvalue('rename-form', 'redirect', False)
tc.submit('submit')
tc.url(base_url + "/wiki/" + newpagename)
+ tc.find("The page %s has been renamed to %s."
+ % (pagename, newpagename))
# this time, the original page is gone
tc.go(page_url)
tc.url(page_url)
@@ -91,8 +146,7 @@ class RegressionTestTicket4812(Functiona
class ReStructuredTextWikiTest(FunctionalTwillTestCaseSetup):
def runTest(self):
"""Render reStructured text using a wikiprocessor"""
- pagename = random_unique_camel()
- self._tester.create_wiki_page(pagename, content="""
+ pagename = self._tester.create_wiki_page(content="""
{{{
#!rst
Hello
@@ -112,8 +166,7 @@ Hello
class ReStructuredTextCodeBlockTest(FunctionalTwillTestCaseSetup):
def runTest(self):
"""Render reStructured code block"""
- pagename = random_unique_camel()
- self._tester.create_wiki_page(pagename, content="""
+ pagename = self._tester.create_wiki_page(content="""
{{{
#!rst
.. code-block:: python
@@ -127,6 +180,54 @@ class ReStructuredTextCodeBlockTest(Func
tc.find('"123"')
+class RegressionTestTicket8976(FunctionalTwillTestCaseSetup):
+ def runTest(self):
+ """Test for regression of http://trac.edgewall.org/ticket/8976
+ Test fine grained permissions policy on wiki for specific page
+ versions."""
+ name = self._tester.create_wiki_page()
+ self._tester.edit_wiki_page(name)
+ self._tester.edit_wiki_page(name)
+ self._tester.logout()
+ self._tester.login('user')
+ try:
+ self._tester.go_to_wiki(name, 1)
+ tc.notfind(r"\bError: Forbidden\b")
+ self._tester.go_to_wiki(name, 2)
+ tc.notfind(r"\bError: Forbidden\b")
+ self._tester.go_to_wiki(name, 3)
+ tc.notfind(r"\bError: Forbidden\b")
+ self._tester.go_to_wiki(name, 4)
+ tc.find(r"\bTrac Error\b")
+ self._tester.go_to_wiki(name)
+ tc.notfind(r"\bError: Forbidden\b")
+ self._testenv.enable_authz_permpolicy("""
+ [wiki:%(name)s@1]
+ * = !WIKI_VIEW
+ [wiki:%(name)s@2]
+ * = WIKI_VIEW
+ [wiki:%(name)s@3]
+ * = !WIKI_VIEW
+ [wiki:%(name)s]
+ * = WIKI_VIEW
+ """ % {'name': name})
+ self._tester.go_to_wiki(name, 1)
+ tc.find(r"\bError: Forbidden\b")
+ self._tester.go_to_wiki(name, 2)
+ tc.notfind(r"\bError: Forbidden\b")
+ self._tester.go_to_wiki(name, 3)
+ tc.find(r"\bError: Forbidden\b")
+ self._tester.go_to_wiki(name, 4)
+ tc.find(r"\bTrac Error\b")
+ self._tester.go_to_wiki(name)
+ tc.notfind(r"\bError: Forbidden\b")
+ self._tester.edit_wiki_page(name)
+ finally:
+ self._tester.logout()
+ self._tester.login('admin')
+ self._testenv.disable_authz_permpolicy()
+
+
class RegressionTestTicket10274(FunctionalTwillTestCaseSetup):
def runTest(self):
"""Test for regression of http://trac.edgewall.org/ticket/10274"""
@@ -139,47 +240,127 @@ class RegressionTestTicket10274(Function
class RegressionTestTicket10850(FunctionalTwillTestCaseSetup):
-
def runTest(self):
"""Test for regression of http://trac.edgewall.org/ticket/10850"""
- pagename = random_unique_camel()
- self._tester.create_wiki_page(pagename)
+ pagename = self._tester.create_wiki_page()
# colon characters
attachment = self._tester.attach_file_to_wiki(
- pagename, tempfilename='2012-09-11_15:36:40-test.tbz2')
+ pagename, filename='2012-09-11_15:36:40-test.tbz2')
base_url = self._tester.url
tc.go(base_url + '/attachment/wiki/' + pagename +
'/2012-09-11_15:36:40-test.tbz2')
tc.notfind('Error: Invalid Attachment')
# backslash characters
attachment = self._tester.attach_file_to_wiki(
- pagename, tempfilename=r'/tmp/back\slash.txt')
+ pagename, filename=r'/tmp/back\slash.txt')
base_url = self._tester.url
tc.go(base_url + '/attachment/wiki/' + pagename + r'/back\slash.txt')
tc.notfind('Error: Invalid Attachment')
# Windows full path
attachment = self._tester.attach_file_to_wiki(
- pagename, tempfilename=r'z:\tmp\windows:path.txt')
+ pagename, filename=r'z:\tmp\windows:path.txt')
base_url = self._tester.url
tc.go(base_url + '/attachment/wiki/' + pagename + r'/windows:path.txt')
tc.notfind('Error: Invalid Attachment')
# Windows share folder path
attachment = self._tester.attach_file_to_wiki(
- pagename, tempfilename=r'\\server\share\file:name.txt')
+ pagename, filename=r'\\server\share\file:name.txt')
base_url = self._tester.url
tc.go(base_url + '/attachment/wiki/' + pagename + r'/file:name.txt')
tc.notfind('Error: Invalid Attachment')
+class RegressionTestTicket10957(FunctionalTwillTestCaseSetup):
+ def runTest(self):
+ """Test for regression of http://trac.edgewall.org/ticket/10957"""
+
+ self._tester.go_to_front()
+ try:
+ self._tester.logout()
+
+ # Check that page can't be created without WIKI_CREATE
+ page_name = random_unique_camel()
+ self._tester.go_to_wiki(page_name)
+ tc.find("Trac Error")
+ tc.find("Page %s not found" % page_name)
+ tc.notfind("Create this page")
+ tc.go(self._tester.url + '/wiki/%s?action=edit' % page_name)
+ tc.find("Error: Forbidden")
+ tc.find("WIKI_CREATE privileges are required to perform this "
+ "operation on %s. You don't have the required permissions."
+ % page_name)
+
+ # Check that page can be created when user has WIKI_CREATE
+ self._testenv.grant_perm('anonymous', 'WIKI_CREATE')
+ content_v1 = random_sentence()
+ self._tester.create_wiki_page(page_name, content_v1)
+ tc.find(content_v1)
+
+ # Check that page can't be edited without WIKI_MODIFY
+ tc.notfind("Edit this page")
+ tc.notfind("Attach file")
+ tc.go(self._tester.url + '/wiki/%s?action=edit' % page_name)
+ tc.find("Error: Forbidden")
+ tc.find("WIKI_MODIFY privileges are required to perform this "
+ "operation on %s. You don't have the required permissions."
+ % page_name)
+
+ # Check that page can be edited when user has WIKI_MODIFY
+ self._testenv.grant_perm('anonymous', 'WIKI_MODIFY')
+ self._tester.go_to_wiki(page_name)
+ tc.find("Edit this page")
+ tc.find("Attach file")
+ content_v2 = random_sentence()
+ self._tester.edit_wiki_page(page_name, content_v2)
+ tc.find(content_v2)
+
+ # Check that page can be reverted to a previous revision
+ tc.go(self._tester.url + '/wiki/%s?version=1' % page_name)
+ tc.find("Revert to this version")
+ tc.formvalue('modifypage', 'action', 'edit')
+ tc.submit()
+ tc.find(content_v1)
+
+ # Check that page can't be reverted without WIKI_MODIFY
+ self._tester.edit_wiki_page(page_name)
+ self._testenv.revoke_perm('anonymous', 'WIKI_MODIFY')
+ tc.go(self._tester.url + '/wiki/%s?version=1' % page_name)
+ tc.notfind("Revert to this version")
+ tc.go(self._tester.url + '/wiki/%s?action=edit&version=1' % page_name)
+ tc.find("WIKI_MODIFY privileges are required to perform this "
+ "operation on %s. You don't have the required permissions."
+ % page_name)
+
+ finally:
+ # Restore pre-test state.
+ self._tester.login('admin')
+ self._testenv.revoke_perm('anonymous', 'WIKI_CREATE')
+
+
+class RegressionTestTicket11302(FunctionalTwillTestCaseSetup):
+ def runTest(self):
+ """Test for regression of http://trac.edgewall.org/ticket/11302"""
+ pagename = self._tester.create_wiki_page()
+ attachment = self._tester.attach_file_to_wiki(
+ pagename, description="illustrates [./@1#point1]")
+ self._tester.go_to_wiki(pagename + '?action=edit')
+ tc.find(r'illustrates <a class="wiki"'
+ r' href="/wiki/%s\?version=1#point1">@1</a>' % pagename)
+
+
def functionalSuite(suite=None):
if not suite:
- import trac.tests.functional.testcases
- suite = trac.tests.functional.testcases.functionalSuite()
+ import trac.tests.functional
+ suite = trac.tests.functional.functionalSuite()
suite.addTest(TestWiki())
+ suite.addTest(TestWikiAddAttachment())
+ suite.addTest(TestWikiHistory())
suite.addTest(TestWikiRename())
suite.addTest(RegressionTestTicket4812())
suite.addTest(RegressionTestTicket10274())
suite.addTest(RegressionTestTicket10850())
+ suite.addTest(RegressionTestTicket10957())
+ suite.addTest(RegressionTestTicket11302())
if has_docutils:
import docutils
if get_pkginfo(docutils):
@@ -189,6 +370,10 @@ def functionalSuite(suite=None):
print "SKIP: reST wiki tests (docutils has no setuptools metadata)"
else:
print "SKIP: reST wiki tests (no docutils)"
+ if ConfigObj:
+ suite.addTest(RegressionTestTicket8976())
+ else:
+ print "SKIP: RegressionTestTicket8976 (ConfigObj not installed)"
return suite
Modified: bloodhound/vendor/trac/current/trac/wiki/tests/macros.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/tests/macros.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/tests/macros.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/tests/macros.py Thu Feb 13 05:08:02 2014
@@ -1,15 +1,54 @@
# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2006-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
+
+from StringIO import StringIO
from datetime import datetime
+import os
+import shutil
+import tempfile
import unittest
-from trac.config import Option
+from trac.config import Option, ListOption, IntOption, BoolOption
from trac.test import locale_en
from trac.util.datefmt import format_date, utc
from trac.wiki.model import WikiPage
from trac.wiki.tests import formatter
+
+def add_pages(tc, names):
+ now = datetime.now(utc)
+ for name in names:
+ w = WikiPage(tc.env)
+ w.name = name
+ w.text = '--'
+ w.save('joe', 'the page ' + name, '::1', now)
+
+
# == [[Image]]
+def image_setup(tc):
+ add_pages(tc, ['page:fr'])
+ from trac.attachment import Attachment
+ tc.env.path = tempfile.mkdtemp(prefix='trac-tempenv-')
+ attachment = Attachment(tc.env, 'wiki', 'page:fr')
+ attachment.description = "image in page:fr"
+ attachment.insert('img.png', StringIO(''), 0, 2)
+
+def image_teardown(tc):
+ shutil.rmtree(os.path.join(tc.env.path, 'files'))
+ os.rmdir(tc.env.path)
+ tc.env.reset_db()
+
# Note: using `« test »` string in the following tests for checking
# unicode robustness and whitespace support (first space is
# normal ASCII SPACE, second is Unicode NO-BREAK SPACE).
@@ -91,13 +130,39 @@ IMAGE_MACRO_TEST_CASES = u"""
------------------------------
<a style="padding:0; border:none" href="/wiki/WikiStart"><img src="/browser/%C2%AB%20test%C2%A0%C2%BB?format=raw" alt="/browser/« test »" title="/browser/« test »" /></a>
============================== Strip unicode white-spaces and ZWSPs (#10668)
-[[Image(â âsource:« test ».pngã â, nolink)]]
+[[Image(â âsource:« test ».pngã â, nolink, 100%ã â)]]
------------------------------
<p>
-<img src="/browser/%C2%AB%20test%C2%A0%C2%BB.png?format=raw" alt="source:« test ».png" title="source:« test ».png" />
+<img width="100%" alt="source:« test ».png" title="source:« test ».png" src="/browser/%C2%AB%20test%C2%A0%C2%BB.png?format=raw" />
</p>
------------------------------
-<img src="/browser/%C2%AB%20test%C2%A0%C2%BB.png?format=raw" alt="source:« test ».png" title="source:« test ».png" />
+<img width="100%" alt="source:« test ».png" title="source:« test ».png" src="/browser/%C2%AB%20test%C2%A0%C2%BB.png?format=raw" />
+------------------------------
+============================== Attachments on page with ':' characters (#10562)
+[[Image("page:fr":img.pngâ,nolink)]]
+------------------------------
+<p>
+<img src="/raw-attachment/wiki/page%3Afr/img.png" alt="image in page:fr" title="image in page:fr" />
+</p>
+------------------------------
+<img src="/raw-attachment/wiki/page%3Afr/img.png" alt="image in page:fr" title="image in page:fr" />
+------------------------------
+============================== htdocs: Image, nolink
+[[Image(htdocs:trac_logo.png, nolink)]]
+------------------------------
+<p>
+<img src="/chrome/site/trac_logo.png" alt="trac_logo.png" title="trac_logo.png" />
+</p>
+------------------------------
+<img src="/chrome/site/trac_logo.png" alt="trac_logo.png" title="trac_logo.png" />
+============================== shared: Image, nolink
+[[Image(shared:trac_logo.png, nolink)]]
+------------------------------
+<p>
+<img src="/chrome/shared/trac_logo.png" alt="trac_logo.png" title="trac_logo.png" />
+</p>
+------------------------------
+<img src="/chrome/shared/trac_logo.png" alt="trac_logo.png" title="trac_logo.png" />
------------------------------
"""
@@ -110,14 +175,6 @@ IMAGE_MACRO_TEST_CASES = u"""
# == [[TitleIndex]]
-def add_pages(tc, names):
- now = datetime.now(utc)
- for name in names:
- w = WikiPage(tc.env)
- w.name = name
- w.text = '--'
- w.save('joe', 'the page ' + name, '::1', now)
-
def titleindex_teardown(tc):
tc.env.reset_db()
@@ -391,8 +448,36 @@ TRACINI_MACRO_TEST_CASES = u"""\
</p><div class="tracini">\
<h3 id="section-42-section"><code>[section-42]</code></h3>\
<table class="wiki"><tbody>\
-<tr><td><tt>option1</tt></td><td></td><td class="default"><code>value</code></td></tr>\
-<tr><td><tt>option2</tt></td><td>blah</td><td class="default"><code>value</code></td></tr>\
+<tr class="even"><td><tt>option1</tt></td><td></td><td class="default"><code>value</code></td></tr>\
+<tr class="odd"><td><tt>option2</tt></td><td>blah</td><td class="default"><code>value</code></td></tr>\
+</tbody></table>\
+</div><p>
+</p>
+------------------------------
+============================== TracIni, list option with sep=| (#11074)
+[[TracIni(section-list)]]
+------------------------------
+<p>
+</p><div class="tracini">\
+<h3 id="section-list-section"><code>[section-list]</code></h3>\
+<table class="wiki"><tbody>\
+<tr class="even"><td><tt>option1</tt></td><td></td><td class="default"><code>4.2|42|42||0|enabled</code></td></tr>\
+</tbody></table>\
+</div><p>
+</p>
+------------------------------
+============================== TracIni, option with "false" value as default
+[[TracIni(section-def)]]
+------------------------------
+<p>
+</p><div class="tracini">\
+<h3 id="section-def-section"><code>[section-def]</code></h3>\
+<table class="wiki"><tbody>\
+<tr class="even"><td><tt>option1</tt></td><td></td><td class="nodefault">(no default)</td></tr>\
+<tr class="odd"><td><tt>option2</tt></td><td></td><td class="nodefault">(no default)</td></tr>\
+<tr class="even"><td><tt>option3</tt></td><td></td><td class="default"><code>0</code></td></tr>\
+<tr class="odd"><td><tt>option4</tt></td><td></td><td class="default"><code>disabled</code></td></tr>\
+<tr class="even"><td><tt>option5</tt></td><td></td><td class="default"><code></code></td></tr>\
</tbody></table>\
</div><p>
</p>
@@ -404,6 +489,13 @@ def tracini_setup(tc):
class Foo(object):
option_a1 = (Option)('section-42', 'option1', 'value', doc='')
option_a2 = (Option)('section-42', 'option2', 'value', doc='blah')
+ option_l1 = (ListOption)('section-list', 'option1',
+ [4.2, '42', 42, None, 0, True], sep='|')
+ option_d1 = (Option)('section-def', 'option1', None)
+ option_d2 = (Option)('section-def', 'option2', '')
+ option_d3 = (IntOption)('section-def', 'option3', 0)
+ option_d4 = (BoolOption)('section-def', 'option4', False)
+ option_d5 = (ListOption)('section-def', 'option5', [])
def tracini_teardown(tc):
Option.registry = tc._orig_registry
@@ -411,7 +503,9 @@ def tracini_teardown(tc):
def suite():
suite = unittest.TestSuite()
- suite.addTest(formatter.suite(IMAGE_MACRO_TEST_CASES, file=__file__))
+ suite.addTest(formatter.suite(IMAGE_MACRO_TEST_CASES, file=__file__,
+ setup=image_setup,
+ teardown=image_teardown))
suite.addTest(formatter.suite(TITLEINDEX1_MACRO_TEST_CASES, file=__file__))
suite.addTest(formatter.suite(TITLEINDEX2_MACRO_TEST_CASES, file=__file__,
setup=titleindex2_setup,
Modified: bloodhound/vendor/trac/current/trac/wiki/tests/model.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/tests/model.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/tests/model.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/tests/model.py Thu Feb 13 05:08:02 2014
@@ -1,9 +1,19 @@
# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2005-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
from __future__ import with_statement
from datetime import datetime
-import os.path
import shutil
from StringIO import StringIO
import tempfile
@@ -12,6 +22,7 @@ import unittest
from trac.attachment import Attachment
from trac.core import *
from trac.test import EnvironmentStub
+from trac.tests import compat
from trac.util.datefmt import utc, to_utimestamp
from trac.wiki import WikiPage, IWikiChangeListener
@@ -47,8 +58,7 @@ class WikiPageTestCase(unittest.TestCase
def setUp(self):
self.env = EnvironmentStub()
- self.env.path = os.path.join(tempfile.gettempdir(), 'trac-tempenv')
- os.mkdir(self.env.path)
+ self.env.path = tempfile.mkdtemp(prefix='trac-tempenv-')
def tearDown(self):
shutil.rmtree(self.env.path)
@@ -56,14 +66,14 @@ class WikiPageTestCase(unittest.TestCase
def test_new_page(self):
page = WikiPage(self.env)
- self.assertEqual(False, page.exists)
- self.assertEqual(None, page.name)
+ self.assertFalse(page.exists)
+ self.assertIsNone(page.name)
self.assertEqual(0, page.version)
self.assertEqual('', page.text)
self.assertEqual(0, page.readonly)
self.assertEqual('', page.author)
self.assertEqual('', page.comment)
- self.assertEqual(None, page.time)
+ self.assertIsNone(page.time)
def test_existing_page(self):
t = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
@@ -73,10 +83,10 @@ class WikiPageTestCase(unittest.TestCase
'Testing', 0))
page = WikiPage(self.env, 'TestPage')
- self.assertEqual(True, page.exists)
+ self.assertTrue(page.exists)
self.assertEqual('TestPage', page.name)
self.assertEqual(1, page.version)
- self.assertEqual(None, page.resource.version) # FIXME: Intentional?
+ self.assertIsNone(page.resource.version) # FIXME: Intentional?
self.assertEqual('Bla bla', page.text)
self.assertEqual(0, page.readonly)
self.assertEqual('joe', page.author)
@@ -97,7 +107,7 @@ class WikiPageTestCase(unittest.TestCase
t = datetime(2001, 1, 1, 1, 1, 1, 0, utc)
page.save('joe', 'Testing', '::1', t)
- self.assertEqual(True, page.exists)
+ self.assertTrue(page.exists)
self.assertEqual(1, page.version)
self.assertEqual(1, page.resource.version)
self.assertEqual(0, page.readonly)
@@ -164,7 +174,7 @@ class WikiPageTestCase(unittest.TestCase
page = WikiPage(self.env, 'TestPage')
page.delete()
- self.assertEqual(False, page.exists)
+ self.assertFalse(page.exists)
self.assertEqual([], self.env.db_query("""
SELECT version, time, author, ipnr, text, comment, readonly
@@ -183,7 +193,7 @@ class WikiPageTestCase(unittest.TestCase
page = WikiPage(self.env, 'TestPage')
page.delete(version=2)
- self.assertEqual(True, page.exists)
+ self.assertTrue(page.exists)
self.assertEqual(
[(1, 42, 'joe', '::1', 'Bla bla', 'Testing', 0)],
self.env.db_query("""
@@ -202,7 +212,7 @@ class WikiPageTestCase(unittest.TestCase
page = WikiPage(self.env, 'TestPage')
page.delete(version=1)
- self.assertEqual(False, page.exists)
+ self.assertFalse(page.exists)
self.assertEqual([], self.env.db_query("""
SELECT version, time, author, ipnr, text, comment, readonly
@@ -223,6 +233,7 @@ class WikiPageTestCase(unittest.TestCase
page = WikiPage(self.env, 'TestPage')
page.rename('PageRenamed')
self.assertEqual('PageRenamed', page.name)
+ self.assertEqual('PageRenamed', page.resource.id)
self.assertEqual([data], self.env.db_query("""
SELECT version, time, author, ipnr, text, comment, readonly
@@ -235,8 +246,7 @@ class WikiPageTestCase(unittest.TestCase
Attachment.delete_all(self.env, 'wiki', 'PageRenamed')
old_page = WikiPage(self.env, 'TestPage')
- self.assertEqual(False, old_page.exists)
-
+ self.assertFalse(old_page.exists)
self.assertEqual([], self.env.db_query("""
SELECT version, time, author, ipnr, text, comment, readonly
@@ -268,7 +278,7 @@ class WikiPageTestCase(unittest.TestCase
def suite():
- return unittest.makeSuite(WikiPageTestCase, 'test')
+ return unittest.makeSuite(WikiPageTestCase)
if __name__ == '__main__':
unittest.main(defaultTest='suite')
Modified: bloodhound/vendor/trac/current/trac/wiki/tests/wiki-tests.txt
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/tests/wiki-tests.txt?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/tests/wiki-tests.txt (original)
+++ bloodhound/vendor/trac/current/trac/wiki/tests/wiki-tests.txt Thu Feb 13 05:08:02 2014
@@ -316,6 +316,13 @@ nolink:"<blink>"
nolink:"<blink>"
</p>
------------------------------
+============================== Bracketed links
+See <http://en.wikipedia.org/wiki/Mornington_Crescent_(game)>
+------------------------------
+<p>
+See <<a class="ext-link" href="http://en.wikipedia.org/wiki/Mornington_Crescent_(game)"><span class="icon"></span>http://en.wikipedia.org/wiki/Mornington_Crescent_(game)</a>>
+</p>
+------------------------------
============================================================
Other Links
@@ -1168,6 +1175,27 @@ Inline comment
</p>
------------------------------
Inline comment
+============================== Exception with ascii bytes
+[[ValueErrorWithUtf8(error)]]
+------------------------------
+<p>
+<div class="system-message"><strong>Error: Macro ValueErrorWithUtf8(error) failed</strong><pre>error</pre></div>
+</p>
+------------------------------
+============================== Exception with utf-8 bytes
+[[ValueErrorWithUtf8(érrör)]]
+------------------------------
+<p>
+<div class="system-message"><strong>Error: Macro ValueErrorWithUtf8(érrör) failed</strong><pre>érrör</pre></div>
+</p>
+------------------------------
+============================== TracError with unicode
+[[TracErrorWithUnicode(érrör)]]
+------------------------------
+<p>
+<div class="system-message"><strong>Error: Macro TracErrorWithUnicode(érrör) failed</strong><pre>érrör</pre></div>
+</p>
+------------------------------
============================================================
Headings
Modified: bloodhound/vendor/trac/current/trac/wiki/tests/wikisyntax.py
URL: http://svn.apache.org/viewvc/bloodhound/vendor/trac/current/trac/wiki/tests/wikisyntax.py?rev=1567849&r1=1567848&r2=1567849&view=diff
==============================================================================
--- bloodhound/vendor/trac/current/trac/wiki/tests/wikisyntax.py (original)
+++ bloodhound/vendor/trac/current/trac/wiki/tests/wikisyntax.py Thu Feb 13 05:08:02 2014
@@ -1,4 +1,15 @@
# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2006-2013 Edgewall Software
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at http://trac.edgewall.org/wiki/TracLicense.
+#
+# This software consists of voluntary contributions made by many
+# individuals. For the exact contribution history, see the revision
+# history and logs, available at http://trac.edgewall.org/log/.
from datetime import datetime
import unittest
@@ -711,6 +722,8 @@ nolink http://noweb
w.text = '--'
w.save('joe', 'other third level of hierarchy', '::1', now)
+ tc.env.db_transaction("INSERT INTO ticket (id) VALUES ('123')")
+
def wiki_teardown(tc):
tc.env.reset_db()