Author: jure
Date: Mon Feb 11 10:24:23 2013
New Revision: 1444725
URL: http://svn.apache.org/r1444725
Log:
#355, ticket model tests, patch t355_r1442601_trac_test_ticket_model.patch
applied (from Olemis)
Added:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/model.py
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/env.py
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/env.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=1444725&r1=1444724&r2=1444725&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 11 10:24:23 2013
@@ -105,7 +105,7 @@ class EnvironmentStub(trac.test.Environm
self.parent = None
self.product = None
self.mpsystem = None
- super(EnvironmentStub, self).__init__(default_data=default_data,
+ super(EnvironmentStub, self).__init__(default_data=False,
enable=enable, disable=disable,
path=path, destroying=destroying)
# Apply multi product upgrades. This is required as the database proxy
(translator)
@@ -117,6 +117,9 @@ class EnvironmentStub(trac.test.Environm
except OperationalError:
pass
+ if default_data:
+ self.reset_db(default_data)
+
@staticmethod
def enable_component_in_config(env, cls):
"""Keep track of enabled state in configuration as well
Modified:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/env.py
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/env.py?rev=1444725&r1=1444724&r2=1444725&view=diff
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/env.py
(original)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/env.py
Mon Feb 11 10:24:23 2013
@@ -117,13 +117,14 @@ class MultiproductTestCase(unittest.Test
# Test setup
- def _setup_test_env(self, create_folder=True, path=None):
+ def _setup_test_env(self, create_folder=True, path=None, **kwargs):
r"""Prepare a new test environment .
Optionally set its path to a meaningful location (temp folder
if `path` is `None`).
"""
- self.env = env = EnvironmentStub(enable=['trac.*', 'multiproduct.*'])
+ kwargs.setdefault('enable', ['trac.*', 'multiproduct.*'])
+ self.env = env = EnvironmentStub(**kwargs)
if create_folder:
if path is None:
env.path = tempfile.mkdtemp('bh-product-tempenv')
@@ -172,6 +173,20 @@ class MultiproductTestCase(unittest.Test
# table remains but database version is deleted
pass
+ def _load_default_data(self, env):
+ r"""Initialize environment with default data by respecting
+ values set in system table.
+ """
+ from trac import db_default
+
+ with env.db_transaction as db:
+ for table, cols, vals in db_default.get_data(db):
+ if table != 'system':
+ db.executemany('INSERT INTO %s (%s) VALUES (%s)' %
+ (table, ','.join(cols),
+ ','.join(['%s' for c in cols])),
+ vals)
+
def _mp_setup(self):
"""Shortcut for quick product-aware environment setup.
"""
Added:
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/model.py
URL:
http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/model.py?rev=1444725&view=auto
==============================================================================
---
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/model.py
(added)
+++
incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/model.py
Mon Feb 11 10:24:23 2013
@@ -0,0 +1,62 @@
+
+# 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 tickets model in product environments"""
+
+import unittest
+
+from trac.ticket.tests.model import TicketTestCase, TicketCommentTestCase, \
+ TicketCommentEditTestCase, TicketCommentDeleteTestCase, EnumTestCase, \
+ MilestoneTestCase, ComponentTestCase, VersionTestCase
+
+from multiproduct.env import ProductEnvironment
+from tests.env import MultiproductTestCase
+
+class ProductTicketTestCase(TicketTestCase, MultiproductTestCase):
+
+ def setUp(self):
+ self.global_env = self._setup_test_env(create_folder=False,
+ default_data=True)
+ self._upgrade_mp(self.global_env)
+ self._setup_test_log(self.global_env)
+ self._load_product_from_data(self.global_env, self.default_product)
+ self.env = ProductEnvironment(self.global_env, self.default_product)
+ self._load_default_data(self.env)
+
+ self.env.config.set('ticket-custom', 'foo', 'text')
+ self.env.config.set('ticket-custom', 'cbon', 'checkbox')
+ self.env.config.set('ticket-custom', 'cboff', 'checkbox')
+
+ def tearDown(self):
+ self.global_env.reset_db()
+
+
+def test_suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(ProductTicketTestCase, 'test'))
+# suite.addTest(unittest.makeSuite(ProductTicketCommentEditTestCase,
'test'))
+# suite.addTest(unittest.makeSuite(ProductTicketCommentDeleteTestCase,
'test'))
+# suite.addTest(unittest.makeSuite(ProductEnumTestCase, 'test'))
+# suite.addTest(unittest.makeSuite(ProductMilestoneTestCase, 'test'))
+# suite.addTest(unittest.makeSuite(ProductComponentTestCase, 'test'))
+# suite.addTest(unittest.makeSuite(ProductVersionTestCase, 'test'))
+ return suite
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='test_suite')
+