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


Python InboxSession.close方法代码示例

本文整理汇总了Python中inbox.models.session.InboxSession.close方法的典型用法代码示例。如果您正苦于以下问题:Python InboxSession.close方法的具体用法?Python InboxSession.close怎么用?Python InboxSession.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inbox.models.session.InboxSession的用法示例。


在下文中一共展示了InboxSession.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestDB

# 需要导入模块: from inbox.models.session import InboxSession [as 别名]
# 或者: from inbox.models.session.InboxSession import close [as 别名]
class TestDB(object):
    def __init__(self, config, dumpfile):
        from inbox.models.session import InboxSession
        from inbox.ignition import main_engine
        engine = main_engine()
        # Set up test database
        self.session = InboxSession(engine, versioned=False)
        self.engine = engine
        self.config = config
        self.dumpfile = dumpfile

        # Populate with test data
        self.populate()

    def populate(self):
        """ Populates database with data from the test dumpfile. """
        database = self.config.get('MYSQL_DATABASE')
        user = self.config.get('MYSQL_USER')
        password = self.config.get('MYSQL_PASSWORD')
        hostname = self.config.get('MYSQL_HOSTNAME')
        port = self.config.get('MYSQL_PORT')

        cmd = 'mysql {0} -h{1} -P{2} -u{3} -p{4} < {5}'. \
            format(database, hostname, port, user, password, self.dumpfile)
        subprocess.check_call(cmd, shell=True)

    def teardown(self):
        """
        Closes the session. We need to explicitly do this to prevent certain
        tests from hanging. Note that we don't need to actually destroy or
        rolback the database because we create it anew on each test.

        """
        self.session.close()
开发者ID:bsorin,项目名称:inbox,代码行数:36,代码来源:base.py

示例2: real_db

# 需要导入模块: from inbox.models.session import InboxSession [as 别名]
# 或者: from inbox.models.session.InboxSession import close [as 别名]
def real_db():
    """A fixture to get access to the real mysql db. We need this
    to log in to providers like gmail to check that events changes
    are synced back."""
    engine = main_engine()
    session = InboxSession(engine)
    yield session
    session.rollback()
    session.close()
开发者ID:apolmig,项目名称:inbox,代码行数:11,代码来源:test_events.py

示例3: TestDB

# 需要导入模块: from inbox.models.session import InboxSession [as 别名]
# 或者: from inbox.models.session.InboxSession import close [as 别名]
class TestDB(object):
    def __init__(self, config, dumpfile):
        from inbox.models.session import InboxSession
        from inbox.ignition import engine
        # Set up test database
        self.session = InboxSession(engine, versioned=False)
        self.engine = engine
        self.config = config
        self.dumpfile = dumpfile

        # Populate with test data
        self.populate()

    def populate(self):
        """ Populates database with data from the test dumpfile. """
        database = self.config.get('MYSQL_DATABASE')
        user = self.config.get('MYSQL_USER')
        password = self.config.get('MYSQL_PASSWORD')

        cmd = 'mysql {0} -u{1} -p{2} < {3}'.format(database, user, password,
                                                   self.dumpfile)
        subprocess.check_call(cmd, shell=True)

    def new_session(self, ignore_soft_deletes=True):
        from inbox.models.session import InboxSession
        self.session.close()
        self.session = InboxSession(self.engine,
                                    versioned=False,
                                    ignore_soft_deletes=ignore_soft_deletes)

    def teardown(self):
        """Closes the session. We need to explicitly do this to prevent certain
        tests from hanging. Note that we don't need to actually destroy or
        rolback the database because we create it anew on each test."""
        self.session.close()

    def save(self):
        """ Updates the test dumpfile. """
        database = self.config.get('MYSQL_DATABASE')

        cmd = 'mysqldump {0} > {1}'.format(database, self.dumpfile)
        subprocess.check_call(cmd, shell=True)
开发者ID:AmyWeiner,项目名称:inbox,代码行数:44,代码来源:base.py


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