1. Olemis Lang
  2. bloodhound-mq

Commits

Olemis Lang  committed 45b961d

BH Multiproduct #115 : Assertions for message of exception raised in ProductEnvironment initializer

  • Participants
  • Parent commits 389d7ff
  • Branches t115_bep3_product_env

Comments (0)

Files changed (1)

File t115/t115_r1431447_product_envs_bep3_p1.diff

View file
 # HG changeset patch
-# Parent 00a5e8114cb43b9d28de1ae1ce8030fbe5e7b2b8
+# Parent 9b04a5a324bee6bf4f6b6d044488f9f7868f9e43
 BH Multiproduct #115 : Product environments. Compliance with BEP 3 - part 1
 
-diff -r 00a5e8114cb4 bloodhound_multiproduct/multiproduct/env.py
---- a/bloodhound_multiproduct/multiproduct/env.py	Sun Jan 13 10:19:19 2013 +0000
-+++ b/bloodhound_multiproduct/multiproduct/env.py	Mon Jan 14 01:49:36 2013 -0500
+diff -r 9b04a5a324be bloodhound_multiproduct/multiproduct/env.py
+--- a/bloodhound_multiproduct/multiproduct/env.py	Mon Jan 14 14:05:28 2013 +0000
++++ b/bloodhound_multiproduct/multiproduct/env.py	Mon Jan 14 19:26:46 2013 -0500
 @@ -46,7 +46,7 @@
      def __init__(self, path, create=False, options=[]):
          super(Environment, self).__init__(path, create=create, options=options)
  
      project_icon = Option('project', 'icon', 'common/trac.ico',
          """URL of the icon of the product.""")
-@@ -207,6 +207,12 @@
+@@ -207,6 +207,13 @@
          :param product: product prefix or an instance of
                          multiproduct.model.Product
          """
 +        if not isinstance(env, trac.env.Environment):
++            cls = self.__class__
 +            raise TypeError("Initializer must be called with " \
 +                "trac.env.Environment instance as first argument " \
 +                "(got %s instance instead)" % 
-+                        (self._component_name(env.__class__),) )
++                         (cls.__module__ + '.' + cls.__name__, ))
 +
          ComponentManager.__init__(self)
  
          if isinstance(product, Product):
-@@ -221,9 +227,9 @@
+@@ -221,9 +228,9 @@
                          product, products)
                  raise LookupError("Missing product %s" % (product,))
  
          self.systeminfo = []
          self._href = self._abs_href = None
  
-@@ -231,16 +237,12 @@
+@@ -231,16 +238,12 @@
  
      # ISystemInfoProvider methods
  
      get_repository = trac.env.Environment.get_repository.im_func
      is_component_enabled = trac.env.Environment.is_component_enabled.im_func
  
-@@ -264,7 +266,7 @@
+@@ -264,7 +267,7 @@
                 ...
          """
          # share connection pool with global environment
  
      @lazy
      def db_exc(self):
-@@ -282,7 +284,7 @@
+@@ -282,7 +285,7 @@
                  ...
          """
          # exception types same as in global environment
  
      def with_transaction(self, db=None):
          """Decorator for transaction functions :deprecated:"""
-@@ -293,7 +295,7 @@
+@@ -293,7 +296,7 @@
  
          See `trac.db.api.get_read_db` for detailed documentation."""
          # database connection is shared with global environment
  
      @property
      def db_query(self):
-@@ -328,7 +330,7 @@
+@@ -328,7 +331,7 @@
            `db_transaction`).
          """
          BloodhoundIterableCursor.set_env(self)
  
      @property
      def db_transaction(self):
-@@ -364,7 +366,7 @@
+@@ -364,7 +367,7 @@
            (`db_query` or `db_transaction`).
          """
          BloodhoundIterableCursor.set_env(self)
  
      def shutdown(self, tid=None):
          """Close the environment."""
-@@ -385,58 +387,30 @@
+@@ -385,58 +388,30 @@
          """
          # TODO: Handle options args
  
          if format:
              format = format.replace('$(', '%(') \
                       .replace('%(path)s', self.path) \
-@@ -449,25 +423,8 @@
+@@ -449,25 +424,8 @@
          self.log.info('-' * 32 + ' environment startup [Trac %s] ' + '-' * 32,
                        get_pkginfo(core).get('version', VERSION))
  
          return False
  
      def upgrade(self, backup=False, backup_dest=None):
-diff -r 00a5e8114cb4 bloodhound_multiproduct/tests/env.py
---- a/bloodhound_multiproduct/tests/env.py	Sun Jan 13 10:19:19 2013 +0000
-+++ b/bloodhound_multiproduct/tests/env.py	Mon Jan 14 01:49:36 2013 -0500
+diff -r 9b04a5a324be bloodhound_multiproduct/tests/env.py
+--- a/bloodhound_multiproduct/tests/env.py	Mon Jan 14 14:05:28 2013 +0000
++++ b/bloodhound_multiproduct/tests/env.py	Mon Jan 14 19:26:46 2013 -0500
 @@ -20,9 +20,17 @@
  
  import os.path
 +        with self.assertRaises(TypeError) as cm_test:
 +            new_env = ProductEnvironment(self.product_env, 'tp2')
 +
-+        #msg = str(cm_test.exception)
-+        #expected_msg = "Initializer must be called with " \
-+        #        "trac.env.Environment instance as first argument " \
-+        #        "(got multiproduct.env.ProductEnvironment instance instead)"
-+        #self.assertEqual(msg, expected_msg)
++        msg = str(cm_test.exception)
++        expected_msg = "Initializer must be called with " \
++                "trac.env.Environment instance as first argument " \
++                "(got multiproduct.env.ProductEnvironment instance instead)"
++        self.assertEqual(msg, expected_msg)
 +
 +    def tearDown(self):
 +        # Release reference to transient environment mock object
 -    unittest.main(defaultTest='suite')
 +    unittest.main(defaultTest='test_suite')
  
-diff -r 00a5e8114cb4 bloodhound_theme/setup.py
---- a/bloodhound_theme/setup.py	Sun Jan 13 10:19:19 2013 +0000
-+++ b/bloodhound_theme/setup.py	Mon Jan 14 01:49:36 2013 -0500
+diff -r 9b04a5a324be bloodhound_theme/setup.py
+--- a/bloodhound_theme/setup.py	Mon Jan 14 14:05:28 2013 +0000
++++ b/bloodhound_theme/setup.py	Mon Jan 14 19:26:46 2013 -0500
 @@ -19,6 +19,7 @@
  #  under the License.