def it_creates_a_speaker(self, db): speaker = create_speaker() assert Speaker.query.count() == 1 speaker_from_db = Speaker.query.filter(Speaker.id == speaker.id).first() assert speaker == speaker_from_db
def it_shows_speaker_json_on_serialize(self, db, db_session): speaker = create_speaker() assert speaker.serialize() == { 'id': str(speaker.id), 'title': speaker.title, 'name': speaker.name, 'parent_id': None }
def it_raises_an_error_when_importing_speaker_with_parent_speaker_that_has_parent( self, client, db_session, sample_speaker): speaker = create_speaker(name='New Speaker', parent_id=str(sample_speaker.id)) data = [{'name': 'Another Speaker', 'parent_name': speaker.name}] response = client.post(url_for('speakers.import_speakers'), data=json.dumps(data), headers=[('Content-Type', 'application/json'), create_authorization_header()]) assert response.status_code == 400
def it_updates_an_event_dao_with_new_speaker(self, db, db_session): speaker = create_speaker(name='John Brown') event_date = create_event_date(event_datetime='2018-01-20T19:00:00', speakers=[speaker]) event = create_event(event_dates=[event_date]) speaker2 = create_speaker(name='Jim Blue') db_event_date = dao_get_event_date_by_id(event_date.id) db_event_date.speakers = [speaker, speaker2] dao_update_event(event.id, event_dates=[db_event_date]) event_from_db = Event.query.filter(Event.id == event.id).first() assert event.event_dates[0] == event_from_db.event_dates[0] event_dates = EventDate.query.all() assert len(event_dates) == 1
def it_updates_an_event_dao_with_new_event_date(self, db, db_session, sample_event): speaker = create_speaker(name='John Brown') event_date = create_event_date(event_datetime='2018-01-20T19:00:00', speakers=[speaker]) dao_update_event(sample_event.id, event_dates=[event_date]) event_from_db = Event.query.filter(Event.id == sample_event.id).first() assert sample_event.event_dates[0] == event_from_db.event_dates[0] event_date2 = create_event_date(event_datetime='2018-02-20T19:00:00', speakers=[speaker]) dao_update_event(sample_event.id, event_dates=[event_date2]) event_dates = EventDate.query.all() assert len(event_dates) == 1
def sample_speaker(db): return create_speaker(name='Paul White')
def it_gets_a_speaker_by_name(self, db, db_session, sample_speaker): speaker = create_speaker(name='Sam Black') fetched_speaker = dao_get_speaker_by_name(speaker.name) assert fetched_speaker == speaker
def it_gets_all_speakers_in_last_name_alphabetical_order(self, db, db_session, sample_speaker): speakers = [create_speaker(name='Bob Blue'), create_speaker(name='Sid Green'), sample_speaker] speakers_from_db = dao_get_speakers() assert speakers == speakers_from_db
def it_gets_last_name_correctly(self, db, db_session): speaker = create_speaker(name='John Smith') assert speaker.last_name == 'Smith'