Add tests for account ACL model

Add string repr to account ACL model
This commit is contained in:
Ethan Paul 2020-02-24 23:09:05 -05:00
parent 54ac7c4141
commit ae86a5d21c
2 changed files with 15 additions and 0 deletions

View File

@ -47,3 +47,6 @@ class AccountACLEntry(KeyoskBaseModel):
yield "permission", self.permission.name
yield "with_server_secret", self.with_server_secret
yield "with_client_secret", self.with_client_secret
def __str__(self):
return f"ACL {self.permission.name}@{self.access_list.name} (scope:{'+'.join([item for item in ['server' if self.with_server_secret else '', 'client' if self.with_client_secret else ''] if item])})"

View File

@ -0,0 +1,12 @@
import json
import peewee
from fixtures import demo_database
from keyosk import database
def test_formatting(demo_database):
for acl in database.AccountACLEntry.select():
assert dict(acl) == json.loads(json.dumps(dict(acl)))
assert str(acl.uuid) not in str(acl)