forked from Georg/pyacl
Move test parameters to YAML
The large amount of test data can be managed more easily if it is contained in a separate file instead of being in the test code. Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
10a3123305
commit
7fe8afba38
43
tests/matrix.yaml
Normal file
43
tests/matrix.yaml
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
- user:user:r:
|
||||
user:
|
||||
user:
|
||||
read: true
|
||||
write: false
|
||||
execute: false
|
||||
group:
|
||||
null:
|
||||
read: true
|
||||
write: false
|
||||
execute: false
|
||||
mask:
|
||||
null:
|
||||
read: true
|
||||
write: false
|
||||
execute: false
|
||||
other:
|
||||
null:
|
||||
read: true
|
||||
write: false
|
||||
execute: false
|
||||
- user:user:-w-:
|
||||
user:
|
||||
user:
|
||||
read: false
|
||||
write: true
|
||||
execute: false
|
||||
group:
|
||||
null:
|
||||
read: true
|
||||
write: false
|
||||
execute: false
|
||||
mask:
|
||||
null:
|
||||
read: true
|
||||
write: true
|
||||
execute: false
|
||||
other:
|
||||
null:
|
||||
read: true
|
||||
write: false
|
||||
execute: false
|
@ -8,80 +8,27 @@ An English copy of the Licence is shipped in a file called LICENSE along with th
|
||||
You may obtain copies of the Licence in any of the official languages at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12.
|
||||
"""
|
||||
|
||||
from os.path import dirname, join
|
||||
|
||||
from pytest import mark
|
||||
from yaml import safe_load
|
||||
|
||||
from pyacl import acl
|
||||
|
||||
testdata = [
|
||||
(
|
||||
'user:user:r',
|
||||
{
|
||||
'user': {
|
||||
'user': {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'group': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'mask': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'other': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
},
|
||||
),
|
||||
(
|
||||
'user:user:-w-',
|
||||
{
|
||||
'user': {
|
||||
'user': {
|
||||
'read': False,
|
||||
'write': True,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'group': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'mask': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': True,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
'other': {
|
||||
None: {
|
||||
'read': True,
|
||||
'write': False,
|
||||
'execute': False,
|
||||
},
|
||||
},
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
@mark.parametrize('aclin, aclout', testdata)
|
||||
def load_yaml(file):
|
||||
with open(join(dirname(__file__), file)) as fh:
|
||||
data = safe_load(fh)
|
||||
|
||||
out = []
|
||||
|
||||
for entry in data:
|
||||
out.append(tuple(entry.items())[0])
|
||||
|
||||
return out
|
||||
|
||||
|
||||
@mark.parametrize('aclin, aclout', load_yaml('matrix.yaml'))
|
||||
def test_parse_acl(sample_file, aclin, aclout):
|
||||
have = acl.parsefromfile(sample_file)
|
||||
assert aclout == have
|
||||
|
Loading…
Reference in New Issue
Block a user