incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1444713 - in /incubator/bloodhound/branches/bep_0003_multiproduct: bloodhound_multiproduct/tests/env.py bloodhound_multiproduct/tests/ticket/conversion.py trac/trac/web/chrome.py
Date Mon, 11 Feb 2013 10:09:16 GMT
Author: jure
Date: Mon Feb 11 10:09:16 2013
New Revision: 1444713

URL: http://svn.apache.org/r1444713
Log:
#355, patch t355_r1442601_trac_test_ticket_conversion.diff applied (from Olemis), test cases
for ticket MIME conversions


Added:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/conversion.py
Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/env.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/chrome.py

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=1444713&r1=1444712&r2=1444713&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:09:16 2013
@@ -161,8 +161,10 @@ class MultiproductTestCase(unittest.Test
     def _upgrade_mp(self, env):
         r"""Apply multi product upgrades
         """
+        # Do not break wiki parser ( see #373 )
         env.disable_component(TicketModule)
         env.disable_component(ReportModule)
+
         self.mpsystem = MultiProductSystem(env)
         try:
             self.mpsystem.upgrade_environment(env.db_transaction)

Added: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/conversion.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/conversion.py?rev=1444713&view=auto
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/conversion.py
(added)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/ticket/conversion.py
Mon Feb 11 10:09:16 2013
@@ -0,0 +1,87 @@
+
+#  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 MIME conversions for tickets in
+product environments"""
+
+import os.path
+import unittest
+
+from trac.test import Mock
+from trac.mimeview.api import Mimeview
+from trac.ticket.tests.conversion import TicketConversionTestCase
+from trac.web.href import Href
+
+from multiproduct.ticket.web_ui import ProductTicketModule
+from multiproduct.env import ProductEnvironment
+from tests.env import MultiproductTestCase
+
+class ProductTicketConversionTestCase(TicketConversionTestCase, \
+        MultiproductTestCase):
+
+    def setUp(self):
+        self._mp_setup()
+        self.global_env = self.env
+        self.env = ProductEnvironment(self.global_env, self.default_product)
+
+        # Product name inserted in RSS feed
+        self.env.product._data['name'] = 'My Project'
+
+        self.env.config.set('trac', 'templates_dir',
+                            os.path.join(os.path.dirname(self.env.path),
+                                         'templates'))
+        self.ticket_module = ProductTicketModule(self.env)
+        self.mimeview = Mimeview(self.env)
+        self.req = Mock(base_path='/trac.cgi', path_info='',
+                        href=Href('/trac.cgi'), chrome={'logo': {}},
+                        abs_href=Href('http://example.org/trac.cgi'),
+                        environ={}, perm=[], authname='-', args={}, tz=None,
+                        locale='', session=None, form_token=None)
+
+    def test_csv_conversion(self):
+        ticket = self._create_a_ticket()
+        csv = self.mimeview.convert_content(self.req, 'trac.ticket.Ticket',
+                                            ticket, 'csv')
+        self.assertEqual(('\xef\xbb\xbf'
+                          'id,summary,reporter,owner,description,status,'
+                          'product,keywords,cc\r'
+                          '\n1,Foo,santa,,Bar,,,,\r\n',
+                          'text/csv;charset=utf-8', 'csv'), csv)
+
+    def test_tab_conversion(self):
+        ticket = self._create_a_ticket()
+        csv = self.mimeview.convert_content(self.req, 'trac.ticket.Ticket',
+                                            ticket, 'tab')
+        self.assertEqual(('\xef\xbb\xbf'
+                          'id\tsummary\treporter\towner\tdescription\tstatus\t'
+                          'product\tkeywords\tcc\r\n'
+                          '1\tFoo\tsanta\t\tBar\t\t\t\t\r\n',
+                          'text/tab-separated-values;charset=utf-8', 'tsv'),
+                         csv)
+
+    def tearDown(self):
+        self.global_env.reset_db()
+
+def test_suite():
+    return unittest.TestSuite([
+            unittest.makeSuite(ProductTicketConversionTestCase,'test'),
+        ])
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/chrome.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/chrome.py?rev=1444713&r1=1444712&r2=1444713&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/chrome.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/chrome.py Mon Feb 11
10:09:16 2013
@@ -803,7 +803,7 @@ class Chrome(Component):
     def populate_data(self, req, data):
         d = self._default_context_data.copy()
         d['trac'] = {
-            'version': pkg_resources.resource_string('trac', 'TRAC_VERSION'),
+            'version': pkg_resources.resource_string('trac', 'TRAC_VERSION').strip(),
             'homepage': 'http://trac.edgewall.org/', # FIXME: use setup data
         }
         



Mime
View raw message