当前位置: 首页>>代码示例>>Python>>正文


Python fixture.SQLAlchemyFixture类代码示例

本文整理汇总了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
开发者ID:JohnBrodie,项目名称:whatup-api,代码行数:7,代码来源:__init__.py

示例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.")
开发者ID:raygunsix,项目名称:tracking,代码行数:34,代码来源:websetup.py

示例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()
开发者ID:amitm,项目名称:DailyLog,代码行数:9,代码来源:test_dailylog.py

示例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()
开发者ID:colwilson,项目名称:Flask-rename-your-application,代码行数:11,代码来源:tests.py

示例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()
开发者ID:JamesX88,项目名称:tes,代码行数:14,代码来源:test_sqlalchemy_loadable.py

示例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)
开发者ID:grampajoe,项目名称:tincture,代码行数:32,代码来源:test_list.py

示例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')
     })
开发者ID:JamesX88,项目名称:tes,代码行数:25,代码来源:test_sqlalchemy_loadable.py

示例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)
开发者ID:jianingy,项目名称:treestore,代码行数:7,代码来源:test_service.py

示例9: setUp

    def setUp(self):
        setup_environment()

        self.fixture = SQLAlchemyFixture(
            env=models,
            session=session,
            style=NamedDataStyle(),
        )
开发者ID:grampajoe,项目名称:tincture,代码行数:8,代码来源:test_detail.py

示例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)
开发者ID:wzqwsrf,项目名称:itdb,代码行数:8,代码来源:test_provider_dal.py

示例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)
开发者ID:wzqwsrf,项目名称:itdb,代码行数:8,代码来源:test_asset_info_dal.py

示例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)
开发者ID:wzqwsrf,项目名称:itdb,代码行数:9,代码来源:test_device_state_dal.py

示例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)
开发者ID:wzqwsrf,项目名称:itdb,代码行数:9,代码来源:test_in_out_reason_dal.py

示例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)
开发者ID:wzqwsrf,项目名称:itdb,代码行数:9,代码来源:test_asset_consume_info_dal.py

示例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)
开发者ID:wzqwsrf,项目名称:hstore,代码行数:10,代码来源:test_user_service.py


注:本文中的fixture.SQLAlchemyFixture类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。