def test_api_tracks(self): self.assertEqual(self.app.get('/api/v1/event/1').status_code, 404) event = ObjectMother.get_event() track = ObjectMother.get_track() with app.test_request_context(): 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)
def setUp(self): self.app = Setup.create_app() with app.test_request_context(): event = ObjectMother.get_event() event.owner = 1 track = ObjectMother.get_track() save_to_db(event,"Event saved") save_to_db(track, "Track saved") register(self.app,'test', '*****@*****.**', 'test')
def setUp(self): self.app = Setup.create_app() with app.test_request_context(): event = ObjectMother.get_event() event.owner = 1 track = ObjectMother.get_track() save_to_db(event, "Event saved") save_to_db(track, "Track saved") register(self.app, 'test', '*****@*****.**', 'test')
def test_api_tracks(self): self.assertEqual(self.app.get('/api/v1/event/1').status_code, 404) event = ObjectMother.get_event() track = ObjectMother.get_track() with app.test_request_context(): 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)
def test_api_tracks(self): with self.assertRaises(Exception) as context: self.app.get('/api/v1/event/1') self.assertTrue(AttributeError, context.exception) event = ObjectMother.get_event() track = ObjectMother.get_track() with app.test_request_context(): 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)
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)
def test_published_event_sessions_view(self): with app.test_request_context(): event = ObjectMother.get_event() event.state = 'Published' save_to_db(event, "Event Saved") track = ObjectMother.get_track() track.event_id = event.id save_to_db(track, "Track Saved") speaker = ObjectMother.get_speaker() speaker.event_id = event.id save_to_db(speaker, "Speaker Saved") session = ObjectMother.get_session() session.event_id = event.id session.speakers = [speaker] save_to_db(speaker, "Session Saved") rv = self.app.get(url_for('event_detail.display_event_sessions', event_id=event.id), follow_redirects=True) self.assertTrue("Sessions" in rv.data, msg=rv.data)
def test_published_event_unpublished_schedule_view_attempt(self): with app.test_request_context(): event = ObjectMother.get_event() event.state = 'Published' save_to_db(event, "Event Saved") track = ObjectMother.get_track() track.event_id = event.id save_to_db(track, "Track Saved") speaker = ObjectMother.get_speaker() speaker.event_id = event.id save_to_db(speaker, "Speaker Saved") microlocation = ObjectMother.get_microlocation() save_to_db(microlocation, "Microlocation Saved") session = ObjectMother.get_session() session.event_id = event.id session.microlocation_id = microlocation.id session.speakers = [speaker] save_to_db(speaker, "Session Saved") rv = self.app.get(url_for('event_detail.display_event_schedule', event_id=event.id), follow_redirects=True) self.assertEqual(rv.status_code, 404)
def test_published_event_schedule_view(self): with app.test_request_context(): event = ObjectMother.get_event() event.state = "Published" event.schedule_published_on = datetime.now() save_to_db(event, "Event Saved") track = ObjectMother.get_track() track.event_id = event.id save_to_db(track, "Track Saved") speaker = ObjectMother.get_speaker() speaker.event_id = event.id save_to_db(speaker, "Speaker Saved") microlocation = ObjectMother.get_microlocation() save_to_db(microlocation, "Microlocation Saved") session = ObjectMother.get_session() session.event_id = event.id session.microlocation_id = microlocation.id session.speakers = [speaker] save_to_db(speaker, "Session Saved") rv = self.app.get(url_for("event_detail.display_event_schedule", event_id=event.id), follow_redirects=True) self.assertTrue("Schedule" in rv.data, msg=rv.data)