Ejemplo n.º 1
0
        def create_all_tables():
            db.create_all()

            # Create initial data
            user = UserModel.find_by(username='******')
            if not user:
                user = UserModel('Alex', '*****@*****.**', '123456', is_admin=True)
                db.session.add(user)
                db.session.commit()
Ejemplo n.º 2
0
    def setUp(self):
        """
        It runs once for every test method in this class and derived classes
        :return: None
        """
        # Make sure your database is created
        with BaseTest.flaskApp.app_context():
            try:
                db.create_all()
            except OperationalError as ex:
                BaseTest.flaskApp.logger.error(
                    'Database initialization error . Error: {}'.format(
                        str(ex)))
            except DatabaseError as ex:
                BaseTest.flaskApp.logger.error(
                    'Error in database connection: {}\nError: {}'.format(
                        ex.statement, str(ex)))

        # Get a test client and app context for integration and system tests.
        self.app_context = BaseTest.flaskApp.app_context
        self.client = BaseTest.flaskApp.test_client