Log in or init with insufficient user information

!lamin disconnect
import lamindb_setup as ln_setup
from lamindb_setup.core._settings_store import (
    current_user_settings_file,
    get_settings_file_name_prefix,
    settings_dir,
)
import pytest

Log in with in-sufficient information

with pytest.raises(ValueError):
    ln_setup.login()

If we add an email or handle it looks up credentials from the stored env file (lamin login testuser1@lamin.ai):

ln_setup.login("testuser1@lamin.ai")

Now, let’s start with a fresh environment without any user profiles stored.

(
    settings_dir / f"{get_settings_file_name_prefix()}user--testuser1@lamin.ai.env"
).unlink()
(settings_dir / f"{get_settings_file_name_prefix()}user--testuser1.env").unlink()
current_user_settings_file().unlink()

If we try to login with a handle at first login, this will error:

with pytest.raises(SystemExit):
    ln_setup.login("testuser1", key="dummy")

If we try to login without key, this will error:

with pytest.raises(SystemExit):
    ln_setup.login("testuser1@lamin.ai")

If we try login with a wrong key, this will error:

from gotrue.errors import AuthApiError

with pytest.raises(AuthApiError):
    ln_setup.login("testuser1@lamin.ai", key="hello")

Add back login for testuser1:

from laminci.nox import login_testuser1
login_testuser1("dummy_nox_session_arg")