示例#1
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
        with app.app_context():
            self.db = self.couchdb.db
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'))
示例#3
0
    def setUp(self):
        app = flask.Flask(__name__)
        app.config['COUCHDB_DATABASE'] = 'test_db_3'
        app.config['TESTING'] = True
        couchdb = CouchDBKit(app)

        with app.app_context():
            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
示例#4
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'))
示例#5
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()
示例#6
0
 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'))
示例#7
0
 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'))
 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'))