def test_commit_rooms(self, mock_livingspaces, mock_offices): mock_livingspaces.__iter__.return_value = ['Michigan'] mock_offices.__iter__.return_value = ['Camelot'] create_db('test_amity.db') msg = self.room.commit_rooms('test_amity.db') self.assertEqual(msg, 'rooms committed to session')
def test_commit_people(self, mock_staff_not_allocated_office, mock_fellows_not_allocated_office, mock_unallocated_people, mock_staff, mock_fellows, mock_livingspaces, mock_offices): mock_livingspaces.__iter__.return_value = ['python'] mock_offices.__iter__.return_value = ['oculus', 'mordor'] mock_fellows.__iter__.return_value = ['Migwi'] mock_staff.__iter__.return_value = ['jojo', 'jimbo'] mock_staff_not_allocated_office.__iter__.return_value = ['jimbo'] mock_fellows_not_allocated_office.__iter__.return_value = [] mock_unallocated_people.__iter__.return_value = [] create_db('elsis.db') msg = self.person.commit_people('elsis.db') self.assertEqual(msg, 'Person data commit successfull')
def get(self): create_db() self.write('创建表成功')
def create_db(): models.create_db()
import os from dotenv import load_dotenv, find_dotenv from sqlalchemy.orm import sessionmaker from app.models import create_db from app.models.Orders import Orders from app.models.Products import Products load_dotenv(find_dotenv()) Session = sessionmaker(bind=create_db()) session = Session()
import sys, os FILE_DIRNAME = os.path.dirname(os.path.realpath(__file__)) sys.path.append(os.path.join(FILE_DIRNAME, os.pardir)) from flask_migrate import MigrateCommand from flask_script import Manager from app.app_init import app as flask_app # noinspection PyUnresolvedReferences from app.models.glob_models import * from app.models import create_db create_db(flask_app) manager = Manager(flask_app) manager.add_command('db', MigrateCommand) if __name__ == '__main__': manager.run()
def get(self): create_db() self.write("创建表成功")