incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1436300 - in /incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct: multiproduct/env.py tests/attachment.py tests/env.py
Date Mon, 21 Jan 2013 12:25:38 GMT
Author: jure
Date: Mon Jan 21 12:25:38 2013
New Revision: 1436300

URL: http://svn.apache.org/viewvc?rev=1436300&view=rev
Log:
#355 patch t355_r1434677_trac_test_attachments.diff applied (from Olemis)


Added:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/attachment.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=1436300&r1=1436299&r2=1436300&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 Jan 21 12:25:38 2013
@@ -137,6 +137,14 @@ class ProductEnvironment(Component, Comp
             raise AttributeError("'%s' object has no attribute '%s'" %
                     (self.__class__.__name__, attrnm))
 
+    @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.
+        """
+        return os.path.join(self.parent.path, 'products', self.product.prefix)
+
     @property
     def setup_participants(self):
         """Setup participants list for product environments will always
@@ -267,7 +275,6 @@ class ProductEnvironment(Component, Comp
 
         self.parent = env
         self.product = product
-        self.path = self.parent.path
         self.systeminfo = []
         self._href = self._abs_href = None
 

Added: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/attachment.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/attachment.py?rev=1436300&view=auto
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/attachment.py
(added)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/attachment.py
Mon Jan 21 12:25:38 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 attachments in product environments"""
+
+import shutil
+import os.path
+import unittest
+
+from trac.attachment import Attachment
+from trac.test import EnvironmentStub
+from trac.tests.attachment import AttachmentTestCase
+
+from multiproduct.env import ProductEnvironment
+from tests.env import MultiproductTestCase
+
+class ProductAttachmentTestCase(AttachmentTestCase, MultiproductTestCase):
+
+    def setUp(self):
+        try:
+            AttachmentTestCase.setUp(self)
+        except:
+            self.global_env = self.env
+            self.tearDown()
+            raise
+        else:
+            self.global_env = global_env = self.env
+            self._upgrade_mp(global_env)
+            self._setup_test_log(global_env)
+            self._load_product_from_data(global_env, self.default_product)
+            self.env = ProductEnvironment(global_env, self.default_product)
+            os.makedirs(self.env.path)
+
+            # Root folder for default product environment
+            self.attachments_dir = os.path.join(self.global_env.path,
+                    'products', self.default_product, 'files', 'attachments')
+
+    def tearDown(self):
+        if os.path.exists(self.global_env.path):
+            shutil.rmtree(self.global_env.path)
+        self.env.reset_db()
+
+    def test_product_path_isolation(self):
+        product_attachment = Attachment(self.env, 'ticket', '42')
+        global_attachment = Attachment(self.global_env, 'ticket', '42')
+        global_attachment.filename = product_attachment.filename = 'foo.txt'
+
+        self.assertNotEqual(product_attachment.path, global_attachment.path)
+
+def test_suite():
+    return unittest.TestSuite([
+            unittest.makeSuite(ProductAttachmentTestCase,'test'),
+        ])
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+

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=1436300&r1=1436299&r2=1436300&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 Jan 21 12:25:38 2013
@@ -209,6 +209,11 @@ class ProductEnvApiTestCase(Multiproduct
         self._mp_setup()
         self.product_env = ProductEnvironment(self.env, self.default_product)
 
+    def tearDown(self):
+        # Release reference to transient environment mock object
+        self.env = None
+        self.product_env = None
+
     def test_attr_forward_parent(self):
         """Testing env.__getattr__"""
         class EnvironmentAttrSandbox(EnvironmentStub):
@@ -336,10 +341,10 @@ class ProductEnvApiTestCase(Multiproduct
         self.assertIsNot(global_env[C], None)
         self.assertIs(product_env[C], None)
 
-    def tearDown(self):
-        # Release reference to transient environment mock object
-        self.env = None
-        self.product_env = None
+    def test_path(self):
+        """Testing env.path"""
+        self.assertEqual(self.product_env.path, 
+                os.path.join(self.env.path, 'products', self.default_product))
 
 def test_suite():
     return unittest.TestSuite([



Mime
View raw message