def setUp(self): APP.config['TESTING'] = True APP.config['DEBUG'] = False APP.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test' self.app = APP.test_client() DB.drop_all() DB.create_all() self.lifegoup1 = { 'name': 'uq1', 'password': '******', 'email': '*****@*****.**' } self.lifegoup2 = { 'name': 'uq2', 'password': '******', 'email': '*****@*****.**' } self.lifegoup3 = { 'name': 'uq3', 'password': '******', 'email': '*****@*****.**' } DB.session.add(LifegroupModel(**self.lifegoup1)) DB.session.add(LifegroupModel(**self.lifegoup2)) DB.session.add(LifegroupModel(**self.lifegoup3)) DB.session.commit() self.member1 = { 'id': '1', 'lifegroup': 'uq1', 'name': 'Kenneth Guo', 'suburb': 'Sunnybank QLD, 4109' } self.member2 = { 'id': '2', 'lifegroup': 'uq2', 'name': 'Ken Guo', 'suburb': 'Sunnybank QLD, 4109' } self.note1 = { 'id': '1', 'lifegroup': 'uq1', 'text': "A and B stay at the same place" } self.note2 = { 'id': '2', 'lifegroup': 'uq2', 'text': "C and D stay at the same place" } DB.session.add(MemberModel(**self.member1)) DB.session.add(MemberModel(**self.member2)) DB.session.add(NoteModel(**self.note1)) DB.session.add(NoteModel(**self.note2)) DB.session.commit() self.assertFalse(APP.debug)
def setUp(self): APP.config['TESTING'] = True APP.config['DEBUG'] = False APP.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test' self.app = APP.test_client() DB.drop_all() DB.create_all() self.lifegoup1 = { 'name': 'uq1', 'password': '******', 'email': '*****@*****.**' } self.lifegoup2 = { 'name': 'uq2', 'password': '******', 'email': '*****@*****.**' } self.lifegoup3 = { 'name': 'uq3', 'password': '******', 'email': '*****@*****.**' } DB.session.add(LifegroupModel(**self.lifegoup1)) DB.session.add(LifegroupModel(**self.lifegoup2)) DB.session.add(LifegroupModel(**self.lifegoup3)) DB.session.commit() self.assertFalse(APP.debug)
def setUp(self): """ A method that is called before each test. """ """ Pass testing configuration and initializes the app. """ self.app = create_app(config_name="testing") self.client = self.app.test_client with self.app.app_context(): DB.create_all()
def setUp(self): test_config = TestConfig() self.app = create_app(test_config) self.app_context = self.app.app_context() self.app_context.push() self.client = self.app.test_client() db.create_all()
def db(): ''' creates tables and drops them for every test ''' DB.create_all() yield DB.session.commit() DB.drop_all()
def app(): environ['FLASK_ENV'] = 'test' _app = create_app() with _app.app_context(): DB.create_all() yield _app DB.session.remove() DB.drop_all() return _app
def setUp(self): """Define test variables and initialize app.""" self.app = create_app(config_name="TESTING") self.client = self.app.test_client self.bucketlist = {'name': 'Go to Borabora for vacation'} # binds the app to the current context with self.app.app_context(): # create all tables DB.create_all()
def setUp(self): """"Initialize the app and set up test variables.""" self.app = create_app(config_name="testing") self.client = self.app.test_client self.bucketlist = {'name': 'Go to Molo for vacation'} # self.user = User(username='******', password='******', email='*****@*****.**') # db.session.add(self.user) # db.session.commit() with self.app.app_context(): db.create_all()
def setUp(self): """setting up all variables""" APP.config['TESTING'] = True APP.config['WTF_CSRF_ENABLED'] = False APP.config['DEBUG'] = False APP.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False APP.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \ os.path.join(BASEDIR, TEST_DB) self.app = APP.test_client() DB.drop_all() DB.create_all() insert_jokes_categories()
def setUp(self): """ A method that is called before each test. """ """ Pass testing configuration and initializes the app. """ self.app = create_app(config_name="testing") self.client = self.app.test_client self.shoppingitem = { 'itemname': 'wheat flour', 'quantity': 12, 'price': 1200 } with self.app.app_context(): DB.create_all()
def setUp(self): APP.config['TESTING'] = True APP.config['DEBUG'] = False APP.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test' self.app = APP.test_client() self.member = {'id': '123', 'name': 'Kenneth', 'suburb': 'Sunnybank, QLD 4109'} DB.drop_all() DB.create_all() self.assertFalse(APP.debug)
def setUp(self): """ A method that is called before each test. """ """ Pass testing configuration and initializes the app. """ self.app = create_app(config_name="testing") self.client = self.app.test_client self.user = { 'username': '******', 'email': '*****@*****.**', 'password': '******', 'repeat_password': '******' } self.userlogs = {'email': '*****@*****.**', 'password': '******'} with self.app.app_context(): DB.create_all()
def setUp(self): APP.config['TESTING'] = True APP.config['DEBUG'] = False APP.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test' self.app = APP.test_client() DB.drop_all() DB.create_all() self.lifegoup1 = { 'name': 'uq8', 'password': '******', 'email': '*****@*****.**' } self.lifegoup2 = { 'name': 'uq6', 'password': '******', 'email': '*****@*****.**' } self.member1 = { 'id': '1', 'lifegroup': 'uq8', 'name': 'Kenneth Guo', 'suburb': 'Sunnybank QLD, 4109' } self.member2 = { 'id': '2', 'lifegroup': 'uq8', 'name': 'Ezmond Cheung', 'seats': 4, 'suburb': 'Taringa QLD, 1234' } self.member3 = { 'id': '3', 'lifegroup': 'uq6', 'name': 'Bruno Cheung', 'suburb': 'xxxx QLD, 4321' } DB.session.add(LifegroupModel(**self.lifegoup1)) DB.session.add(LifegroupModel(**self.lifegoup2)) DB.session.commit() DB.session.add(MemberModel(**self.member1)) DB.session.add(MemberModel(**self.member2)) DB.session.add(MemberModel(**self.member3)) DB.session.commit() self.assertFalse(APP.debug)
def setUp(self): '''Declare initial variables''' self.maxDiff = None self.app = create_app('testing') self.client = self.app.test_client() self.app_context = self.app.app_context() self.app_context.push() self.database = DB DB.drop_all() DB.create_all() self.today = datetime.utcnow().date() self.test_user = { 'username': '******', 'email': '*****@*****.**', 'password': '******' } self.admin_user = dict(username='******', email='*****@*****.**', password='******', admin=True) self.meal_model = Meal self.order_model = Order self.menu_model = Menu self.order_model = Order self.user_model = User self.user1 = User(email='*****@*****.**', password='******', username='******') self.user2 = User(email='*****@*****.**', username='******', password='******') self.menu = Menu() self.menu1 = Menu(date=datetime(year=2019, month=4, day=18)) self.menu2 = Menu(date=datetime(year=2019, month=4, day=19)) self.meal1 = Meal(name='Rice & Beef', price=100.00, description='Rice with beef. Yummy.') self.meal2 = Meal(name='Ugali Fish', price=150.00, description='Ugali and fish, Nyanza tings!') self.meal3 = Meal(name='Muthokoi', price=100.00, description='Kamba tributes')
def setUp(self): APP.config['TESTING'] = True APP.config['DEBUG'] = False APP.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test' self.app = APP.test_client() DB.drop_all() DB.create_all() self.lifegoup1 = { 'name': 'uq8', 'password': '******', 'email': '*****@*****.**' } self.lifegoup2 = { 'name': 'uq7', 'password': '******', 'email': '*****@*****.**' } DB.session.add(LifegroupModel(**self.lifegoup1)) DB.session.add(LifegroupModel(**self.lifegoup2)) DB.session.commit() self.note1 = { 'id': '1', 'lifegroup': 'uq8', 'text': "A and B stay at the same place" } self.note2 = { 'id': '2', 'lifegroup': 'uq8', 'text': "C and D stay close to each other" } self.note3 = { 'id': '3', 'lifegroup': 'uq7', 'text': "E and F want to be in the same car" } DB.session.add(NoteModel(**self.note1)) DB.session.add(NoteModel(**self.note2)) DB.session.add(NoteModel(**self.note3)) DB.session.commit() self.assertFalse(APP.debug)
def setUp(self): APP.config['TESTING'] = True APP.config['DEBUG'] = False APP.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test' self.app = APP.test_client() self.lifegroup = { 'name': 'uq8', 'password': '******', 'email': '*****@*****.**' } DB.drop_all() DB.create_all() self.assertFalse(APP.debug)
def setUp(self): APP.config['TESTING'] = True APP.config['DEBUG'] = False APP.config[ 'SQLALCHEMY_DATABASE_URI'] = 'postgres://localhost/transport_test' self.app = APP.test_client() self.note = { 'id': '1', 'lifegroup': 'uq8', 'body': 'Haha make sure everyone can go home safely' } DB.drop_all() DB.create_all() self.assertFalse(APP.debug)
def init_database(request): """Initializes the database """ DB.drop_all() DB.create_all() base_dir = join(abspath(dirname(__file__)), '..') for fixture_file in glob(join(base_dir, 'seed', '*.json')): fixtures = JSONLoader().load(fixture_file) load_fixtures(DB, fixtures) for fixture_file in sorted(glob(join(base_dir, 'seed', 'demo', '*.json'))): fixtures = JSONLoader().load(fixture_file) load_fixtures(DB, fixtures) request.cls.DB = DB yield DB close_all_sessions()
def initdb_command(): """Initializes the database with proper tables""" print(APP.config['SQLALCHEMY_DATABASE_URI']) DB.create_all() # DB.session.commit() print("Initialized the database")
def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() DB.create_all()
""" Create our database and fill it with items """ from app import DB from app.models.transaction import Transaction from app.models.item import Item from app.config import ITEMS DB.create_all() print 'Adding items...' for item in ITEMS: new_item = Item(name=item['name'], price=item['price']) DB.session.add(new_item) print 'Done' DB.session.commit()
#!./venv/bin/python """Set up DB tables and add some core data""" from app import DB import app.types from re import compile, UNICODE _strip_pattern = compile('[\W_]+', UNICODE) DB.drop_all() DB.create_all() ROLE_MAP = {} ALL_ROLES = ['admin', 'scorekeeper'] for role_name in ALL_ROLES: role = app.types.Role(name=role_name) DB.session.add(role) ROLE_MAP[role_name] = role for info in [ ['avi', 'finkel.org', ALL_ROLES], ['elizabeth', 'papa.org', ALL_ROLES], ['admin', 'papa.org', ['admin']], ['scorekeeper', 'papa.org', ['scorekeeper']], ]: user = app.types.User( username=info[0], email=info[0] + '@' + info[1],
def setUp(self): self.app = APP.test_client() with APP.app_context(): DB.create_all()
def setUp(self): self.app = create_app(config_name='testing') self.client = self.app.test_client DB.create_all(app=self.app)
def create_db(name): """Creates database with tables""" os.system('createdb {}'.format(name)) db.create_all() db.session.commit()
def init_db(): ''' Create all tables ''' DB.create_all() DB.session.commit()