示例#1
0
 def setUp(self):
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     Role.insert_roles()
     self.client = self.app.test_client()
示例#2
0
    def setUp(self):
        self.app = app
        self.app.config['TESTING'] = True
        self.app.config['WTF_CSRF_ENABLED'] = False
        self.app.config['DEBUG'] = False
        self.app.config[
            'SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(
                basedir, TEST_DB)
        self.appd = app.test_client()
        self.client = self.app.test_client
        self.request = {
            'title': 'title 1',
            'description': "description 2",
            'client': 1,
            'priority': 1,
            'target_date': '2018-11-06',
            'product': 'claims'
        }

        db.create_all()
 def create_test_tables(self):
     """
     Creates the current model on the testing database and inserts some
     well-known sample data.
     """
     # Binds the app to the current context
     with self.app.app_context():
         # Creates the current model on the testing database
         db.create_all()
         # Adds the test entries to the database with a unique bulk operation
         objects = [
             Currency(iso_code='GBP',
                      description='Pound sterling',
                      symbol='£'),
             Product(name='Lavender heart', price=9.25, currency_iso='GBP'),
             Product(name='Personalised cufflinks',
                     price=45.,
                     currency_iso='GBP'),
             Product(name='Kids T-shirt', price=19.95, currency_iso='GBP')
         ]
         db.session.bulk_save_objects(objects)
         db.session.commit()
示例#4
0
from main_app import db

db.create_all()
示例#5
0
def create_db():
    db.drop_all()
    db.create_all()
    db.session.commit()
示例#6
0
att_li.append(att_2)
att_3 = Attribute(att_desc="Prone to Animal Welfare Pitfalls",
                  att_pos_neg=False)
att_li.append(att_3)
att_4 = Attribute(att_desc="Often Imported; Transportation Resource Intensive",
                  att_pos_neg=False)
att_li.append(att_4)
att_5 = Attribute(att_desc="Considered healthy, contains nutrients",
                  att_pos_neg=True)
att_li.append(att_5)

# [LINK ATTs] ----------------------------------------------------------------------------------------------------
# Link the attributes to the ingredients
ing_avacados.attributes.append(att_1)
ing_avacados.attributes.append(att_4)
ing_avacados.attributes.append(att_5)
ing_zucchini.attributes.append(att_2)


def add_data():
    db.session.add_all([fg_fruit, fg_grain, fg_veggie, fg_protein, fg_dairy])
    for ing in ing_li:
        db.session.add(ing)
    db.session.commit()


if __name__ == "__main__":
    db.drop_all()  # Drop all the tables in the DB to make new ones
    db.create_all()  # Create all tables in the DB
    add_data()
    db.session.commit()
 def setUp(self):
     app.config['SQLALCHEMY_DATABSE_URL'] = 'sqlite://'
     db.create_all()
示例#8
0
from main_app import Post, db

# create database
db.create_all()

# insert data
db.session.add(Post("GOOD", "I AM GOOD"))
db.session.add(Post("WELL", "I AM LLLL"))
db.session.add(Post("EVIL", "Y're EVIL"))

# commit database
db.session.commit()