def db(): from service import db with app.app_context(): db.create_all() yield db db.drop_all() db.session.commit()
def setUp(self): app.config.from_object('testing.TestConfig') self.app = app.test_client() db.create_all() fixtures.load_fixtures( loaders.load('testing/fixtures/user.json')) fixtures.load_fixtures( loaders.load('testing/fixtures/broadcaster2_follower.json')) fixtures.load_fixtures( loaders.load('testing/fixtures/tweet.json')) # manually setting date_created; I don't believe # Flask-Fixtures supports setting dates renee_tweet = Tweet.query.filter_by(id=1).first() renee_tweet.date_created = datetime.date(2015, 1, 1) trenton_tweet = Tweet.query.filter_by(id=2).first() trenton_tweet.date_created = datetime.date(2015, 1, 2) db.session.add(renee_tweet) db.session.add(trenton_tweet) db.session.commit()
def client(): ## Setup for each test ## app.config['TESTING'] = True app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@testdb:5432/mytestdb' client = app.test_client() with app.app_context(): db.create_all() yield client ## Teardown for each test ## with app.app_context(): db.session.close() db.drop_all()
def setUp(self): app.config["TESTING"] = True app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///data/test.db" self.app = app.test_client() db.create_all() self.data = {'code': 'g', 'description': 'Giulia', 'designer': 'alice', 'gender': 'F', 'image_urls': ['http://www.oxygenboutique.com/GetImage/d', 'http://www.oxygenboutique.com/GetImage/d'], 'last_updated': '2013-07-12 17:25:24', 'name': 'Giulia Emb', 'price': 690.0, 'raw_color': '', 'sale_discount': 0, 'source_url': 'http://www.oxygenboutique.com/giulia-em', 'stock_status': {u'L': 1, u'M': 1, u'S': 3, u'XS': 3}, 'type': 'A'} self.data["__type__"] = "Product"
def setUp(self): app.config.from_object('testing.TestConfig') self.app = app.test_client() db.create_all() fixtures.load_fixtures(loaders.load('testing/fixtures/user.json')) fixtures.load_fixtures( loaders.load('testing/fixtures/broadcaster2_follower.json')) fixtures.load_fixtures(loaders.load('testing/fixtures/tweet.json')) # manually setting date_created; I don't believe # Flask-Fixtures supports setting dates renee_tweet = Tweet.query.filter_by(id=1).first() renee_tweet.date_created = datetime.date(2015, 1, 1) trenton_tweet = Tweet.query.filter_by(id=2).first() trenton_tweet.date_created = datetime.date(2015, 1, 2) db.session.add(renee_tweet) db.session.add(trenton_tweet) db.session.commit()
def create_app(testing=False): """ Create a Flask app instance, sets SQLALCHEMY configurations """ migrate = Migrate() app = Flask(__name__) app.register_blueprint(views_bp, url_prefix="") app.config["LOG_LEVEL"] = "INFO" app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite3' db.init_app(app) migrate.init_app(app, db) db.create_all(app=app) setup_logging(app) return app
def create(): "Creates database tables from sqlalchemy models" db.create_all()
# with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software distributed under the License # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express # or implied. See the License for the specific language governing permissions and limitations under the License. import argparse from service import db from models.pipeline import Pipeline from models.application import Application from models.mapping import Mapping from models.operator import Operator try: db.create_all() except Exception as e: print(e) from service.api import app def app_runner(args): if args.debug: debug = True app.run(host="0.0.0.0", debug=debug, port=5000) def run_with_args(): parser = argparse.ArgumentParser(description='Start args') parser.add_argument('--debug', action="store_true") args = parser.parse_args()
def recreate_db(): db.drop_all() db.create_all() db.session.commit()
#!flask/bin/python from migrate.versioning import api import os.path from config import SQLALCHEMY_DATABASE_URI from config import SQLALCHEMY_MIGRATE_REPO from service import db, models db.create_all() if not os.path.exists(SQLALCHEMY_MIGRATE_REPO): api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository') api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO) else: api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, api.version(SQLALCHEMY_MIGRATE_REPO))
def setUp(self): db.create_all() db.session.commit()
def create(): db.create_all()
def setUp(self): ''' Setup the database. ''' db.create_all() db.session.commit()
def init_db(): db.create_all() db.session.commit()
def setUp(self): db.create_all()