Return-Path: X-Original-To: apmail-incubator-bloodhound-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-bloodhound-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 19563EF2E for ; Mon, 21 Jan 2013 12:26:06 +0000 (UTC) Received: (qmail 99435 invoked by uid 500); 21 Jan 2013 12:26:05 -0000 Delivered-To: apmail-incubator-bloodhound-commits-archive@incubator.apache.org Received: (qmail 99340 invoked by uid 500); 21 Jan 2013 12:26:02 -0000 Mailing-List: contact bloodhound-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bloodhound-dev@incubator.apache.org Delivered-To: mailing list bloodhound-commits@incubator.apache.org Received: (qmail 99308 invoked by uid 99); 21 Jan 2013 12:26:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Jan 2013 12:26:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Jan 2013 12:25:58 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A29632388900; Mon, 21 Jan 2013 12:25:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: bloodhound-commits@incubator.apache.org From: jure@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130121122538.A29632388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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/` 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([