Author: rjollos Date: Thu Jan 23 03:47:17 2014 New Revision: 1560582 URL: http://svn.apache.org/r1560582 Log: 0.8dev: Utilize database API for handling exceptions.
This resolves issues reported by Saint Germain when `python-pysqlite2` is installed in the environment. Modified: bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py bloodhound/trunk/bloodhound_multiproduct/tests/env.py bloodhound/trunk/bloodhound_multiproduct/tests/model.py bloodhound/trunk/bloodhound_multiproduct/tests/upgrade.py bloodhound/trunk/bloodhound_relations/bhrelations/search.py bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py bloodhound/trunk/bloodhound_relations/bhrelations/tests/base.py bloodhound/trunk/bloodhound_search/bhsearch/tests/security.py Modified: bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py?rev=1560582&r1=1560581&r2=1560582&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py (original) +++ bloodhound/trunk/bloodhound_multiproduct/multiproduct/env.py Thu Jan 23 03:47:17 2014 @@ -21,7 +21,6 @@ import os.path from urlparse import urlsplit -from sqlite3 import OperationalError from trac.config import BoolOption, ConfigSection, Option from trac.core import Component, ComponentManager, ExtensionPoint, implements, \ Modified: bloodhound/trunk/bloodhound_multiproduct/tests/env.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/tests/env.py?rev=1560582&r1=1560581&r2=1560582&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_multiproduct/tests/env.py (original) +++ bloodhound/trunk/bloodhound_multiproduct/tests/env.py Thu Jan 23 03:47:17 2014 @@ -23,7 +23,6 @@ from inspect import stack import os.path import shutil import tempfile -from sqlite3 import OperationalError from tests import unittest from types import MethodType @@ -230,7 +229,7 @@ class MultiproductTestCase(unittest.Test mpsystem = MultiProductSystem(env) try: mpsystem.upgrade_environment(env.db_transaction) - except OperationalError: + 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) @@ -310,7 +309,7 @@ class ProductEnvApiTestCase(Multiproduct if self.env is not None: try: self.env.reset_db() - except OperationalError: + except self.env.db_exc.OperationalError: # "Database not found ...", # "OperationalError: no such table: system" or the like pass @@ -575,7 +574,7 @@ class ProductEnvHrefTestCase(Multiproduc if self.env is not None: try: self.env.reset_db() - except OperationalError: + except self.env.db_exc.OperationalError: # "Database not found ...", # "OperationalError: no such table: system" or the like pass Modified: bloodhound/trunk/bloodhound_multiproduct/tests/model.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/tests/model.py?rev=1560582&r1=1560581&r2=1560582&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_multiproduct/tests/model.py (original) +++ bloodhound/trunk/bloodhound_multiproduct/tests/model.py Thu Jan 23 03:47:17 2014 @@ -19,7 +19,6 @@ """Tests for multiproduct/model.py""" import shutil import tempfile -from sqlite3 import OperationalError from tests import unittest from trac.core import TracError @@ -46,7 +45,7 @@ class ProductTestCase(unittest.TestCase) self.mpsystem = MultiProductSystem(self.env) try: self.mpsystem.upgrade_environment(self.env.db_transaction) - except OperationalError: + except self.env.db_exc.OperationalError: # table remains but database version is deleted pass Modified: bloodhound/trunk/bloodhound_multiproduct/tests/upgrade.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_multiproduct/tests/upgrade.py?rev=1560582&r1=1560581&r2=1560582&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_multiproduct/tests/upgrade.py (original) +++ bloodhound/trunk/bloodhound_multiproduct/tests/upgrade.py Thu Jan 23 03:47:17 2014 @@ -21,7 +21,6 @@ import os import shutil import tempfile import uuid -from sqlite3 import OperationalError from contextlib import contextmanager from tests import unittest @@ -434,13 +433,13 @@ class EnvironmentUpgradeTestCase(unittes @contextmanager def assertFailsWithMissingTable(self): - with self.assertRaises(OperationalError) as cm: + with self.assertRaises(self.env.db_exc.OperationalError) as cm: yield self.assertIn('no such table', str(cm.exception)) @contextmanager def assertFailsWithMissingColumn(self): - with self.assertRaises(OperationalError) as cm: + with self.assertRaises(self.env.db_exc.OperationalError) as cm: yield self.assertIn('no such column', str(cm.exception)) Modified: bloodhound/trunk/bloodhound_relations/bhrelations/search.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/search.py?rev=1560582&r1=1560581&r2=1560582&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_relations/bhrelations/search.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/search.py Thu Jan 23 03:47:17 2014 @@ -18,8 +18,6 @@ # specific language governing permissions and limitations # under the License. -from sqlite3 import OperationalError - from trac.core import Component, implements from bhsearch.api import IDocIndexPreprocessor @@ -42,7 +40,7 @@ class RelationsDocPreprocessor(Component for relation in rls._select_relations(resource_id): relations.extend(self._format_relations(relation)) doc['relations'] = ','.join(relations) - except OperationalError: + except self.env.db_exc.OperationalError: # If bhrelations and bhsearch are installed at the same time and # bhsearch is upgraded before bhrelations, table # bloodhound_relations will be missing, thus causing the Modified: bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py?rev=1560582&r1=1560581&r2=1560582&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/tests/api.py Thu Jan 23 03:47:17 2014 @@ -18,7 +18,6 @@ # specific language governing permissions and limitations # under the License. from datetime import datetime -from _sqlite3 import IntegrityError import unittest from bhrelations.api import TicketRelationsSpecifics from bhrelations.tests.mocks import TestRelationChangingListener @@ -98,7 +97,10 @@ class ApiTestCase(BaseRelationsTestCase) with self.env.db_transaction as db: db(sql, ["1", "2", "dependson"]) self.assertRaises( - IntegrityError, db, sql, ["1", "2", "dependson"]) + self.env.db_exc.IntegrityError, + db, + sql, + ["1", "2", "dependson"]) def test_can_add_one_way_relations(self): #arrange Modified: bloodhound/trunk/bloodhound_relations/bhrelations/tests/base.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_relations/bhrelations/tests/base.py?rev=1560582&r1=1560581&r2=1560582&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_relations/bhrelations/tests/base.py (original) +++ bloodhound/trunk/bloodhound_relations/bhrelations/tests/base.py Thu Jan 23 03:47:17 2014 @@ -15,7 +15,6 @@ # specific language governing permissions and limitations # under the License. -from _sqlite3 import OperationalError from tests.env import MultiproductTestCase from multiproduct.env import ProductEnvironment from bhrelations.api import RelationsSystem, EnvironmentSetup, \ @@ -86,7 +85,7 @@ class BaseRelationsTestCase(Multiproduct environment_setup = EnvironmentSetup(self.env) try: environment_setup.upgrade_environment(self.env.db_transaction) - except OperationalError: + except self.env.db_exc.OperationalError: # table remains but database version is deleted pass Modified: bloodhound/trunk/bloodhound_search/bhsearch/tests/security.py URL: http://svn.apache.org/viewvc/bloodhound/trunk/bloodhound_search/bhsearch/tests/security.py?rev=1560582&r1=1560581&r2=1560582&view=diff ============================================================================== --- bloodhound/trunk/bloodhound_search/bhsearch/tests/security.py (original) +++ bloodhound/trunk/bloodhound_search/bhsearch/tests/security.py Thu Jan 23 03:47:17 2014 @@ -24,7 +24,6 @@ system backend. """ import contextlib import os -from sqlite3 import OperationalError from bhsearch.security import SecurityFilter try: @@ -69,7 +68,7 @@ class SecurityTest(BaseBloodhoundSearchT try: MultiProductSystem(self.env)\ .upgrade_environment(self.env.db_transaction) - except OperationalError: + except self.env.db_exc.OperationalError: # table remains but content is deleted self._add_products('@') self.env.enable_multiproduct_schema()