1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 19:42:20 -05:00
SickRage/lib/sqlalchemy/testing/suite/test_ddl.py

64 lines
1.7 KiB
Python
Raw Normal View History

2014-05-05 00:05:43 -04:00
2014-05-04 23:25:51 -04:00
from .. import fixtures, config, util
from ..config import requirements
from ..assertions import eq_
from sqlalchemy import Table, Column, Integer, String
class TableDDLTest(fixtures.TestBase):
2014-05-05 00:05:43 -04:00
__backend__ = True
2014-05-04 23:25:51 -04:00
def _simple_fixture(self):
return Table('test_table', self.metadata,
Column('id', Integer, primary_key=True, autoincrement=False),
Column('data', String(50))
)
2014-05-05 00:05:43 -04:00
def _underscore_fixture(self):
return Table('_test_table', self.metadata,
Column('id', Integer, primary_key=True, autoincrement=False),
Column('_data', String(50))
)
2014-05-04 23:25:51 -04:00
def _simple_roundtrip(self, table):
with config.db.begin() as conn:
conn.execute(table.insert().values((1, 'some data')))
result = conn.execute(table.select())
eq_(
result.first(),
(1, 'some data')
)
@requirements.create_table
@util.provide_metadata
def test_create_table(self):
table = self._simple_fixture()
table.create(
config.db, checkfirst=False
)
self._simple_roundtrip(table)
@requirements.drop_table
@util.provide_metadata
def test_drop_table(self):
table = self._simple_fixture()
table.create(
config.db, checkfirst=False
)
table.drop(
config.db, checkfirst=False
)
2014-05-05 00:05:43 -04:00
@requirements.create_table
@util.provide_metadata
def test_underscore_names(self):
table = self._underscore_fixture()
table.create(
config.db, checkfirst=False
)
self._simple_roundtrip(table)
2014-05-04 23:25:51 -04:00
__all__ = ('TableDDLTest', )