def test_rrule_create_valid(db_session, setup_session): users, aliases, reminders = setup_session new_reminder = Reminder.create_reminder(alias_id=aliases[3].id, title="Here's a title", session=db_session) now = datetime.utcnow() RRule.create_rrule(new_reminder.id, now, session=db_session)
def setup_session(db_session): """Instantiate a session for testing objects""" user1 = User.create_user( 'jaytyler', 'secretpass', 'jason', 'tyler', session=db_session) user2 = User.create_user( 'ryty', 'othersecret', 'ryan', 'tyler', session=db_session) user3 = User.create_user( 'nick', 'nickpassword', 'nick', 'draper', session=db_session) user4 = User.create_user( 'saki', 'nakedmolerats', 'saki', 'fu', session=db_session) user5 = User.create_user( 'grace', 'gatitapass', 'grace', 'hata', session=db_session) db_session.flush() alias1 = Alias.create_alias( user1.id, "*****@*****.**", "ME", 1, session=db_session) alias2 = Alias.create_alias( user1.id, "206-659-4510", "ME", 2, session=db_session) alias3 = Alias.create_alias( user2.id, "*****@*****.**", "ME", 1, session=db_session) alias4 = Alias.create_alias( user3.id, "*****@*****.**", "ME", 1, session=db_session) alias5 = Alias.create_alias( user4.id, "*****@*****.**", "ME", 1, session=db_session) alias6 = Alias.create_alias( user5.id, "*****@*****.**", "ME", 1, session=db_session) db_session.flush() reminder1 = Reminder.create_reminder( alias1.id, "Here's an email to send to Jason's email", session=db_session) reminder2 = Reminder.create_reminder(alias2.id, "Heres a text to send to Jason's phone", session=db_session) reminder3 = Reminder.create_reminder(alias3.id, "Here's a email to send to Ryan", session=db_session) reminder4 = Reminder.create_reminder(alias4.id, "Here's an email to send to Nick", session=db_session) reminder5 = Reminder.create_reminder(alias5.id, "Here's an email to send to Saki", session=db_session) reminder6 = Reminder.create_reminder(alias6.id, "Here's an email to send to Grace", session=db_session) db_session.flush() now = datetime.utcnow() rrule1 = RRule.create_rrule(reminder1.id, now + timedelta(hours=-3), session=db_session) rrule2 = RRule.create_rrule(reminder2.id, now + timedelta(hours=-2), session=db_session) rrule3 = RRule.create_rrule(reminder3.id, now + timedelta(hours=-1), session=db_session) rrule4 = RRule.create_rrule(reminder4.id, now + timedelta(hours=1), session=db_session) rrule5 = RRule.create_rrule(reminder5.id, now + timedelta(hours=2), session=db_session) rrule6 = RRule.create_rrule(reminder6.id, now + timedelta(hours=3), session=db_session) db_session.flush() users = [user1, user2, user3, user4, user5] aliases = [alias1, alias2, alias3, alias4, alias5, alias6] reminders = [reminder1, reminder2, reminder3, reminder4, reminder5, reminder6] return (users, aliases, reminders)
def test_rrule_create_invalid(db_session, setup_session): users, aliases, reminders = setup_session now = datetime.utcnow() with pytest.raises(NoResultFound): RRule.create_rrule(1200, now)
def test_rrule_get_rrules_invalid(db_session, setup_session): users, aliases, reminders = setup_session with pytest.raises(NoResultFound): out = RRule.get_rrules(1200, session=db_session)
def test_rrule_get_rrules_valid(db_session, setup_session): users, aliases, reminders = setup_session reminder = reminders[0] out = RRule.get_rrules(reminder.id, session=db_session) assert isinstance(out, datetime)