本文整理汇总了Python中tests.unittests.object_mother.ObjectMother.get_user方法的典型用法代码示例。如果您正苦于以下问题:Python ObjectMother.get_user方法的具体用法?Python ObjectMother.get_user怎么用?Python ObjectMother.get_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.unittests.object_mother.ObjectMother
的用法示例。
在下文中一共展示了ObjectMother.get_user方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_role_delete
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_role_delete(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
user = ObjectMother.get_user()
save_to_db(user, "New user saved")
populate()
role = Role.query.filter_by(name='coorganizer').first()
uer = UsersEventsRoles(user, event, role)
save_to_db(uer, "UER Saved")
rv = self.app.get(url_for('event_roles.delete_view', uer_id=uer.id, event_id=event.id),
follow_redirects=True)
uer = UsersEventsRoles.query.get(uer.id)
self.assertTrue(uer is None, msg=rv.data)
示例2: test_db_users
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_db_users(self):
with app.test_request_context():
start = time.clock()
for i in range(1, 10000):
user = ObjectMother.get_user()
user.email = 'User' + str(i)
db.session.add(user)
db.session.commit()
url = url_for('sadmin_users.index_view')
self.app.get(url, follow_redirects=True)
print time.clock() - start
for query in get_debug_queries():
if query.duration >= ProductionConfig.DATABASE_QUERY_TIMEOUT:
app.logger.warning("SLOW QUERY: %s\nParameters: %s\nDuration: %fs\nContext: %s\n" % (
query.statement, query.parameters, query.duration, query.context))
示例3: test_role_create_post
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_role_create_post(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
user = ObjectMother.get_user()
save_to_db(user, "New user saved")
populate()
data = {
'user_email': user.email,
'user_role': 'coorganizer'
}
rv = self.app.post(url_for('event_roles.create_view', event_id=event.id), follow_redirects=True, data=data)
# Check if user has been sent a Role Invite
role = Role.query.filter_by(name='coorganizer').first()
ri = RoleInvite.query.filter_by(email=user.email, event=event, role=role).first()
self.assertTrue(ri is not None, msg=rv.data)
示例4: test_db_users
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_db_users(self):
with app.test_request_context():
for i in range(1, 10000):
user = ObjectMother.get_user()
user.email = 'User' + str(i)
db.session.add(user)
db.session.commit()
url = url_for('sadmin_users.index_view')
self.app.get(url, follow_redirects=True)
with open("output_users.txt", "w") as text_file:
for query in get_debug_queries():
if query.duration >= ProductionConfig.DATABASE_QUERY_TIMEOUT:
text_file.write("SLOW QUERY: %s\nParameters: %s\nDuration: %fs\nContext: %s\n" % (
query.statement, query.parameters, query.duration, query.context))
text_file.write("\n")
示例5: get_event_invoice
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def get_event_invoice():
set_settings(paypal_mode='sandbox',
paypal_sandbox_username=environ.get('PAYPAL_SANDBOX_USERNAME', 'SQPTVKtS8YvItGQuvHFvwve4'),
paypal_sandbox_password=environ.get('PAYPAL_SANDBOX_PASSWORD', 'SQPTVKtS8YvItGQuvHFvwve4'),
paypal_sandbox_signature=environ.get('PAYPAL_SANDBOX_SIGNATURE', 'SQPTVKtS8YvItGQuvHFvwve4'),
stripe_secret_key='sk_test_SQPTVKtS8YvItGQuvHFvwve4',
stripe_publishable_key='pk_test_e2jsd4RNUlYesCUb2KJ9nkCm',
secret='super secret key')
event = ObjectMother.get_event()
event.name = 'Super Event'
event.state = 'Published'
user = ObjectMother.get_user()
save_to_db(user)
save_to_db(event, "Event Saved")
new_invoice = EventInvoice(amount=100, event_id=event.id, user_id=user.id)
save_to_db(new_invoice, "Ticket Saved")
return event, new_invoice
示例6: test_role_update
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_role_update(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
user = ObjectMother.get_user()
save_to_db(user, "New user saved")
populate()
role = Role.query.filter_by(name='coorganizer').first()
uer = UsersEventsRoles(user, event, role)
save_to_db(uer, "UER Saved")
data = {
'user_email': user.email,
'user_role': 'track_organizer'
}
rv = self.app.post(url_for('event_roles.edit_view', uer_id=uer.id, event_id=event.id), data=data,
follow_redirects=True)
uer = DataGetter.get_user_event_roles_by_role_name(event.id, 'track_organizer').first()
self.assertTrue(uer is not None, msg=rv.data)
示例7: test_my_session_unauthorized_access
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_my_session_unauthorized_access(self):
with app.test_request_context():
event = ObjectMother.get_event()
user = ObjectMother.get_user()
save_to_db(user, "User saved")
save_to_db(event, "Event saved")
speaker = Speaker(name="name",
email="[email protected]",
organisation="FOSSASIA",
event_id=event.id,
user=user,
country="India")
save_to_db(speaker, "Speaker saved")
session = Session(title='test',
long_abstract='dsad',
start_time=datetime(2003, 8, 4, 12, 30, 45),
end_time=datetime(2003, 8, 4, 12, 30, 45),
event_id=event.id,
speakers=[speaker],
state='pending')
save_to_db(session, "Session saved")
rv = self.app.get(url_for('my_sessions.display_session_view', session_id=session.id), follow_redirects=True)
self.assertEqual(rv.status_code, 404)
示例8: test_get_event_roles_for_user
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_get_event_roles_for_user(self):
with app.test_request_context():
user = ObjectMother.get_user()
save_to_db(user)
self.assertTrue(DataGetter.get_event_roles_for_user(user.id))
示例9: test_all_user_notifications
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_all_user_notifications(self):
with app.test_request_context():
user = ObjectMother.get_user()
self.assertEquals(DataGetter().get_all_user_notifications(user), [])
示例10: test_admin_users
# 需要导入模块: from tests.unittests.object_mother import ObjectMother [as 别名]
# 或者: from tests.unittests.object_mother.ObjectMother import get_user [as 别名]
def test_admin_users(self):
with app.test_request_context():
user = ObjectMother.get_user()
save_to_db(user, "User saved")
rv = self.app.get(url_for('sadmin_users.index_view'), follow_redirects=True)
self.assertTrue('[email protected]' in rv.data, msg=rv.data)