Skip to content

Commit

Permalink
added test for exceeded clients
Browse files Browse the repository at this point in the history
added a test for too much mpsks clients added

Signed-off-by: Alex <[email protected]>
#744
  • Loading branch information
agmes4 committed Sep 19, 2024
1 parent b0209cc commit adf2433
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/model/test_mpsk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm.base import object_state

from pycroft.lib.mpsk_client import mpsk_client_create
from pycroft.model.mpsk_client import MPSKClient
from pycroft.model.types import InvalidMACAddressException
from pycroft.model.types import InvalidMACAddressException, AmountExceededError
from .. import factories


Expand Down Expand Up @@ -69,6 +70,20 @@ def test_names(self, session, user, name):
mpsk_client = MPSKClient(mac="00:00:00:00:00:00", name=name, owner=user)
assert mpsk_client.name == name

def test_exceeds_max(self, session, user):
mac = "00:00:00:00:00:0"
for i in range(10):
mac_client = mac + hex(i)[2:]
c = mpsk_client_create(user, "Hallo", mac_client, user)
user.mpsks.append(c)
session.flush()
assert len(user.mpsks) == i + 1

for i in range(10, 15):
mac_client = mac + hex(i)[2:]
with pytest.raises(AmountExceededError):
c = mpsk_client_create(user, "Hallo", mac_client, user)

@pytest.fixture(scope="class")
def user(self, class_session):
user = factories.UserFactory.build(with_host=True)
Expand Down

0 comments on commit adf2433

Please sign in to comment.