Commits

Olemis Lang committed b5ec69c

BH Multiproduct #757 : Ensure that multiproduct DB version is set to latest after upgrading EnvironmentStub

  • Participants
  • Parent commits ffa6286
  • Branches t757_tracadmin_help_v2

Comments (0)

Files changed (1)

t757/t757_r1570616_product_help.tests.diff

 
 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:34:52 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
 +
 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:34:52 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_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)