本文整理汇总了Python中tests.unittests.setup_database.Setup.create_app方法的典型用法代码示例。如果您正苦于以下问题:Python Setup.create_app方法的具体用法?Python Setup.create_app怎么用?Python Setup.create_app使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.unittests.setup_database.Setup
的用法示例。
在下文中一共展示了Setup.create_app方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
update_role_to_admin({'admin_perm': 'isAdmin'}, user_id=1)
event_id = create_event(creator_email='[email protected]')
create_services(event_id)
示例2: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
create_event(creator_email='[email protected]')
create_services(1, '1')
create_services(1, '2')
create_services(1, '3')
示例3: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
# `event_id` is going to be 1
event_id = create_event(creator_email=u'[email protected]')
# Associate services to event_id
create_services(event_id)
示例4: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
"""Create Event but don't define services for it.
"""
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
# Created event will have id=1
create_event(creator_email=u'[email protected]')
示例5: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
logout(self.app)
event_id = create_event(
name='TestEvent_1', creator_email=u'[email protected]')
create_services(event_id)
示例6: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
app.config['TESTING'] = True
app.secret_key = 'super secret key'
app.config['PROFILE'] = True
app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])
with app.test_request_context():
db.create_all()
populate()
示例7: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
# User must be part of the staff to access listed events
update_role_to_admin({'admin_perm': 'isAdmin'}, user_id=1)
event_id = create_event(creator_email=u'[email protected]')
create_services(event_id)
示例8: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
create_event(
creator_email='[email protected]', location_name='Science Centre, Singapore',
latitude=87.5, longitude=88.5
)
create_services(1, '1')
create_session(1, '2', state='accepted', track=1, microlocation=1, speakers=[1], session_type=1)
示例9: test_event_api
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def test_event_api(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
login(self.app, u'[email protected]', u'test')
# Non existing event
event_id = 1
path = get_path(event_id)
response = self.app.get(path)
self.assertEqual(response.status_code, 404)
self.assertIn('does not exist', response.data)
示例10: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
"""Create Event (it will have id = `event_id`). Create services and
associate them with event id = `event_id` + 1.
"""
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
# `event_id` is going to be 1
event_id = create_event(creator_email=u'[email protected]')
# Associate services to event_id=2
# No need to create the event though
create_services(event_id+1)
示例11: test_add_social_link_to_db
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def test_add_social_link_to_db(self):
"""Checks the one to many relationship between event and social_links """
self.app = Setup.create_app()
with app.test_request_context():
event = ObjectMother.get_event()
social_link1 = SocialLink(name='Link1', link='some_random_link_1', event_id='1')
social_link2 = SocialLink(name='Link2', link='some_random_link_2', event_id='1')
save_to_db(event, "Event Saved")
save_to_db(social_link1, "SocialLink1 Saved")
save_to_db(social_link2, "SocialLink2 Saved")
self.assertEqual(social_link1.event_id, 1)
self.assertEqual(social_link2.event_id, 1)
示例12: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
# User must be part of the staff to access listed events
update_role_to_admin({'admin_perm': 'isAdmin'}, user_id=1)
# Create two instances of event/services
# event_id is going to be 1
event_id1 = create_event('TestEvent_1', creator_email=u'[email protected]')
# event_id is going to be 2
create_event('TestEvent_2', creator_email=u'[email protected]')
# Associate services to event_id1
create_services(event_id1, serial_no=1)
create_services(event_id1, serial_no=2)
示例13: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
event = Event(name=UNICODE_STRING,
start_time=datetime(2013, 8, 4, 12, 30, 45),
end_time=datetime(2016, 9, 4, 12, 30, 45))
event.owner = 1
microlocation = Microlocation(name=UNICODE_STRING)
session = Session(title=UNICODE_STRING, long_abstract='descp',
start_time=datetime(2014, 8, 4, 12, 30, 45),
end_time=datetime(2015, 9, 4, 12, 30, 45))
speaker = Speaker(name=UNICODE_STRING, email='[email protected]',
organisation='org', country='japan')
sponsor = Sponsor(name=UNICODE_STRING)
save_to_db(event, "Event saved")
save_to_db(microlocation, 'Microlocation saved')
save_to_db(session, 'Session saved')
save_to_db(speaker, 'Speaker saved')
save_to_db(sponsor, 'Sponsor saved')
示例14: test_add_session_type_to_db
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def test_add_session_type_to_db(self):
"""Checks the one to many relationship between event and session_types and
the many to one relationship between session and session_types"""
self.app = Setup.create_app()
with app.test_request_context():
event = ObjectMother.get_event()
session1 = ObjectMother.get_session()
session_type1 = SessionType(name='Type1', length='30', event_id='1')
session_type2 = SessionType(name='Type2', length='30', event_id='1')
session2 = Session(title='test2',
long_abstract='dsadsd',
start_time=datetime(2003, 8, 4, 12, 30, 45),
end_time=datetime(2003, 8, 4, 12, 30, 45),
session_type=session_type1)
save_to_db(event, "Event Saved")
save_to_db(session1, "Session1 Saved")
save_to_db(session2, "Session2 Saved")
save_to_db(session_type1, "SessionType1 Saved")
save_to_db(session_type2, "SessionType2 Saved")
self.assertEqual(session_type1.event_id, 1)
self.assertEqual(session_type2.event_id, 1)
self.assertEqual(session2.session_type_id, 1)
self.assertEqual(session1.session_type_id, None)
示例15: setUp
# 需要导入模块: from tests.unittests.setup_database import Setup [as 别名]
# 或者: from tests.unittests.setup_database.Setup import create_app [as 别名]
def setUp(self):
self.app = Setup.create_app()
with app.test_request_context():
register(self.app, u'[email protected]', u'test')
create_event(creator_email=u'[email protected]')
logout(self.app)