Ejemplo n.º 1
0
def client():
    app.config.from_object('master.config.TestingConfig')
    client = app.test_client()

    # Initial data
    car = CarModel(
        car_number='KK0001',
        make='Toyota',
        body_type='Sedan',
        colour='black',
        seats=5,
        latitude=-37.804663448,
        longitude=144.957996168,
        cost_per_hour=12,
        lock_status=True,
    )
    booking = BookingModel(
        car_number='KK0001',
        username='******',
        departure_time=datetime.date(2020, 6, 5),
        return_time=datetime.date(2020, 6, 12),
    )
    with app.app_context():
        db.drop_all()
        db.create_all()
        car.save_to_db()
        booking.save_to_db()
        db.session.commit()

    yield client
def client():
    app.config.from_object('master.config.TestingConfig')
    client = app.test_client()

    # Initial data
    user = UserModel(
        username='******',
        password=sha256.hash('password01'),
        first_name='Apple',
        last_name='Chan',
        email='*****@*****.**',
    )

    with app.app_context():
        db.drop_all()
        db.create_all()
        user.add_new_record()
        db.session.commit()

    yield client
Ejemplo n.º 3
0
#This program is used to create master.db i.e the database
from master import db
db.create_all()
exit()
Ejemplo n.º 4
0
from migrate.versioning import api
from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
from master import db
import os.path
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))