Skip to content

Commit

Permalink
Add missing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjuhrich committed Jul 10, 2024
1 parent 497ab62 commit 81a0575
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion tests/model/test_unix_tombstone.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from sqlalchemy.orm import Session

from pycroft.model.user import User
from pycroft.model.unix_account import UnixTombstone
from pycroft.model.unix_account import UnixTombstone, UnixAccount
from tests import factories as f


Expand Down Expand Up @@ -182,6 +182,38 @@ def test_user_deletion(self, session, user):
assert inspect(user).deleted, "user did not get deleted"
assert inspect(ua).deleted, "unix_account did not get deleted"

def test_user_change_unix_account(self, session, user):
with pytest.raises(IntegrityError), session.begin_nested():
ua = f.UnixAccountFactory()
user.unix_account = ua
session.add(user)


class TestUserNoUnixAccount:
@pytest.fixture(scope="class")
def user(self, class_session) -> User:
user = f.UserFactory()
class_session.flush()
return user

def test_create_unix_account(self, session, user):
with session.begin_nested():
ua = f.UnixAccountFactory()
user.unix_account = ua
session.add(user)


class TestUnixAccountNoUser:
@pytest.fixture(scope="class")
def unix_account(self, class_session) -> UnixAccount:
ua = f.UnixAccountFactory()
class_session.flush()
return ua

def test_create_user(self, session, ua):
with pytest.raises(IntegrityError), session.begin_nested():
session.add(f.UserFactory(unix_account=ua))


class TestTombstoneLifeCycle:
@pytest.fixture(scope="class")
Expand Down

0 comments on commit 81a0575

Please sign in to comment.