Example #1
0
def fake_imap_accounts(db):
    imap_account_data = {
        'yahoo': '*****@*****.**',
        'aol': '*****@*****.**',
        'icloud': '*****@*****.**',
        'imap': '*****@*****.**',
    }
    accounts = {'gmail': add_fake_gmail_account(db.session)}
    for provider, email in imap_account_data.items():
        accounts[provider] = add_fake_imap_account(db.session, provider, email,
                                                   'sEcr3T')
    return accounts
Example #2
0
def add_completely_fake_account(db, email='*****@*****.**'):
    from inbox.models.backends.gmail import GmailAuthCredentials
    fake_account = add_fake_gmail_account(db.session, email_address=email)
    calendar = add_fake_calendar(db.session, fake_account.namespace.id)
    for i in random_range(1, 10):
        add_fake_event(db.session,
                       fake_account.namespace.id,
                       calendar=calendar,
                       title='%s' % i)

    # Add fake Threads, Messages and ImapUids.
    folder = add_fake_folder(db.session, fake_account)
    for i in random_range(1, 4):
        th = add_fake_thread(db.session, fake_account.namespace.id)

        for j in random_range(1, 3):
            msg = add_fake_msg_with_calendar_part(db.session,
                                                  fake_account,
                                                  'fake part',
                                                  thread=th)
            db.session.add(msg)
            db.session.flush()

            for k in random_range(1, 2):
                add_fake_imapuid(db.session, fake_account.id, msg, folder,
                                 int('%s%s' % (msg.id, k)))
    # Add fake contacts
    for i in random_range(1, 5):
        add_fake_contact(db.session, fake_account.namespace.id, uid=str(i))

    auth_creds = GmailAuthCredentials()
    auth_creds.gmailaccount = fake_account
    auth_creds.scopes = "email"
    auth_creds.g_id_token = "test"
    auth_creds.client_id = "test"
    auth_creds.client_secret = "test"
    auth_creds.refresh_token = "test"
    auth_creds.is_valid = True
    db.session.add(auth_creds)
    db.session.commit()

    return fake_account
Example #3
0
def add_completely_fake_account(db, email='*****@*****.**'):
    from inbox.models.backends.gmail import GmailAuthCredentials
    fake_account = add_fake_gmail_account(db.session, email_address=email)
    calendar = add_fake_calendar(db.session, fake_account.namespace.id)
    for i in random_range(1, 10):
        add_fake_event(db.session, fake_account.namespace.id,
                       calendar=calendar, title='%s' % i)

    # Add fake Threads, Messages and ImapUids.
    folder = add_fake_folder(db.session, fake_account)
    for i in random_range(1, 4):
        th = add_fake_thread(db.session, fake_account.namespace.id)

        for j in random_range(1, 3):
            msg = add_fake_msg_with_calendar_part(db.session,
                                                  fake_account,
                                                  'fake part', thread=th)
            db.session.add(msg)
            db.session.flush()

            for k in random_range(1, 2):
                add_fake_imapuid(db.session, fake_account.id, msg, folder,
                                 int('%s%s' % (msg.id, k)))
    # Add fake contacts
    for i in random_range(1, 5):
        add_fake_contact(db.session, fake_account.namespace.id, uid=str(i))

    auth_creds = GmailAuthCredentials()
    auth_creds.gmailaccount = fake_account
    auth_creds.scopes = "email"
    auth_creds.g_id_token = "test"
    auth_creds.client_id = "test"
    auth_creds.client_secret = "test"
    auth_creds.refresh_token = "test"
    auth_creds.is_valid = True
    db.session.add(auth_creds)
    db.session.commit()

    return fake_account