Esempio n. 1
0
	def run(self):
		db.drop_all()
		db.create_all()
		db.session.add(Group('Diggers', 'Preschool'))
		db.session.add(Group('Discoverers', 'Year R-2'))
		db.session.add(Group('Explorers', 'Years 3-6'))
		db.session.commit()
Esempio n. 2
0
def init_db():
    db.drop_all()
    db.create_all()
    type_ids = {}
    rate_type_ids = {}
    for type_name in ["office", "meeting", "other"]:
        t = ListingType(type_name)
        db.session.add(t)
        db.session.commit()
        type_ids[type_name] = t
    for type_name in ["Hour", "Day", "Week", "Month", "3 Months", "6 Months", "Year"]:
        t = RateType(type_name)
        db.session.add(t)
        db.session.commit()
        rate_type_ids[type_name] = t
    db.session.add(Listing(address="1500 Union Ave #2500, Baltimore, MD",
                           lat="39.334497", lon="-76.64081",
                           name="Headquarters for Maryland Nonprofits", space_type=type_ids["office"], price=2500,
                           description="""Set in beautiful downtown Baltimore, this is the perfect space for you.

1800 sq ft., with spacious meeting rooms.

Large windows, free wifi, free parking, quiet neighbors.""", contact_phone="55555555555", rate_type=rate_type_ids['Month']))
    db.session.add(Listing(address="6695 Dobbin Rd, Columbia, MD",
                           lat="39.186198", lon="-76.824842",
                           name="Frisco Taphouse and Brewery", space_type=type_ids["meeting"], price=1700,
                           description="""Large open space in a quiet subdivision near Columbia.

High ceilings, lots of parking, good beer selection.""", rate_type=rate_type_ids['Day'], contact_phone="55555555555", expires_in_days=-1))
    db.session.add(Account("admin", "*****@*****.**", "Pass1234"))
    db.session.commit()
Esempio n. 3
0
 def run(app=app):
     """
     Creates the database in the application context
     :return: no return
     """
     with app.app_context():
         db.drop_all()
    def tearDown(self):
        """
        Remove/delete the database and the relevant connections
!
        :return: no return
        """
        db.session.remove()
        db.drop_all()
Esempio n. 5
0
def testdb():
  #if db.session.query("1").from_statement("SELECT 1").all():
  #  return 'It works.'
  #else:
  #  return 'Something is broken.'   
  db.drop_all()
  db.create_all()
  return "i got here"
    def tearDown(self):
        db.session.remove()
        db.drop_all()

        os.close(self.db_fd)
        os.unlink(self.dbname)

        if self._ctx is not None:
            self._ctx.pop()
Esempio n. 7
0
    def tearDown(self):
        info("Drop tables.")

        # Otherwise hangs at drop_all.
        # More info: http://stackoverflow.com/questions/24289808/
        db.session.commit()

        db.drop_all()
        info("Tables dropped.")
Esempio n. 8
0
def create_db():
    db.drop_all()
    # db.configure_mappers()
    db.create_all()

    create_characters()
    create_houses()
    create_books()

    db.session.commit()
Esempio n. 9
0
    def tearDown(self):
        log.debug("Drop tables.")

        # Otherwise hangs at drop_all.
        # More info: http://stackoverflow.com/questions/24289808/
        db.session.commit()

        with app.app_context():
            db.drop_all()
        log.debug("Tables dropped.")
Esempio n. 10
0
 def tearDown(self):
     """
     Ensures that the database is emptied for next unit test
     """
     db.session.remove()
     db.drop_all()
     try:
         user = User.query.all()
     except Exception as e:
         assert e
Esempio n. 11
0
    def setUpClass(cls):
        cls.app = app
        cls.app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://*****:*****@localhost:5432/test_factory_boy'
        cls.app.config['SQLALCHEMY_ECHO'] = True
        db.app = cls.app

        db.init_app(cls.app)
        cls._ctx = cls.app.test_request_context()
        cls._ctx.push()
        db.drop_all()
        db.create_all()
Esempio n. 12
0
def createdb(testdata=False):
    """Initializes the database"""
    app = create_app()
    with app.app_context():
        db.drop_all()
        db.create_all()
        if testdata:
            user = User(username='******', password='******')
            db.session.add(user)

            db.session.commit()
Esempio n. 13
0
def db(app, request):
    """Function-wide test database."""
    _db.create_engine(
        app.config['SQLALCHEMY_DATABASE_URI'], convert_unicode=True
    )
    _db.drop_all()
    _db.create_all()

    yield _db

    # Teardown
    _db.drop_all()
Esempio n. 14
0
def init_all():
    db.drop_all()
    db.create_all()
    init_descriptions(current_app.file_root)
    init_abilities()
    init_races()
    init_skills()
    init_classes()
    init_messages()
    init_characters()
    init_handlers()
    init_items()
    init_knowledge()
    init_alignments()
Esempio n. 15
0
def reload_all():
    db.drop_all()
    db.create_all()

    with open(DATA_PATH) as f:
        data = loads(f.read())

    ability_map = {}
    for ability_data in data['abilities']:
        ability = Ability(ability_data['name'], ability_data['abbreviation'], ability_data['description'])
        ability_map[ability_data['id']] = ability
        db.session.add(ability)

    skill_map = {}
    for skill_data in data['skills']:
        ability = ability_map[skill_data['ability_id']]
        skill = Skill(skill_data['name'], ability, skill_data['description'])
        skill_map[skill_data['id']] = skill
        db.session.add(skill)

    alignment_map = {}
    for alignment_data in data['alignments']:
        alignment = Alignment(alignment_data['name'], alignment_data['description'])
        alignment_map[alignment_data['id']] = alignment
        db.session.add(alignment)

    race_map = {}
    for race_data in data['races']:
        race = Race(race_data['name'], race_data['description'])
        race_map[race_data['id']] = race
        db.session.add(race)

    class_map = {}
    for class_data in data['classes']:
        character_class = CharacterClass(class_data['name'], class_data['description'])
        class_map[class_data['id']] = character_class
        db.session.add(character_class)

    item_type_map = {}
    for item_type_data in data['item_types']:
        item_type_id = item_type_data['id']
        del item_type_data['id']
        item_type = ItemType(**item_type_data)
        item_type_map[item_type_id] = item_type
        db.session.add(item_type)

    db.session.commit()
    print data
    return data
Esempio n. 16
0
def initdb(newinstance=False):
    # Destroy and recreate tables
    ctx = app.test_request_context()
    ctx.push()
    if newinstance:
        db.drop_all()
    db.create_all()  
    categories = ['Projector', 'Camera', 'Laptop', 'Modem', 'Printer']
    for c in categories:
        if not DBCategory.query.filter(DBCategory.name == c).first():
            db.session.add(DBCategory(c)) 
    if not DBUser.query.filter(DBUser.username == 'admin').first():
        db.session.add(DBUser('admin', 'admin'))
        db.session.add(DBUser('jnhdny', 'steel'))
    DBUser.query.filter(DBUser.id > 2).delete()
    # Must commit to save
    db.session.commit()
    ctx.pop()
Esempio n. 17
0
def create_db():
	db.drop_all()
	db.create_all()

	create_users()
	create_projects()

	db.session.commit()

	print()
	print('The database contains:')
	for user in User.query.all():
		print(repr(user))
		print('\tid:', user.id)
		print('\tname:', user.name)
	for project in Project.query.all():
		print(repr(project))
		print('\tid:', project.id)
		print('\tname:', project.name)
		print('\tauthor:', project.author)
		print('\tdescription:', project.description)
Esempio n. 18
0
 def run(self, **kwargs):
     db.drop_all()
     db.create_all()
Esempio n. 19
0
def create_schema():
    db.drop_all()
    db.create_all()
Esempio n. 20
0
def create():
    db.drop_all()
    db.create_all()
    return redirect(url_for('index'))
Esempio n. 21
0
from unittest import TestCase

from app import app
from models import db, Cupcake

# Use test database and don't clutter tests with SQL
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql:///cupcakes_test'
app.config['SQLALCHEMY_ECHO'] = False

# Make Flask errors be real errors, rather than HTML pages with error info
app.config['TESTING'] = True

db.drop_all()
db.create_all()


CUPCAKE_DATA = {
    "flavor": "TestFlavor",
    "size": "TestSize",
    "rating": 5,
    "image": "http://test.com/cupcake.jpg"
}

CUPCAKE_DATA_2 = {
    "flavor": "TestFlavor2",
    "size": "TestSize2",
    "rating": 10,
    "image": "http://test.com/cupcake2.jpg"
}

Esempio n. 22
0
def resetdb():
    if click.confirm('This will drop all tables are you sure'):
        db.drop_all()
        db.create_all()
Esempio n. 23
0
 def tearDown(self):
     db.session.rollback()
     db.drop_all()
     self.ctx.pop()
Esempio n. 24
0
 def tearDown(self):
     db.session.rollback()
     db.drop_all()
Esempio n. 25
0
 def tearDown(self):
     db.drop_all()
Esempio n. 26
0
def initdb_command():
    """Creates the database tables."""
    db.drop_all()
    db.create_all()
    print('Initialized the database.')
Esempio n. 27
0
def initdb_command():
    db.drop_all()
    db.create_all()
    print('Initialized the database.')
Esempio n. 28
0
    def setUp(self):
        """ starts with a clean slate """

        db.drop_all()
        db.create_all()
Esempio n. 29
0
def initdb():
    """Initialize the database."""
    click.echo('Initialize the database')
    with app.app_context():
        db.drop_all()
        db.create_all()
Esempio n. 30
0
    def tearDown(self):
        """Do at end of every test."""

        db.session.close()
        db.drop_all()
Esempio n. 31
0
 def setUp(self):
     db.drop_all()
     db.create_all()
Esempio n. 32
0
 def trunCate(self):
     db.drop_all()
     db.create_all()
Esempio n. 33
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Esempio n. 34
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
     self.app_context.pop()
Esempio n. 35
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Esempio n. 36
0
 def tearDown(self):
     with self.app.app_context():
         db.drop_all()
Esempio n. 37
0
 def tearDownClass(cls):
     db.drop_all()
Esempio n. 38
0
    def setUp(self):
        self.app = create_app("testing.json", VERSION)
        self.client = self.app.test_client
        self.url = '/api/v1'

        self.testing_user = {'name': 'Testing User',
                             'email': 'testing@glucolog',
                             'password': '******',
                             'birthday': '2015-09-20',
                             'sex': Sex.male.value,
                             'diabetes': DiabetesType.one.value,
                             'detection': '2018-03-02'}

        self.weight_records = [{'takenAt': '2018-03-02', 'value': 20},
                               {'takenAt': '2018-03-15', 'value': 25},
                               {'takenAt': '2018-04-02', 'value': 22},
                               {'takenAt': '2018-04-17', 'value': 23},
                               {'takenAt': '2018-05-01', 'value': 28},
                               {'takenAt': '2018-06-03', 'value': 35}]

        self.glycaemia_records = [{'takenAt': '2018-03-02 08:20:01', 'value': 90},
                                  {'takenAt': '2018-03-02 10:30:31', 'value': 120},
                                  {'takenAt': '2018-03-02 12:05:16', 'value': 90},
                                  {'takenAt': '2018-03-02 6:00:50', 'value': 160},
                                  {'takenAt': '2018-05-01 20:42:20', 'value': 130}]

        self.record_photo = {'url': 'https://DUMMY/URL'}
        self.glycaemia_record_photo_id = -1
        self.weight_record_photo_id = -1
        self.key_record_id = -1

        self.key_record_password = ''
        self.key_record_username = ''

        self.state_records = ['fasting', 'post-meal']

        jwt = JWTManager(self.app)

        @jwt.token_in_blacklist_loader
        def check_if_token_in_blacklist(decrypted_token):
            jti = decrypted_token['jti']
            return RevokedTokenModel.is_jti_blacklisted(jti)

        with self.app.app_context():
            db.drop_all()
            db.create_all()

            for state in self.state_records:
                record = StateModel(state)
                db.session.add(record)

            db.session.commit()

            user = UserModel(self.testing_user.get('email'), self.testing_user.get('password'))
            user.name = self.testing_user.get('name')
            user.birthday = datetime.datetime.strptime(self.testing_user.get('birthday'), "%Y-%m-%d").date()
            user.detection = datetime.datetime.strptime(self.testing_user.get('detection'), "%Y-%m-%d").date()
            user.sex = self.testing_user.get('sex')
            user.diabetes = self.testing_user.get('diabetes')
            db.session.add(user)

            db.session.commit()

            UserModel.query.filter_by(email=self.testing_user.get('email')).first()

            for record in self.weight_records:
                weight = WeightModel(user.id)
                weight.value = record.get('value')
                weight.takenAt = datetime.datetime.strptime(record.get('takenAt'), "%Y-%m-%d").date()
                db.session.add(weight)

            db.session.commit()

            for record in self.glycaemia_records:
                glycemia = GlycaemiaModel(user.id)
                glycemia.value = record.get('value')

                rand = round(random.uniform(0, 1))
                state = self.state_records[rand]
                state = StateModel.getByDescription(state).id
                glycemia.state_id = state
                glycemia.comment = "random record {}".format(state)
                glycemia.takenAt = datetime.datetime.strptime(record.get('takenAt'), "%Y-%m-%d %H:%M:%S").date()
                db.session.add(glycemia)

            db.session.commit()

            last_glycemia_record = GlycaemiaModel.findByUserId(user.id).pop().id
            glycemia_record_photo = GlycaemiaPhotoModel(last_glycemia_record)
            glycemia_record_photo.url = self.record_photo.get('url')
            db.session.add(glycemia_record_photo)

            db.session.commit()

            last_weight_record = WeightModel.findByUserId(user.id).pop().id
            weight_record_photo = WeightPhotoModel(last_weight_record)
            weight_record_photo.url = self.record_photo.get('url')
            db.session.add(weight_record_photo)

            db.session.commit()

            key = KeyModel(user.id)
            key.value = KeyModel.generateKey()
            self.key_record_password = key.value
            key.username = '******'
            self.key_record_username = key.username
            db.session.add(key)

            db.session.commit()

            self.glycaemia_record_photo_id = last_glycemia_record
            self.weight_record_photo_id = last_weight_record
            self.key_record_id = KeyModel.getByUsername('testing01').id
Esempio n. 39
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Esempio n. 40
0
def clear_tables():
    db.drop_all()
    print("   Deleted tables")
Esempio n. 41
0
    def setUp(self):
        """create test user and specimens"""

        # db.session.close()
        db.session.close()
        db.drop_all()
        db.create_all()

        user1 = User.signup("tester1", "password1", None, None, None)
        user1id = 11
        user1.id = user1id

        specimen1 = Specimen(
            link="https://i.imgur.com/pMkflKn.jpg",
            user_id=11,
        )
        specimen1id = 12
        specimen1.id = specimen1id

        specimen1taxonomy = Taxonomy(
            common_name="Red Oak",
            specimen_id=12,
            species="Quercus rubra",
            genus="Quercus",
            family="Fagaceae",
            order="Fagales",
            phylum="Tracheophyta",
            kingdom="Plantae",
            authorship="L.",
        )

        specimen1details = Details(
            specimen_id=12,
            date="3-12-2019",
            location="Rock Bridge State Park",
            habitat="NE-facing slope",
            county="Boone",
            state="Missouri",
            notes="No Notes",
        )

        specimen2 = Specimen(
            link="https://i.imgur.com/pMkflKn.jpg",
            user_id=11,
        )
        specimen2id = 13
        specimen2.id = specimen2id

        specimen2taxonomy = Taxonomy(
            common_name=None,
            specimen_id=13,
            species=None,
            genus=None,
            family=None,
            order=None,
            phylum=None,
            kingdom=None,
            authorship=None,
        )

        specimen2details = Details(
            specimen_id=13,
            date="3-12-2019",
            location=None,
            habitat="",
            county=None,
            state=None,
            notes=None,
        )

        db.session.add_all([
            specimen1,
            specimen1taxonomy,
            specimen1details,
            specimen2,
            specimen2taxonomy,
            specimen2details,
        ])

        db.session.commit()
Esempio n. 42
0
    def setUp(self):
        """Make sure we start with a clean slate"""

        db.drop_all()
        db.create_all()
Esempio n. 43
0
 def teardown():
     _db.drop_all()
     os.unlink(TEST_DB_PATH)
Esempio n. 44
0
def init_dev_data():
    """Initializes database with data for development and testing"""
    db.drop_all()
    db.create_all()

    print("Initialized Cashify Database.")
    a1 = Account(balance=400.00)
    u1 = User(username="******", password_hash="Vogel")
    a2 = Account(balance=0.00)
    u2 = User(username="******", password_hash="Torpey")

    db.session.add(a1)
    db.session.add(u1)
    db.session.add(a2)
    db.session.add(u2)

    u1.account = a1
    u2.account = a2

    # Transaction dummy data for Tyler
    balance = 400.00
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t1 = Transaction(amount=amount, date="2019-05-11", category="Other", current_balance=round(balance, 2))
    db.session.add(t1)
    a1.transactions.append(t1)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t2 = Transaction(amount=amount, date="2019-05-11", category="Income", current_balance=round(balance, 2))
    db.session.add(t2)
    a1.transactions.append(t2)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t3 = Transaction(amount=amount, date="2019-06-11", category="Entertainment", current_balance=round(balance, 2))
    db.session.add(t3)
    a1.transactions.append(t3)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t4 = Transaction(amount=amount, date="2019-06-11", category="Restaurants", current_balance=round(balance, 2))
    db.session.add(t4)
    a1.transactions.append(t4)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t5 = Transaction(amount=amount, date="2019-06-11", category="Restaurants", current_balance=round(balance, 2))
    db.session.add(t5)
    a1.transactions.append(t5)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t6 = Transaction(amount=amount, date="2019-07-04", category="Savings", current_balance=round(balance, 2))
    db.session.add(t6)
    a1.transactions.append(t6)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t7 = Transaction(amount=amount, date="2019-07-06", category="Income", current_balance=round(balance, 2))
    db.session.add(t7)
    a1.transactions.append(t7)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t8 = Transaction(amount=amount, date="2019-07-08", category="Other", current_balance=round(balance, 2))
    db.session.add(t8)
    a1.transactions.append(t8)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t9 = Transaction(amount=amount, date="2019-07-10", category="Groceries", current_balance=round(balance, 2))
    db.session.add(t9)
    a1.transactions.append(t9)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t10 = Transaction(amount=amount, date="2019-07-12", category="Utilities", current_balance=round(balance, 2))
    db.session.add(t10)
    a1.transactions.append(t10)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t11 = Transaction(amount=amount, date="2019-07-14", category="Other", current_balance=round(balance, 2))
    db.session.add(t11)
    a1.transactions.append(t11)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t12 = Transaction(amount=amount, date="2019-07-15", category="Other", current_balance=round(balance, 2))
    db.session.add(t12)
    a1.transactions.append(t12)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t13 = Transaction(amount=amount, date="2019-07-16", category="Income", current_balance=round(balance, 2))
    db.session.add(t13)
    a1.transactions.append(t13)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t14 = Transaction(amount=amount, date="2019-07-18", category="Entertainment", current_balance=round(balance, 2))
    db.session.add(t14)
    a1.transactions.append(t14)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t15 = Transaction(amount=amount, date="2019-07-19", category="Other", current_balance=round(balance, 2))
    db.session.add(t15)
    a1.transactions.append(t15)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t16 = Transaction(amount=amount, date="2019-07-19", category="Auto", current_balance=round(balance, 2))
    db.session.add(t16)
    a1.transactions.append(t16)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t17 = Transaction(amount=amount, date="2019-07-20", category="Income", current_balance=round(balance, 2))
    db.session.add(t17)
    a1.transactions.append(t17)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t18 = Transaction(amount=amount, date="2019-07-22", category="Healthcare", current_balance=round(balance, 2))
    db.session.add(t18)
    a1.transactions.append(t18)
    amount = -round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t19 = Transaction(amount=amount, date="2019-07-22", category="Restaurants", current_balance=round(balance, 2))
    db.session.add(t19)
    a1.transactions.append(t19)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t20 = Transaction(amount=amount, date="2019-07-23", category="Other", current_balance=round(balance, 2))
    db.session.add(t20)
    a1.transactions.append(t20)
    amount = round(random.uniform(1.00, 100.00), 2)
    balance += amount
    t21 = Transaction(amount=amount, date="2019-07-24", category="Other", current_balance=round(balance, 2))
    db.session.add(t21)
    a1.transactions.append(t21)

    a1.balance = balance


    #Setup Budget
    b = Budget(income = 1000, rent = 200, education = 100, groceries = 50, 
    home_improvement = 50, entertainment = 75, savings = 100, utilities = 25, \
    auto_gas = 50, healthcare = 50, restaurants = 50, shopping = 50, travel = 100, other = 200)

    a1.budget = b

    db.session.commit()
    print("Added dummy data.")
Esempio n. 45
0
# python3 run.py

from models import app, db, Role, User, Post_user
from generator import Generator
from random import randint

gener = Generator()

# Удали
db.drop_all()  # Удали. Это удаляет все таблицы.
# Удали

# Создает файл базы данных и все таблицы
db.create_all()
print("Создана база данных: " + app.config['SQLALCHEMY_DATABASE_URI'])

# Список ролей для таблицы Role
role_list = ["Admin", "Moderator", "User", "visitor"]

# Список начальных пользователей
users_list = ["God", "Son", "Spirit", "Human"]

# Записывает роли в таблицу Role.(добавляет в сессию базы данных)
for role in role_list:
    role_db = Role(name=role)
    # Добавляет в сессию базы данных
    db.session.add(role_db)

# Записывает пользователей в таблицу User.
i = 1
for use in users_list:
Esempio n. 46
0
 def init_db():
     db.drop_all()
     db.create_all()
Esempio n. 47
0
def reset_recommendations():
    """ Removes all recommendations from the database """
    db.session.remove()
    db.drop_all()
    init_db()
    return make_response('', status.HTTP_204_NO_CONTENT)
Esempio n. 48
0
def reset_db():
    """Reinitializes the database"""
    db.drop_all()
    db.create_all()

    print('Initialized the database.')
Esempio n. 49
0
 def setUp(self):
     stripe.api_key = "sk_test_OM2dp9YnI2w5eNuUKtrxd56g"
     db.drop_all()
     db.create_all()
Esempio n. 50
0
def initdb():
    db.drop_all()
    db.create_all()
    db.session.commit()
Esempio n. 51
0
def drop():
    db.drop_all()
Esempio n. 52
0
	def setUp(self):
		db.session.close()
		db.drop_all()
		db.create_all()

		self.client = app.test_client()
Esempio n. 53
0
 def tearDown(self):
     db.drop_all()
Esempio n. 54
0
def dbinit(): 
     db.drop_all()
     db.create_all()
Esempio n. 55
0
 def tearDown(self):
     db.session.close_all()
     db.drop_all()
Esempio n. 56
0
def testdb():
    db.drop_all()
    db.create_all()
    return redirect(url_for('home'))
Esempio n. 57
0
 def setUp(self):
     Item.init_db(app)
     db.drop_all()  # clean up the last tests
     db.create_all()  # make our sqlalchemy tables
Esempio n. 58
0
    def setUp(self):
        """Create test client, add sample data"""

        db.drop_all()
        db.create_all()

        self.client = app.test_client()

        self.testuser = User.signup(
            username="******", email="*****@*****.**", password="******",
        )
        self.testuser_id = 100
        self.testuser.id = self.testuser_id

        self.otheruser = User.signup(
            username="******", email="*****@*****.**", password="******",
        )

        self.otheruser_id = 200
        self.otheruser.id = self.otheruser_id

        self.testproject = Project(
            name="Project_Test", description="Project_Test test description.",
        )
        self.testproject_name = self.testproject.name
        self.testproject_id = 110
        self.testproject.id = self.testproject_id
        db.session.add(self.testproject)

        self.testplot = Plot(
            name="Plot_Test",
            width=5,
            length=10,
            description="Plot_Test test description.",
        )
        self.testplot_name = self.testplot.name
        self.testplot_id = 120
        self.testplot.id = self.testplot_id
        db.session.add(self.testplot)

        self.testplantlist = PlantList(
            name="Plantlist_Test", description="Plantlist_Test test description.",
        )
        self.testplantlist_name = self.testplantlist.name
        self.testplantlist_id = 130
        self.testplantlist.id = self.testplantlist_id
        db.session.add(self.testplantlist)

        self.testplant = Plant(
            trefle_id=1231,
            slug="plantus-slugs1",
            common_name="common plant1",
            scientific_name="plantus testus1",
            family="Plantaceae1",
            family_common_name="Plant Family1",
        )
        self.testplant_common_name = self.testplant.common_name
        self.testplant_id = 140
        self.testplant.id = self.testplant_id

        db.session.add(self.testplant)

        self.testsymbol = Symbol(
            symbol="<i class='symbol fas fa-seedling' style='color:#228B22;'></i>"
        )

        self.testsymbol_id = 1
        self.testsymbol.id = self.testsymbol_id
        db.session.add(self.testsymbol)

        # Connections
        self.testuser.projects.append(self.testproject)
        self.testuser.plots.append(self.testplot)
        self.testuser.plantlists.append(self.testplantlist)
        self.testproject.plots.append(self.testplot)
        self.testproject.plantlists.append(self.testplantlist)
        self.testplot.plantlists.append(self.testplantlist)
        self.testplantlist.plants.append(self.testplant)

        db.session.commit()
from models import db, User, get_pair_list, get_user_list, \
    clear_all_users, clear_all_pairs, get_user_from_user_id

db.drop_all()
db.create_all()

clear_all_users()
clear_all_pairs()
dom = User("Dom", "dom@dom")
arthur = User("Arthur", "arthur@arthur")
isobel = User("Isobel", "isobel@isobel")
joe = User("Joe", "joe@joe")
dom.start()
arthur.start()
isobel.start()
joe.start()

user_list = get_user_list()
print "user list is: ", user_list
pair_list = get_pair_list()
print pair_list

# new match - success

dom_next_pair = dom.get_next_pair()
print "Dom's next pair is: ", dom_next_pair

match1 = dom.make_pair_match(dom_next_pair)
print "Made match 1 with id: ", match1.id

# new match - success
Esempio n. 60
0
def init_db():
    """Initializes database and any model objects necessary for assignment"""
    db.drop_all()
    db.create_all()

    print("Initialized Cashify Database.")