Update tests and reqs for SQLA 1.0
Lift the requirements to support SQLAlchemy 1.0. Two tests were calling upon revised APIs and required adjustment. Change-Id: Ic91a91bb3c915027b522eace302f2ed074233294
This commit is contained in:
parent
b8def7cbfb
commit
a94dae7a01
@ -12,6 +12,8 @@ from sqlalchemy import __version__ as _sa_version
|
||||
_sa_version = tuple(int(re.match("\d+", x).group(0)) for x in _sa_version.split("."))
|
||||
SQLA_07 = _sa_version >= (0, 7)
|
||||
SQLA_08 = _sa_version >= (0, 8)
|
||||
SQLA_09 = _sa_version >= (0, 9)
|
||||
SQLA_10 = _sa_version >= (1, 0)
|
||||
|
||||
del re
|
||||
del _sa_version
|
||||
|
@ -1,3 +1,5 @@
|
||||
from migrate.changeset import SQLA_10
|
||||
|
||||
"""
|
||||
Safe quoting method
|
||||
"""
|
||||
@ -8,3 +10,12 @@ def safe_quote(obj):
|
||||
return obj.name.quote
|
||||
else:
|
||||
return obj.quote
|
||||
|
||||
|
||||
def fk_column_names(constraint):
|
||||
if SQLA_10:
|
||||
return [
|
||||
constraint.columns[key].name for key in constraint.column_keys]
|
||||
else:
|
||||
return [
|
||||
element.parent.name for element in constraint.elements]
|
||||
|
@ -5,6 +5,7 @@ from sqlalchemy import *
|
||||
from sqlalchemy.util import *
|
||||
from sqlalchemy.exc import *
|
||||
|
||||
from migrate.changeset.util import fk_column_names
|
||||
from migrate.exceptions import *
|
||||
from migrate.changeset import *
|
||||
|
||||
@ -91,7 +92,7 @@ class TestConstraint(CommonTestConstraint):
|
||||
self.assertTrue(list(self.table.c.fkey.foreign_keys) is not [])
|
||||
else:
|
||||
self.assertTrue(self.table.c.fkey.foreign_keys._list is not [])
|
||||
for key in fk.columns:
|
||||
for key in fk_column_names(fk):
|
||||
self.assertEqual(key, self.table.c.fkey.name)
|
||||
self.assertEqual([e.column for e in fk.elements], [self.table.c.id])
|
||||
self.assertEqual(list(fk.referenced), [self.table.c.id])
|
||||
|
@ -1,4 +1,4 @@
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, text
|
||||
from migrate.tests import fixture
|
||||
|
||||
class TestConnect(fixture.DB):
|
||||
@ -8,4 +8,6 @@ class TestConnect(fixture.DB):
|
||||
def test_connect(self):
|
||||
"""Connect to the database successfully"""
|
||||
# Connection is done in fixture.DB setup; make sure we can do stuff
|
||||
select(['42'],bind=self.engine).execute()
|
||||
self.engine.execute(
|
||||
select([text('42')])
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ pbr>=0.6,!=0.7,<1.0
|
||||
# never put a cap on this, *ever*, sqla versions are handled via
|
||||
# tox, and if SQLA is capped it will only make it so we aren't testing
|
||||
# against all the versions we are compatible with.
|
||||
SQLAlchemy>=0.7.8,!=0.9.5,<=0.9.99
|
||||
SQLAlchemy>=0.7.8,!=0.9.5,<=1.0.99
|
||||
decorator
|
||||
six>=1.7.0
|
||||
sqlparse
|
||||
|
Loading…
Reference in New Issue
Block a user