class InitializationTestCase(unittest.TestCase):

    def setUp(self):
        app = flask.Flask(__name__)
        app.config['COUCHDB_DATABASE'] = 'test_db_2'
        app.config['TESTING'] = True
        self.app = app

    def tearDown(self):
        with self.app.app_context():
            del self.couchdb.db.server[self.app.config['COUCHDB_DATABASE']]

    def test_init_db(self):
        self.couchdb = CouchDBKit(self.app)
        with self.app.app_context():
            # the jump over db is needed, since get_or_create is done at first usage
            self.assertTrue(self.couchdb.db.server.all_dbs().index('test_db_2'))

    def test_late_initialization(self):
        self.couchdb = CouchDBKit()
        self.couchdb.init_app(self.app)
        with self.app.app_context():
            self.assertTrue(self.couchdb.db.server.all_dbs().index('test_db_2'))
示例#2
0
class InitializationTestCase(unittest.TestCase):
    def setUp(self):
        app = flask.Flask(__name__)
        app.config['COUCHDB_DATABASE'] = 'test_db_2'
        app.config['TESTING'] = True
        self.app = app

    def tearDown(self):
        with self.app.app_context():
            del self.couchdb.db.server[self.app.config['COUCHDB_DATABASE']]

    def test_init_db(self):
        self.couchdb = CouchDBKit(self.app)
        with self.app.app_context():
            # the jump over db is needed, since get_or_create is done at first usage
            self.assertTrue(
                self.couchdb.db.server.all_dbs().index('test_db_2'))

    def test_late_initialization(self):
        self.couchdb = CouchDBKit()
        self.couchdb.init_app(self.app)
        with self.app.app_context():
            self.assertTrue(
                self.couchdb.db.server.all_dbs().index('test_db_2'))