コード例 #1
0
    def setUp(self):
        config = deepcopy(self.config)

        # Add the appropriate connection string to the app config.
        config['sqlalchemy'] = {
            'url': '%s/%s' % (__bind__, TestModel.__db__),
            'encoding': 'utf-8',
            'poolclass': NullPool
        }

        # Set up a fake app
        self.app = self.load_test_app(config)
        dcmodel.clear()
コード例 #2
0
ファイル: __init__.py プロジェクト: ryanpetrello/draughtcraft
    def setUp(self):
        config = deepcopy(self.config)

        # Add the appropriate connection string to the app config.
        config['sqlalchemy'] = {
            'url': '%s/%s' % (__bind__, TestModel.__db__),
            'encoding': 'utf-8',
            'poolclass': NullPool
        }

        # Set up a fake app
        self.app = self.load_test_app(config)
        dcmodel.clear()
コード例 #3
0
    def setUpClass(cls):
        if TestModel.__db__ is None:
            TestModel.__db__ = 'draughtcrafttest'
            # Connect and create the temporary database
            print "=" * 80
            print "CREATING TEMPORARY DATABASE FOR TESTS"
            print "=" * 80
            subprocess.call(['createdb', TestModel.__db__])

            # Bind and create the database tables
            dcmodel.clear()
            dcmodel.bind(
                create_engine('%s/%s' % (__bind__, TestModel.__db__), **{
                    'encoding': 'utf-8',
                    'poolclass': NullPool
                }))
            dcmodel.metadata.create_all()
            dcmodel.commit()
            dcmodel.clear()
コード例 #4
0
ファイル: __init__.py プロジェクト: ryanpetrello/draughtcraft
    def setUpClass(cls):
        if TestModel.__db__ is None:
            TestModel.__db__ = 'draughtcrafttest'
            # Connect and create the temporary database
            print "=" * 80
            print "CREATING TEMPORARY DATABASE FOR TESTS"
            print "=" * 80
            subprocess.call(['createdb', TestModel.__db__])

            # Bind and create the database tables
            dcmodel.clear()
            dcmodel.bind(create_engine(
                '%s/%s' % (__bind__, TestModel.__db__), **{
                    'encoding': 'utf-8',
                    'poolclass': NullPool
                }
            ))
            dcmodel.metadata.create_all()
            dcmodel.commit()
            dcmodel.clear()
コード例 #5
0
    def tearDown(self):
        from sqlalchemy.engine import reflection

        # Tear down and dispose the DB binding
        dcmodel.clear()

        # start a transaction
        engine = conf.sqlalchemy.sa_engine
        conn = engine.connect()
        trans = conn.begin()

        inspector = reflection.Inspector.from_engine(engine)

        # gather all data first before dropping anything.
        # some DBs lock after things have been dropped in
        # a transaction.
        conn.execute("TRUNCATE TABLE %s RESTART IDENTITY CASCADE" %
                     (', '.join(inspector.get_table_names())))

        trans.commit()
        conn.close()
コード例 #6
0
ファイル: __init__.py プロジェクト: ryanpetrello/draughtcraft
    def tearDown(self):
        from sqlalchemy.engine import reflection

        # Tear down and dispose the DB binding
        dcmodel.clear()

        # start a transaction
        engine = conf.sqlalchemy.sa_engine
        conn = engine.connect()
        trans = conn.begin()

        inspector = reflection.Inspector.from_engine(engine)

        # gather all data first before dropping anything.
        # some DBs lock after things have been dropped in
        # a transaction.
        conn.execute("TRUNCATE TABLE %s RESTART IDENTITY CASCADE" % (
            ', '.join(inspector.get_table_names())
        ))

        trans.commit()
        conn.close()