Exemplo n.º 1
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):
        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'))
Exemplo n.º 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):
        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'))
Exemplo n.º 3
0
    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'))
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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()
Exemplo n.º 7
0
 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'))
Exemplo n.º 8
0
 def test_init_db(self):
     self.couchdb = CouchDBKit(self.app)
     self.assertTrue(self.couchdb.server.all_dbs().index('test_db_2'))
Exemplo n.º 9
0
 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'])
Exemplo n.º 10
0
 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'))
Exemplo n.º 11
0
 def test_init_db(self):
     self.couchdb = CouchDBKit(self.app)
     self.assertTrue(self.couchdb.server.all_dbs().index('test_db_2'))
Exemplo n.º 12
0
 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'])