Bring more compatibility with oslo_db

Remove obsolete workaround for transaction in sqlite.
Prevent make request with empty filter (supress sqlalchemy warning).
Bonus: enable a test by fixing its lame name.

Change-Id: Ia7a68b6942c5a5fceab9868769d30db7862fc47e
This commit is contained in:
Feodor Tersin 2015-03-01 01:07:56 +03:00
parent 9e6e4f6542
commit 1a983fe766
2 changed files with 5 additions and 14 deletions

View File

@ -198,6 +198,8 @@ def get_item_by_id(context, item_id):
@require_context
def get_items_by_ids(context, item_ids):
if not item_ids:
return []
return [_unpack_item_data(item)
for item in (model_query(context, models.Item).
filter_by(project_id=context.project_id).

View File

@ -14,7 +14,6 @@
from oslo_config import cfg
from oslotest import base as test_base
from sqlalchemy import event
from sqlalchemy.orm import exc as orm_exception
from ec2api.api import validator
@ -41,16 +40,6 @@ class DbApiTestCase(test_base.BaseTestCase):
conf.set_override('sqlite_synchronous', False, group='database')
engine = session.get_engine()
# NOTE(ft): enable savepoints in sqlite. See SAVEPOINT support
# section in sqlalchemy.dialects.sqlite.base.py
@event.listens_for(engine, "connect")
def do_connect(dbapi_connection, connection_record):
# disable pysqlite's emitting of the BEGIN statement entirely.
# also stops it from emitting COMMIT before any DDL.
dbapi_connection.isolation_level = None
conn = engine.connect()
migration.db_sync()
cls.DB_SCHEMA = "".join(line
@ -428,16 +417,16 @@ class DbApiTestCase(test_base.BaseTestCase):
'value': 'val_b'}])
do_check(tag2_2)
def delete_tags_isolation(self):
def test_delete_tags_isolation(self):
item_id = fakes.random_ec2_id('fake')
tag1 = {'item_id': item_id,
'key': 'key',
'value': 'val1'}
db_api.add_tags(self.context, tag1)
db_api.add_tags(self.context, [tag1])
tag2 = {'item_id': item_id,
'key': 'key',
'value': 'val2'}
db_api.add_tags(self.other_context, tag2)
db_api.add_tags(self.other_context, [tag2])
db_api.delete_tags(self.context, item_id)
self.assertThat(db_api.get_tags(self.other_context),
matchers.ListMatches([tag2]))