Esempio n. 1
0
    def setUp(self):
        super(DatabaseTestCase, self).setUp()

        # We don't want our SQLAlchemy session thrown away post-request because that rolls
        # back the transaction and no database assertions can be made.
        self.flask_app.teardown_request_funcs = {}

        if engine is None:
            # In the future we could provide a postgres URI to test against various
            # databases!
            _configure_db()

        self.connection = engine.connect()
        Base.metadata.create_all(bind=self.connection)
        PSABase.metadata.create_all(bind=self.connection)
        self.transaction = self.connection.begin()

        Session.remove()
        Session.configure(bind=self.connection, autoflush=False)
        self.session = Session()

        # Start a transaction after creating the schema, but before anything is
        # placed into the database. We'll roll back to the start of this
        # transaction at the end of every test, and code under test will start
        # nested transactions
        self.session.begin_nested()
Esempio n. 2
0
    def setUp(self):
        super(DatabaseTestCase, self).setUp()

        # We don't want our SQLAlchemy session thrown away post-request because that rolls
        # back the transaction and no database assertions can be made.
        self.flask_app.teardown_request_funcs = {}

        if engine is None:
            # In the future we could provide a postgres URI to test against various
            # databases!
            _configure_db()

        self.connection = engine.connect()
        Base.metadata.create_all(bind=self.connection)
        PSABase.metadata.create_all(bind=self.connection)
        self.transaction = self.connection.begin()

        Session.remove()
        Session.configure(bind=self.connection, autoflush=False)
        self.session = Session()

        # Start a transaction after creating the schema, but before anything is
        # placed into the database. We'll roll back to the start of this
        # transaction at the end of every test, and code under test will start
        # nested transactions
        self.session.begin_nested()
Esempio n. 3
0
 def setUp(self):
     # Make sure each test starts with a clean session
     Session.remove()
     Session.configure(bind=None)
Esempio n. 4
0
 def setUp(self):
     # Make sure each test starts with a clean session
     Session.remove()
     Session.configure(bind=None)