當前位置: 首頁>>代碼示例>>Python>>正文


Python session.InboxSession類代碼示例

本文整理匯總了Python中inbox.models.session.InboxSession的典型用法代碼示例。如果您正苦於以下問題:Python InboxSession類的具體用法?Python InboxSession怎麽用?Python InboxSession使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了InboxSession類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestDB

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,代碼行數:34,代碼來源:base.py

示例2: real_db

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,代碼行數:9,代碼來源:test_events.py

示例3: TestDB

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,代碼行數:42,代碼來源:base.py

示例4: __init__

    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()
開發者ID:AmyWeiner,項目名稱:inbox,代碼行數:11,代碼來源:base.py

示例5: new_session

 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)
開發者ID:AmyWeiner,項目名稱:inbox,代碼行數:6,代碼來源:base.py


注:本文中的inbox.models.session.InboxSession類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。