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): del self.couchdb.server[self.app.config['COUCHDB_DATABASE']] def test_connection_manager(self): self.app.config['COUCHDB_KEEPALIVE'] = 20 self.couchdb = CouchDBKit(self.app) server = self.couchdb.server self.assertEqual(server.res.client._manager.max_conn, self.app.config['COUCHDB_KEEPALIVE']) def test_init_db(self): self.couchdb = CouchDBKit(self.app) self.assertTrue(self.couchdb.server.all_dbs().index('test_db_2')) def test_late_initialization(self): self.couchdb = CouchDBKit() self.couchdb.init_app(self.app) self.assertTrue(self.couchdb.server.all_dbs().index('test_db_2'))
def setUp(self): app = flask.Flask(__name__) app.config['COUCHDB_DATABASE'] = 'test_db_1' app.config['TESTING'] = True couchdb = CouchDBKit(app) self.Todo = make_todo_model(couchdb) self.app = app self.couchdb = couchdb self.db = self.couchdb.server[self.app.config['COUCHDB_DATABASE']]
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): del self.couchdb.server[self.app.config['COUCHDB_DATABASE']] def test_init_db(self): self.couchdb = CouchDBKit(self.app) self.assertTrue(self.couchdb.server.all_dbs().index('test_db_2')) def test_late_initialization(self): self.couchdb = CouchDBKit() self.couchdb.init_app(self.app) self.assertTrue(self.couchdb.server.all_dbs().index('test_db_2'))
def setUp(self): app = flask.Flask(__name__) app.config['COUCHDB_DATABASE'] = 'test_db_3' app.config['TESTING'] = True couchdb = CouchDBKit(app) self.Todo = make_todo_model(couchdb) self.Todo(title='First Todo', text='Some text.').save() self.Todo(title='Second Todo', text='More text.', done=True).save() self.Todo(title='Third Todo', text='Even more text.').save() self.app = app self.couchdb = couchdb
def setUp(self): app = flask.Flask(__name__) app.config['COUCHDB_DATABASE'] = 'test_db_4' app.config['TESTING'] = True couchdb = CouchDBKit(app) self.Todo = make_todo_model(couchdb) @app.route('/') def index(): return '\n'.join(row['key'] for row in self.Todo.view('todos/all')) @app.route('/add', methods=['POST']) def add(): form = flask.request.form todo = self.Todo(title=form['title'], text=form['text']) todo.save() return 'added' self.app = app self.couchdb = couchdb self.couchdb.sync()
def test_late_initialization(self): self.couchdb = CouchDBKit() self.couchdb.init_app(self.app) self.assertTrue(self.couchdb.server.all_dbs().index('test_db_2'))
def test_init_db(self): self.couchdb = CouchDBKit(self.app) self.assertTrue(self.couchdb.server.all_dbs().index('test_db_2'))
def test_connection_manager(self): self.app.config['COUCHDB_KEEPALIVE'] = 20 self.couchdb = CouchDBKit(self.app) server = self.couchdb.server self.assertEqual(server.res.client._manager.max_conn, self.app.config['COUCHDB_KEEPALIVE'])