You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bloodhound.apache.org by ju...@apache.org on 2013/02/25 15:59:53 UTC
svn commit: r1449737 - in
/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct:
multiproduct/env.py tests/wiki/formatter.py tests/wikisyntax.py
Author: jure
Date: Mon Feb 25 14:59:52 2013
New Revision: 1449737
URL: http://svn.apache.org/r1449737
Log:
#355, wiki syntex extensions test cases, patch t355_r1444754_trac_test_core_wikisyntax.diff applied (from Olemis)
Added:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wikisyntax.py
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/formatter.py
Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py?rev=1449737&r1=1449736&r2=1449737&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py Mon Feb 25 14:59:52 2013
@@ -193,48 +193,6 @@ class ProductEnvironment(Component, Comp
implements(trac.env.ISystemInfoProvider)
- def __getitem__(self, cls):
- if issubclass(cls, trac.env.Environment):
- return self.parent
- elif cls is self.__class__:
- return self
- else:
- return ComponentManager.__getitem__(self, cls)
-
- def __getattr__(self, attrnm):
- """Forward attribute access request to parent environment.
-
- Initially this will affect the following members of
- `trac.env.Environment` class:
-
- system_info_providers, secure_cookies, project_admin_trac_url,
- get_system_info, get_version, get_templates_dir, get_templates_dir,
- get_log_dir, backup
- """
- try:
- if attrnm in ('parent', '_rules'):
- raise AttributeError
- return getattr(self.parent, attrnm)
- except AttributeError:
- raise AttributeError("'%s' object has no attribute '%s'" %
- (self.__class__.__name__, attrnm))
-
- def __repr__(self):
- return "<%s %s at %s>" % (self.__class__.__name__,
- repr(self.product.prefix),
- hex(id(self)))
-
- @lazy
- def path(self):
- """The subfolder `./products/<product prefix>` relative to the
- top-level directory of the global environment will be the root of
- product file system area.
- """
- folder = os.path.join(self.parent.path, 'products', self.product.prefix)
- if not os.path.exists(folder):
- os.makedirs(folder)
- return folder
-
@property
def setup_participants(self):
"""Setup participants list for product environments will always
@@ -384,6 +342,48 @@ class ProductEnvironment(Component, Comp
self.setup_config()
+ def __getitem__(self, cls):
+ if issubclass(cls, trac.env.Environment):
+ return self.parent
+ elif cls is self.__class__:
+ return self
+ else:
+ return ComponentManager.__getitem__(self, cls)
+
+ def __getattr__(self, attrnm):
+ """Forward attribute access request to parent environment.
+
+ Initially this will affect the following members of
+ `trac.env.Environment` class:
+
+ system_info_providers, secure_cookies, project_admin_trac_url,
+ get_system_info, get_version, get_templates_dir, get_templates_dir,
+ get_log_dir, backup
+ """
+ try:
+ if attrnm in ('parent', '_rules'):
+ raise AttributeError
+ return getattr(self.parent, attrnm)
+ except AttributeError:
+ raise AttributeError("'%s' object has no attribute '%s'" %
+ (self.__class__.__name__, attrnm))
+
+ def __repr__(self):
+ return "<%s %s at %s>" % (self.__class__.__name__,
+ repr(self.product.prefix),
+ hex(id(self)))
+
+ @lazy
+ def path(self):
+ """The subfolder `./products/<product prefix>` relative to the
+ top-level directory of the global environment will be the root of
+ product file system area.
+ """
+ folder = os.path.join(self.parent.path, 'products', self.product.prefix)
+ if not os.path.exists(folder):
+ os.makedirs(folder)
+ return folder
+
# ISystemInfoProvider methods
# Same as parent environment's . Avoid duplicated code
Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/formatter.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/formatter.py?rev=1449737&r1=1449736&r2=1449737&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/formatter.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wiki/formatter.py Mon Feb 25 14:59:52 2013
@@ -60,7 +60,11 @@ class ProductWikiTestCase(formatter.Wiki
def tearDown(self):
self.global_env.reset_db()
- self.global_env = self._env = None
+ try:
+ if self._teardown:
+ self._teardown(self)
+ finally:
+ self.global_env = self._env = None
def __init__(self, title, input, correct, file, line, setup=None,
teardown=None, context=None):
Added: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wikisyntax.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wikisyntax.py?rev=1449737&view=auto
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wikisyntax.py (added)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/wikisyntax.py Mon Feb 25 14:59:52 2013
@@ -0,0 +1,72 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests for Apache(TM) Bloodhound's core wiki syntax in product environments"""
+
+import os.path
+import re
+import shutil
+import tempfile
+import unittest
+
+from trac.attachment import Attachment
+from trac.tests import wikisyntax
+
+from multiproduct.env import ProductEnvironment
+from tests.env import MultiproductTestCase
+from tests.wiki import formatter
+
+def attachment_setup(tc):
+ import trac.ticket.api
+ import trac.wiki.api
+ tc.global_env.path = os.path.join(tempfile.gettempdir(), 'trac-tempenv')
+ del tc.env.path
+ attachment = Attachment(tc.env, 'wiki', 'WikiStart')
+ attachment.insert('file.txt', tempfile.TemporaryFile(), 0)
+ attachment = Attachment(tc.env, 'ticket', 123)
+ attachment.insert('file.txt', tempfile.TemporaryFile(), 0)
+ attachment = Attachment(tc.env, 'wiki', 'SomePage/SubPage')
+ attachment.insert('foo.txt', tempfile.TemporaryFile(), 0)
+
+def attachment_teardown(tc):
+ shutil.rmtree(tc.global_env.path)
+ tc.global_env.reset_db()
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(formatter.test_suite(wikisyntax.SEARCH_TEST_CASES,
+ file=wikisyntax.__file__))
+ suite.addTest(formatter.test_suite(wikisyntax.ATTACHMENT_TEST_CASES,
+ file=wikisyntax.__file__,
+ context=('wiki', 'WikiStart'),
+ setup=attachment_setup,
+ teardown=attachment_teardown))
+ suite.addTest(formatter.test_suite(wikisyntax.EMAIL_TEST_CASE_DEFAULT,
+ file=wikisyntax.__file__,
+ context=wikisyntax.email_default_context()))
+ suite.addTest(formatter.test_suite(wikisyntax.EMAIL_TEST_CASE_NEVER_OBFUSCATE,
+ file=wikisyntax.__file__,
+ context=wikisyntax.email_default_context(),
+ setup=wikisyntax.email_never_obfuscate_setup))
+ return suite
+
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
+