本文整理汇总了Python中fixture.SQLAlchemyFixture类的典型用法代码示例。如果您正苦于以下问题:Python SQLAlchemyFixture类的具体用法?Python SQLAlchemyFixture怎么用?Python SQLAlchemyFixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SQLAlchemyFixture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install
def install(app, *args):
engine = m.create_tables(app)
db = SQLAlchemyFixture(env=m, style=NamedDataStyle(), engine=engine)
data = db.data(*args)
data.setup()
db.dispose()
return data
示例2: setup_app
def setup_app(command, conf, vars):
"""Place any commands to setup tracking here"""
load_environment(conf.global_conf, conf.local_conf)
filename = os.path.split(conf.filename)[-1]
if filename == 'test.ini':
# Permanently drop any existing tables
log.info("Dropping existing tables...")
meta.Base.metadata.drop_all(bind=meta.engine, checkfirst=True)
log.info("Creating tables...")
# Create the tables if they don't already exist
meta.Base.metadata.create_all(bind=meta.engine)
log.info("Successfully set up.")
if filename == 'development.ini':
# load sample data during setup-app
db = SQLAlchemyFixture(
env=model, style=NamedDataStyle(),
engine=meta.engine)
data = db.data(PageviewsData)
log.info("Loading sample data...")
data.setup()
log.info("Successfully set up.")
示例3: setUp
def setUp(self):
self.app = create_app('config/test.ini').test_client()
init_db()
# TODO move this to the proper place in the code
dbfixture = SQLAlchemyFixture(
env={'UserData': User},
engine=dailylog.db.engine)
self.data = dbfixture.data(UserData)
self.data.setup()
示例4: setUp
def setUp(self):
db.create_all()
fixture = SQLAlchemyFixture( env=models,
style=TrimmedNameStyle(suffix="Data"),
session=db.session)
try:
self.data = fixture.data(*self.fixtures)
except TypeError:
raise Error('You need overide "fixtures = None" with the name of some real fixtures')
self.data.setup()
示例5: test_cannot_teardown_unloaded_fixture
def test_cannot_teardown_unloaded_fixture():
class CategoryData(DataSet):
class cars:
name = 'cars'
engine = create_engine(conf.LITE_DSN)
metadata.bind = engine
db = SQLAlchemyFixture(
env=globals(),
engine=metadata.bind
)
data = db.data(CategoryData)
data.teardown()
示例6: TestListView
class TestListView(TestCase):
"""Tests for DetailView."""
urls = 'tests.integration.views.generic.urls'
def setUp(self):
setup_environment()
self.fixture = SQLAlchemyFixture(
env=models,
session=session,
style=NamedDataStyle(),
)
def test_list_view(self):
"""Test the list view."""
with self.fixture.data(fixtures.PersonData) as data:
response = self.client.get('/people/')
self.assertEqual(response.status_code, 200)
self.assertIn(data.PersonData.John.name, response.content)
def test_list_view_allow_empty(self):
"""Test getting an empty list with allow_empty = True."""
response = self.client.get('/people/')
self.assertEqual(response.status_code, 200)
def test_list_view_404(self):
"""Test getting an empty list with allow_empty = False."""
response = self.client.get('/non_empty_people/')
self.assertEqual(response.status_code, 404)
示例7: setUp
def setUp(self):
if not conf.HEAVY_DSN:
raise SkipTest("conf.HEAVY_DSN not defined")
engine = create_engine(conf.HEAVY_DSN)
metadata.bind = engine
metadata.create_all()
Session = get_transactional_session()
self.session = Session()
self.fixture = SQLAlchemyFixture(
env=globals(),
engine=metadata.bind,
style=NamedDataStyle(),
)
clear_mappers()
mapper(Category, categories)
mapper(Product, products, properties={
'category': relation(Category, backref='products')
})
mapper(Offer, offers, properties={
'product': relation(Product, backref='offers'),
'category': relation(Category, backref='offers')
})
示例8: setUp
def setUp(self):
super(DBFixture, self).setUp()
self.dbfixture = SQLAlchemyFixture(engine=get_engine(),
env={'TreeNodeData': TreeNode})
self.data = self.dbfixture.data(TreeNodeData)
self.data.setup()
self.addCleanup(self.data.teardown)
示例9: setUp
def setUp(self):
setup_environment()
self.fixture = SQLAlchemyFixture(
env=models,
session=session,
style=NamedDataStyle(),
)
示例10: setUp
def setUp(self):
super(DBFixture, self).setUp()
self.dbfixture = SQLAlchemyFixture(
engine=get_engine(),
env={'MpProviderData': Provider})
self.data = self.dbfixture.data(MpProviderData)
self.data.setup()
self.addCleanup(self.data.teardown)
示例11: setUp
def setUp(self):
super(DBFixture, self).setUp()
self.dbfixture = SQLAlchemyFixture(
engine=get_engine(),
env={'AssetInfoData': AssetInfoModel})
self.data = self.dbfixture.data(AssetInfoData)
self.data.setup()
self.addCleanup(self.data.teardown)
示例12: setUp
def setUp(self):
super(DBFixture, self).setUp()
self.dbfixture = SQLAlchemyFixture(
engine=get_engine(),
env={'DeviceStateData': DeviceState})
self.data = self.dbfixture.data(DeviceStateData)
BASE.metadata.create_all(get_engine())
self.data.setup()
self.addCleanup(self.data.teardown)
示例13: setUp
def setUp(self):
super(DBFixture, self).setUp()
print get_engine()
self.dbfixture = SQLAlchemyFixture(
engine=get_engine(),
env={'InOutData': InOutReason})
self.data = self.dbfixture.data(InOutData)
self.data.setup()
self.addCleanup(self.data.teardown)
示例14: setUp
def setUp(self):
super(DBFixture, self).setUp()
self.dbfixture = SQLAlchemyFixture(
engine=get_engine(),
env={'AssetConsumeInfoData': AssetConsumeInfoModel})
self.data = self.dbfixture.data(AssetConsumeInfoData)
BASE.metadata.create_all(get_engine())
self.data.setup()
self.addCleanup(self.data.teardown)
示例15: setUp
def setUp(self):
super(DBFixture, self).setUp()
self.session = get_session()
self.dbfixture = SQLAlchemyFixture(
engine=get_engine(),
env=dict(UserData=UserHstore)
)
self.data = self.dbfixture.data(UserData)
self.data.setup()
self.addCleanup(self.data.teardown)