Test multi instance and multi user session

!lamin login testuser1
!lamin init --storage "./testsetup-prepare"
import lamindb_setup as ln_setup
import pytest
assert ln_setup.settings.user.handle == "testuser1"
ln_setup.init(storage="./testsetup")
from lnschema_core.models import User
User.objects.get(handle="testuser1")
with pytest.raises(Exception):  # does not exist
    User.objects.get(handle="testuser2")

Let us login with another user:

ln_setup.login("testuser2")
User.objects.get(handle="testuser2")

Let us try to init another instance in the same Python session:

with pytest.raises(RuntimeError):
    ln_setup.init(storage="./testsetup2")
with pytest.raises(RuntimeError):
    ln_setup.connect("testsetup")
with pytest.raises(RuntimeError):
    ln_setup.migrate.create()
with pytest.raises(RuntimeError):
    ln_setup.migrate.deploy()
!lamin login testuser1
!lamin delete --force testsetup-prepare
!lamin delete --force testsetup