Example #1
0
 def setUp(self):
     self.app = create_app('testing')
     with self.app.app_context():
         db.create_all()
     self.client = self.app.test_client()
     self.app_context = self.app.app_context()
     self.app_context.push()
Example #2
0
    def setUp(self):
        self.app = create_app('testing')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.drop_all()
        db.create_all()
        user = User(username=self.default_username,
                    password=self.default_password)
        user2 = User(username=self.another_user,
                     password=self.default_password)
        db.session.add_all([user, user2])
        db.session.commit()
        g.user = user

        bucketlist = BucketList(name=self.bucketlist_name, creator_id=user.id)
        bucketlist2 = BucketList(name=self.bucketlist2_name,
                                 creator_id=user2.id)
        bucketlist3 = BucketList(name=self.bucketlist3_name,
                                 creator_id=user.id)
        db.session.add_all([bucketlist, bucketlist2, bucketlist3])
        db.session.commit()

        bucketlist_item = BucketListItem(
            name=self.bucketlist_item_name, bucketlist_id=bucketlist.id
        )
        bucketlist_item2 = BucketListItem(
            name=self.bucketlist_item2_name, bucketlist_id=bucketlist2.id
        )
        bucketlist_item3 = BucketListItem(
            name=self.bucketlist_item3_name, bucketlist_id=bucketlist3.id
        )
        db.session.add_all([bucketlist_item, bucketlist_item2,
                            bucketlist_item3])
        db.session.commit()
        self.client = self.app.test_client()
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     self.client = self.app.test_client()
     self.payload1 = json.dumps({
         "email": "*****@*****.**",
         "password": "******"
     })
Example #4
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.drop_all()
     db.create_all()
     user = User(username=self.default_username,
                 password=self.default_password)
     db.session.add(user)
     db.session.commit()
     self.client = self.app.test_client()
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.drop_all()
     db.create_all()
     user = User(username=self.default_username,
                 password=self.default_password)
     db.session.add(user)
     db.session.commit()
     self.client = self.app.test_client()
Example #6
0
    def setUp(self):
        self.app = create_app("testing")
        self.client = self.app.test_client
        self.question = json.dumps(
            dict({
                "title": "Which instance is this?",
                "user_id": 1
            }))
        self.user = json.dumps(
            dict({
                "username": "******",
                "email": "*****@*****.**",
                "password": "******"
            }))

        # binding app to the current context
        with self.app.app_context():
            db.create_all()
Example #7
0
import os
from sqlalchemy import create_engine
from config import db_uri

# Initialize a db connection
mysql_engine = create_engine(db_uri)
# Create Database if it does not already exist
mysql_engine.execute('CREATE DATABASE IF NOT EXISTS {0}'.format(
    os.getenv('DB_NAME')))
# Import app and db instance and create tables from models
from api.app import app, db
with app.app_context():
    db.create_all()
Example #8
0
def create_db():
    db.create_all()
    db.session.commit()
Example #9
0
from api.models import Metric, User, Markets, tags
from api.app import db, create_app

db.create_all(app=create_app())
Example #10
0
def _db(app):
    db.app = app
    db.create_all()
    yield db
    db.drop_all()
Example #11
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     self.client = self.app.test_client()
     self.user = User(id=1,
                      email="*****@*****.**",
                      password=generate_password_hash("password123",
                                                      method='sha256'))
     self.ticker1 = 'KRAKEN:BTCEUR'
     self.ticker2 = 'BINANCE:BTCUSDT'
     self.met1 = Metric(market_id=1,
                        close_time=1610100960.0,
                        open_price=9580.0,
                        high=39680.0,
                        low=39574.7,
                        close=39604.1,
                        volume=0.06128536,
                        volume_quote=8521.798796526)
     self.met2 = Metric(market_id=1,
                        close_time=1610123701.08435,
                        open_price=9580.0,
                        high=39680.0,
                        low=39574.7,
                        close=39604.1,
                        volume=0.21523387,
                        volume_quote=8521.798796526)
     self.met3 = Metric(market_id=1,
                        close_time=1610124061.41182,
                        open_price=9580.0,
                        high=39680.0,
                        low=39574.7,
                        close=39604.1,
                        volume=3.33267696,
                        volume_quote=8521.798796526)
     self.met4 = Metric(market_id=1,
                        close_time=1610124121.44782,
                        open_price=9580.0,
                        high=39680.0,
                        low=39574.7,
                        close=39604.1,
                        volume=8.54355811,
                        volume_quote=8521.798796526)
     self.met5 = Metric(market_id=2,
                        close_time=1610100960.0,
                        open_price=9580.0,
                        high=39680.0,
                        low=39574.7,
                        close=39604.1,
                        volume=5,
                        volume_quote=8521.798796526)
     self.met6 = Metric(market_id=2,
                        close_time=1610123701.08435,
                        open_price=9580.0,
                        high=39680.0,
                        low=39574.7,
                        close=39604.1,
                        volume=10,
                        volume_quote=8521.798796526)
     self.met7 = Metric(market_id=2,
                        close_time=1610124061.41182,
                        open_price=9580.0,
                        high=39680.0,
                        low=39574.7,
                        close=39604.1,
                        volume=2,
                        volume_quote=8521.798796526)
     self.met8 = Metric(market_id=2,
                        close_time=1610124121.44782,
                        open_price=9580.0,
                        high=39680.0,
                        low=39574.7,
                        close=39604.1,
                        volume=8,
                        volume_quote=8521.798796526)