本文整理汇总了Python中tests.unittests.object_mother.ObjectMother类的典型用法代码示例。如果您正苦于以下问题:Python ObjectMother类的具体用法?Python ObjectMother怎么用?Python ObjectMother使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectMother类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_session_delete
def test_session_delete(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event Saved")
session = ObjectMother.get_session()
save_to_db(session, "Session Saved")
url = url_for('event_sessions.delete_session', event_id=1, session_id=session.id)
rv = self.app.get(url, follow_redirects=True)
self.assertTrue("deleted" in rv.data, msg=rv.data)
示例2: test_session_create
def test_session_create(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
custom_form = ObjectMother.get_custom_form(event.id)
save_to_db(custom_form, "Custom form saved")
url = url_for('event_sessions.create_view', event_id=event.id)
rv = self.app.get(url, follow_redirects=True)
self.assertTrue("Create Session" in rv.data, msg=rv.data)
示例3: test_add_session_to_db
def test_add_session_to_db(self):
with app.test_request_context():
# create event
event = ObjectMother.get_event()
save_to_db(event, 'Event saved')
# test
session = ObjectMother.get_session()
save_to_db(session, "Session saved")
self.assertEqual(session.id, 1)
self.assertEqual(session.event_id, 1)
示例4: test_speaker_delete
def test_speaker_delete(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
speaker = ObjectMother.get_speaker()
speaker.event_id = event.id
save_to_db(speaker, "Session Saved")
url = url_for('event_speakers.delete', event_id=event.id, speaker_id=speaker.id)
rv = self.app.get(url, follow_redirects=True)
self.assertTrue("deleted" in rv.data, msg=rv.data)
示例5: basic_setup
def basic_setup(super_admin):
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
session = ObjectMother.get_session(event.id)
save_to_db(session, "Session saved")
speaker = ObjectMother.get_speaker()
speaker.event_id = event.id
speaker.user_id = super_admin.id
save_to_db(speaker, "Speaker saved")
return event
示例6: test_sessions_list
def test_sessions_list(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
session = ObjectMother.get_session(event.id)
save_to_db(session, "Session Saved")
url = url_for('event_sessions.index_view', event_id=event.id, session_id=session.id)
rv = self.app.get(url, follow_redirects=True)
self.assertTrue("Sessions" in rv.data, msg=rv.data)
self.assertTrue("test" in rv.data, msg=rv.data)
示例7: test_session_view
def test_session_view(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event)
session = ObjectMother.get_session()
session.event_id = event.id
save_to_db(session, "Session Saved")
url = url_for('event_sessions.session_display_view', event_id=event.id, session_id=session.id)
rv = self.app.get(url, follow_redirects=True)
self.assertTrue("Short abstract" in rv.data, msg=rv.data)
示例8: test_wrong_form_config
def test_wrong_form_config(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
speaker = ObjectMother.get_speaker()
speaker.event_id = event.id
save_to_db(speaker, "Speaker saved")
url = url_for('event_speakers.edit_view', event_id=event.id, speaker_id=speaker.id)
rv = self.app.get(url, follow_redirects=True)
self.assertFalse("incorrectly configured" in rv.data, msg=rv.data)
示例9: test_api_tracks
def test_api_tracks(self):
with app.test_request_context():
self.assertEqual(self.app.get('/api/v1/event/1').status_code, 404)
event = ObjectMother.get_event()
track = ObjectMother.get_track()
save_to_db(event, "Event saved")
save_to_db(track, "Track saved")
self.assertEqual(self.app.get('/api/v1/event/1').status_code, 200)
self.assertEqual(self.app.get('/api/v1/event/1/tracks').status_code, 200)
示例10: test_session_create_post
def test_session_create_post(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
custom_form = ObjectMother.get_custom_form(event.id)
save_to_db(custom_form, "Custom form saved")
data = POST_SESSION_DATA
data.update(POST_SPEAKER_DATA)
url = url_for('event_sessions.create_view', event_id=event.id)
rv = self.app.post(url, follow_redirects=True, buffered=True, content_type='multipart/form-data', data=data)
self.assertTrue(data['title'] in rv.data, msg=rv.data)
示例11: test_session_edit_post
def test_session_edit_post(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
custom_form = ObjectMother.get_custom_form(event.id)
save_to_db(custom_form, "Custom form saved")
session = ObjectMother.get_session(event.id)
save_to_db(session, "Session saved")
data = POST_SESSION_DATA
data['title'] = 'TestSession2'
url = url_for('event_sessions.edit_view', event_id=event.id, session_id=session.id)
rv = self.app.post(url, follow_redirects=True, buffered=True, content_type='multipart/form-data', data=data)
self.assertTrue("TestSession2" in rv.data, msg=rv.data)
示例12: test_speaker_view
def test_speaker_view(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
speaker = ObjectMother.get_speaker()
speaker.event_id = event.id
save_to_db(speaker, "Speaker saved")
custom_forms = ObjectMother.get_custom_form()
custom_forms.event_id = event.id
save_to_db(custom_forms, "Custom forms Saved")
url = url_for('event_speakers.edit_view', event_id=event.id, speaker_id=speaker.id)
rv = self.app.get(url, follow_redirects=True)
self.assertTrue("name" in rv.data, msg=rv.data)
示例13: test_role_delete
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)
示例14: test_event_view
def test_event_view(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
url = url_for('events.details_view', event_id=event.id)
rv = self.app.get(url, follow_redirects=True)
self.assertTrue("event1" in rv.data, msg=rv.data)
microlocation = ObjectMother.get_microlocation(event_id=event.id)
track = ObjectMother.get_track(event_id=event.id)
cfs = ObjectMother.get_cfs(event_id=event.id)
save_to_db(track, "Track saved")
save_to_db(microlocation, "Microlocation saved")
save_to_db(cfs, "Call for speakers saved")
rv = self.app.get(url, follow_redirects=True)
self.assertTrue("event1" in rv.data, msg=rv.data)
示例15: test_wrong_form_config
def test_wrong_form_config(self):
with app.test_request_context():
event = ObjectMother.get_event()
save_to_db(event, "Event saved")
url = url_for('event_sessions.create_view', event_id=event.id)
rv = self.app.get(url, follow_redirects=True)
self.assertFalse("incorrectly configured" in rv.data, msg=rv.data)