def test_password_auth(email, password): with session_scope() as db_session: create_account(db_session, email, password) start_time = time.time() # Check that the account exists while time.time() - start_time < TEST_MAX_DURATION_SECS: client = APIClient.from_email(email)[0] if client is not None: break time.sleep(TEST_GRANULARITY_CHECK_SECS) if client is None: assert False, "Account namespace should have been created" # Now, compute how much time it takes to start syncing the account start_time = time.time() got_messages = False while time.time() - start_time < TEST_MAX_DURATION_SECS: messages = client.get_messages() if len(messages) != 0: got_messages = True break time.sleep(TEST_GRANULARITY_CHECK_SECS) assert got_messages, "Messages should have been found" print "test_password_auth %s %f" % (email, time.time() - start_time) # remove the account with session_scope() as db_session: # remove_account(db_session, email) pass
def f(): for email, password in passwords: with session_scope() as db_session: create_account(db_session, email, password) client = None ns = None start_time = time.time() while time.time() - start_time < TEST_MAX_DURATION_SECS: time.sleep(TEST_GRANULARITY_CHECK_SECS) client, ns = APIClient.from_email(email) if client is not None: break assert client, ("Creating account from password file" " should have been faster") format_test_result("namespace_creation_time", ns["provider"], email, start_time) # wait a little time for the sync to start. It's necessary # because a lot of tests rely on stuff setup at the beginning # of the sync (for example, a folder hierarchy). start_time = time.time() sync_started = False while time.time() - start_time < TEST_MAX_DURATION_SECS: msgs = client.get_messages() if len(msgs) > 0: sync_started = True break time.sleep(TEST_GRANULARITY_CHECK_SECS) assert sync_started, ("The initial sync should have started") data = {"email": ns["email_address"], "provider": ns["provider"]} start_time = time.time() fn(client, data) format_test_result(fn.__name__, ns["provider"], ns["email_address"], start_time) with session_scope() as db_session: # delete account pass
def test_password_auth(email, password): with session_scope() as db_session: auth_handler = handler_from_email(email) account = create_account(db_session, email, password) if auth_handler.verify_account(account): db_session.add(account) db_session.commit() start_time = time.time() # Check that the account exists while time.time() - start_time < TEST_MAX_DURATION_SECS: client = APIClient.from_email(email)[0] if client is not None: break time.sleep(TEST_GRANULARITY_CHECK_SECS) if client is None: assert False, "Account namespace should have been created" # Now, compute how much time it takes to start syncing the account start_time = time.time() got_messages = False while time.time() - start_time < TEST_MAX_DURATION_SECS: messages = client.get_messages() if len(messages) != 0: got_messages = True break time.sleep(TEST_GRANULARITY_CHECK_SECS) assert got_messages, "Messages should have been found" print "test_password_auth %s %f" % (email, time.time() - start_time) # remove the account with session_scope() as db_session: delete_account(db_session, email)