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)
Beispiel #2
0
def test_create_user(app):
    global uuid
    global alias_id
    params = {'username': '******',
              'password': '******',
              'first_name': 'bob',
              'last_name': 'hope',
              'contact_info': '*****@*****.**',
              }
    response = app.post('/createuser', params=params, status='3*')
    redirected = response.follow()
    assert 'Please wait for your confirmation link' in redirected.body

    # pull the uuid out of the db for the next step
    user = User.by_username('user1')
    alias = user.aliases[0]
    alias_id = alias.id
    uuid = alias.uuids[0].uuid