Esempio n. 1
0
 def setUp(self):
     main.app.config['TESTING'] = True
     main.app.logger.setLevel('DEBUG')
     self.app = main.app.test_client()
     main.init_db()
     self.db = main.connect_db()
     self.service = Service(self.db)
def client():
    app.config['TESTING'] = True
    app.config['WTF_CSRF_ENABLED'] = False
    app.config['SQL_ALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
    client = app.test_client()

    with app.app_context():
        init_db()

    yield client
def client():
    db_fd, main.app.config['DATABASE'] = tempfile.mkstemp()
    main.app.config['TESTING'] = True

    with main.app.test_client() as client:
        with main.app.app_context():
            main.init_db()
        yield client

    os.close(db_fd)
    os.unlink(main.app.config['DATABASE'])
Esempio n. 4
0
    def setUp(self):
        """Setup method."""
        self.db_fd, app.config['DATABASE'] = tempfile.mkstemp()
        app.config['TESTING'] = True
        self.app = app.test_client()
        with app.app_context():
            init_db()

        self.place1 = {
            'place_id': u'PID1',
            'coords': (-12, 34),
            'city': u'Kaningina Reserve',
            'region': u'Nkhata Bay',
            'country_name': u'Malawi',
            'country_code': u'MW'
        }
        self.place1_updated_city = u'Village'
        self.place1_updated_region = u'Deforested Area'
        self.place2 = {
            'place_id': u'PID2',
            'coords': (56, -78.9),
            'city': u'Flaherty Island',
            'region': u'Nunavut',
            'country_name': u'Canada',
            'country_code': u'CA'
        }

        self.user1 = {
            'user_id': '1',
            'name': 'Al Bert',
            'email': '*****@*****.**'
        }
        self.user2 = {
            'user_id': '2',
            'name': 'Can Dee',
            'email': '*****@*****.**'
        }
Esempio n. 5
0
from main import init_db
init_db()
Esempio n. 6
0
 def setUp(self):
     self.db_fd, main.app.config['DATABASE'] = tempfile.mkstemp()
     main.app.config['TESTING'] = True
     self.app = main.app.test_client()
     with main.app.app_context():
         main.init_db()
Esempio n. 7
0
import main
from config import APP_HOST, APP_PORT, DEVEL

if __name__ == "__main__":
    main.init_blueprints()
    main.init_db()
    main.main.run(host=APP_HOST, port=APP_PORT, debug=DEVEL)
Esempio n. 8
0
 def setUp(self):
     self.db_fd, main.app.config['DATABASE'] = tempfile.mkstemp()
     main.app.config['TESTING'] = True
     self.app = main.app.test_client()
     main.init_db()
Esempio n. 9
0
from flask.ext.testing import TestCase
from main.models import get_or_create, User
import main
import logging
import unittest

main.main.config["TESTING"] = True
main.init_db(main.main.config["SQLALCHEMY_TEST_DATABASE_URI"])
main.init_blueprints()


class AppTestCase(TestCase):
    def create_app(self):
        return main.main

    def setUp(self):
        self.admin_user = get_or_create(User,
                                        will_commit=True,
                                        username="******",
                                        password="******",
                                        can_read=True,
                                        can_write=True,
                                        can_exec=True)
        main.db.session.flush()

    def verify_inserted(self, model, **kwargs):
        """
        Verify that the record described by **kwargs is inserted into the table
        represented by the given model. Returns the inserted record (if the
        assert succeeds.
        """