Commits

Olemis Lang committed bfb45d2 Merge

BH Multiproduct #756 : Merge [4217117166c4] [b5ec69c3b4df] : Incorporating patches with test cases for #757

  • Participants
  • Parent commits 4217117, b5ec69c
  • Branches t756_admin_failmsg

Comments (0)

Files changed (3)

 t756/t756_r1567795_product_admin_failmsg.diff
+t757/t757_r1570616_product_help.diff
+t757/t757_r1570616_product_help.tests.diff

File t757/t757_r1570616_product_help.diff

+# HG changeset patch
+# Parent 9dd1c8a171d0402b39d803dbd27eb7a85f47d2a2
+BH Multiproduct #757 : Activate help command in products
+
+diff -r 9dd1c8a171d0 bloodhound_multiproduct/multiproduct/product_admin.py
+--- a/bloodhound_multiproduct/multiproduct/product_admin.py	Fri Feb 21 16:11:20 2014 +0000
++++ b/bloodhound_multiproduct/multiproduct/product_admin.py	Fri Feb 21 14:52:13 2014 -0500
+@@ -301,7 +301,7 @@
+             mgr = self.product_admincmd_mgr(args[0])
+             return mgr.complete_command(args[1:])
+ 
+-    GLOBAL_COMMANDS = ('deploy', 'help', 'hotcopy', 'initenv', 'upgrade')
++    GLOBAL_COMMANDS = ('deploy', 'hotcopy', 'initenv', 'upgrade')
+ 
+     def _do_product_admin(self, prefix, *args):
+         mgr = self.product_admincmd_mgr(prefix)

File t757/t757_r1570616_product_help.tests.diff

+# HG changeset patch
+# Parent ae6dbe8b4386d9ac58e2dbe5c929713038fa434c
+BH Multiproduct #757 : Tests for help command activated in products
+
+diff -r ae6dbe8b4386 bloodhound_multiproduct/tests/admin/console-tests.txt
+--- a/bloodhound_multiproduct/tests/admin/console-tests.txt	Fri Feb 21 14:52:13 2014 -0500
++++ b/bloodhound_multiproduct/tests/admin/console-tests.txt	Sat Feb 22 12:36:32 2014 -0500
+@@ -1022,3 +1022,29 @@
+ name18  0     2010-01-19  val18  val18
+ name19  0     2010-01-20  val19  val19
+ 
++===== test_product_help_version =====
++version add <name> [time]
++
++    Add version
++
++version list 
++
++    Show versions
++
++version remove <name>
++
++    Remove version
++
++version rename <name> <newname>
++
++    Rename version
++
++version time <name> <time>
++
++    Set version date
++
++===== test_product_help_version_add =====
++version add <name> [time]
++
++    Add version
++
+diff -r ae6dbe8b4386 bloodhound_multiproduct/tests/admin/console.py
+--- a/bloodhound_multiproduct/tests/admin/console.py	Fri Feb 21 14:52:13 2014 -0500
++++ b/bloodhound_multiproduct/tests/admin/console.py	Sat Feb 22 12:36:32 2014 -0500
+@@ -89,6 +89,22 @@
+             sys.stderr = _err
+             sys.stdout = _out
+ 
++    def test_product_help_version(self):
++        self._admin.env_set('', self.global_env)
++        rv, output = self._execute('product admin %s help version' %
++                                   self.default_product)
++        self.assertEqual(0, rv)
++        expected = self.expected_results[self._testMethodName]
++        self.assertEqual(expected, output)
++
++    def test_product_help_version_add(self):
++        self._admin.env_set('', self.global_env)
++        rv, output = self._execute('product admin %s help version add' %
++                                   self.default_product)
++        self.assertEqual(0, rv)
++        expected = self.expected_results[self._testMethodName]
++        self.assertEqual(expected, output)
++
+ 
+ def test_suite():
+     return unittest.TestSuite([
+diff -r ae6dbe8b4386 bloodhound_multiproduct/tests/env.py
+--- a/bloodhound_multiproduct/tests/env.py	Fri Feb 21 14:52:13 2014 -0500
++++ b/bloodhound_multiproduct/tests/env.py	Sat Feb 22 12:36:32 2014 -0500
+@@ -38,7 +38,7 @@
+ from trac.util.text import to_unicode
+ from trac.web.href import Href
+ 
+-from multiproduct.api import MultiProductSystem
++from multiproduct.api import DB_VERSION, MultiProductSystem
+ from multiproduct.env import ProductEnvironment
+ from multiproduct.model import Product
+ 
+@@ -232,12 +232,16 @@
+         EnvironmentStub.disable_component_in_config(env, ReportModule)
+ 
+         mpsystem = MultiProductSystem(env)
+-        try:
+-            mpsystem.upgrade_environment(env.db_transaction)
+-        except env.db_exc.OperationalError:
+-            # Database is upgraded, but database version was deleted.
+-            # Complete the upgrade by inserting default product.
+-            mpsystem._insert_default_product(env.db_transaction)
++        with env.db_transaction as db:
++            try:
++                mpsystem.upgrade_environment(db)
++            except env.db_exc.OperationalError:
++                # Database is upgraded, but database version was deleted.
++                # Complete the upgrade by inserting default product.
++                mpsystem._insert_default_product(db)
++            finally:
++                # Ensure that multiproduct DB version is set to latest value
++                mpsystem._update_db_version(db, DB_VERSION)
+         # assume that the database schema has been upgraded, enable
+         # multi-product schema support in environment
+         env.enable_multiproduct_schema(True)