From 0c2c1ea2a33e8fe651788eda08c5ef73f5abe1d4 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 9 May 2012 10:47:02 -0700 Subject: [PATCH 1/2] Fix import for `virtual` from the SQLAlchemy backend [GH-127] The SQLAlchemy backend was trying to import `virtual` instead of `transport.virtual`. --- kombu/transport/sqlalchemy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kombu/transport/sqlalchemy/__init__.py b/kombu/transport/sqlalchemy/__init__.py index cb7e4afc..e667c61c 100644 --- a/kombu/transport/sqlalchemy/__init__.py +++ b/kombu/transport/sqlalchemy/__init__.py @@ -7,7 +7,7 @@ from sqlalchemy import create_engine from sqlalchemy.exc import OperationalError from sqlalchemy.orm import sessionmaker -from kombu import virtual +from kombu.transport import virtual from kombu.exceptions import StdChannelError from .models import Queue, Message, metadata From f301056b7101651914d9def42300e28778f5affe Mon Sep 17 00:00:00 2001 From: franck cuny Date: Wed, 9 May 2012 14:15:39 -0700 Subject: [PATCH 2/2] Add a new test file for the SQLAlchemy transport Add a simple test to parse URLs for SQLAlchemy. This tests should prevent issues that were introduced (GH-127 and the one fixed by f187ccdbcf1) --- kombu/tests/transport/test_sqlalchemy.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 kombu/tests/transport/test_sqlalchemy.py diff --git a/kombu/tests/transport/test_sqlalchemy.py b/kombu/tests/transport/test_sqlalchemy.py new file mode 100644 index 00000000..a043b0fc --- /dev/null +++ b/kombu/tests/transport/test_sqlalchemy.py @@ -0,0 +1,24 @@ +from __future__ import absolute_import + +import tempfile + +from kombu.connection import BrokerConnection +from kombu.tests.utils import TestCase + +class test_sqlalchemy(TestCase): + + def test_url_parser(self): + from kombu.transport import sqlalchemy + + tmppath = tempfile.mkdtemp() + + url = "sqlalchemy+sqlite://{path}/celerydb.sqlite".format(path=tmppath) + connection = BrokerConnection(url).connect() + + url = "sqla+sqlite://{path}/celerydb.sqlite".format(path=tmppath) + connection = BrokerConnection(url).connect() + + # Should prevent regression fixed by f187ccd + url = "sqlb+sqlite://{path}/celerydb.sqlite".format(path=tmppath) + with self.assertRaises(KeyError): + BrokerConnection(url).connect()