def seed_db(): global test_driver_id global cust1_id global cust2_id global test_note_text db.drop_all() db.create_all() test_driver = User(email="*****@*****.**", token="testToken", api_id='demo') cust1 = Customer(**cust1_data) cust2 = Customer(**cust2_data) db.session.add(cust1) db.session.add(cust2) db.session.add(test_driver) db.session.commit() test_note_text = "HELLO THERE!" note = Note(driver_id=test_driver.id, cust_id=cust1.id, note=test_note_text) db.session.add(note) db.session.commit() # variables to reference test_driver_id = test_driver.id cust1_id = cust1.id cust2_id = cust2.id test_note_text = test_note_text
def seed_db(): global test_driver_id global cust1_id global cust2_id db.session.rollback() db.drop_all() db.create_all() test_driver = User(email="*****@*****.**", token="testToken", api_id='demo') cust1 = Customer(**cust1_data) cust2 = Customer(**cust2_data) db.session.add(cust1) db.session.add(cust2) db.session.add(test_driver) db.session.commit() # global variables test_driver_id = test_driver.id cust1_id = cust1.id cust2_id = cust2.id
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['DEBUG'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + TEST_DB self.app = app.test_client() db.drop_all() db.create_all()
def seed_the_db(): global user_id db.session.rollback() db.drop_all() db.create_all() test_user = User(**user_data) db.session.add(test_user) db.session.commit() # variables to reference user_id = test_user.id
def seed_db(): db.session.rollback() global test_driver_id global test_cust_id global test_delivery_id global test_order_id global order_data db.drop_all() db.create_all() user_data = {"email": "*****@*****.**", "token": "testToken", api_id='demo'} cust_data = {"id": '1', "name": "testuser1", "address": "Some Address", "phone": "203-881-7843"} test_driver = User(**user_data) test_cust = Customer(**cust_data) db.session.add(test_cust) db.session.add(test_driver) db.session.commit() delivery_data = {"driver_id": test_driver.id} test_delivery = Delivery(**delivery_data) db.session.add(test_delivery) db.session.commit() order_data = {"num": 112, "cust_id": test_cust.id, "del_id": test_delivery.id, "driver_id": test_driver.id, "date": datetime.date(2021, 4, 19)} test_order = Order(**order_data) db.session.add(test_order) db.session.commit() test_driver_id = test_driver.id test_cust_id = test_cust.id test_delivery_id = test_delivery.id test_order_id = (test_order.num, test_order.date)
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker import itertools import db_setup from db_setup import DeckSQL, Hand, HandByCard, Subject, Sets, Found, db from setGame import Deck, getCards, isSetThreeCards, getNhands db.drop_all() db.create_all() session = db.session # no need to retun this ever! cards already exist. hands = session.query(Hand).all() currentdeck = Deck({'number':[0,1,2,3],'symbol':[0,1,2,3], 'color':[0,1,2,3]}) #encoded into dict: 0 = super_small_decks, 1 = small, 2 = large, 3 = super large allHands = { # 0:[ # [[0, 0, 0], [0, 2, 0], [3, 3, 3], [1, 0, 2], [1, 0, 3], [3, 2, 0], [3, 0, 0], [2, 2, 1], [2, 3, 0], [1, 2, 1], [1, 3, 1], [1, 0, 1]], # [[1, 3, 2], [3, 0, 1], [2, 1, 2], [1, 0, 3], [2, 1, 1], [3, 1, 3], [1, 0, 2], [1, 2, 2], [1, 2, 1], [2, 2, 1], [1, 3, 1], [3, 0, 2]], # [[2, 1, 3], [1, 1, 1], [3, 3, 0], [3, 3, 3], [3, 1, 3], [1, 0, 2], [0, 0, 2], [1, 0, 1], [3, 1, 1], [1, 1, 2], [1, 3, 1], [1, 3, 2]],
def create_db(): db.drop_all() db.create_all() db.session.commit()
def tearDown(self): db.drop_all()