diff --git a/tests/matrix.yaml b/tests/matrix.yaml new file mode 100644 index 0000000..143c151 --- /dev/null +++ b/tests/matrix.yaml @@ -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 diff --git a/tests/test_pyacl.py b/tests/test_pyacl.py index 0bd9241..286df8d 100644 --- a/tests/test_pyacl.py +++ b/tests/test_pyacl.py @@ -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