def add_completely_fake_account(db, email="*****@*****.**"): 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)) db.session.commit() return fake_account
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): ev = 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): uid = 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