1
0
mirror of https://github.com/enpaul/keyosk.git synced 2024-11-05 06:07:06 +00:00
keyosk/tests/test_serializers_domain.py
Ethan Paul f59afcccf7 Add basic roundtrip test for domain serializer
Fix dumping and loading compatibility of domain model
Fix (untested) dumping and loading compatibility of account model
Loosen simple name regex requirements
2020-03-10 23:29:05 -04:00

21 lines
656 B
Python

# pylint: disable=unused-argument,redefined-outer-name,unused-import
import pytest
from fixtures import demo_database
from keyosk import database
from keyosk import serializers
def test_roundtrip(demo_database):
serializer = serializers.DomainSerializer()
for domain in database.KeyoskDomain.select():
dumped = serializer.dump(domain)
assert sorted(dumped["permissions"]) == sorted(
[permission.name for permission in domain.permissions]
)
assert sorted(dumped["access-lists"]) == sorted(
acl.name for acl in domain.access_lists
)
assert domain == serializer.load(dumped)