diff --git a/tests/conftest.py b/tests/conftest.py index 65ab500..576d959 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,14 +14,17 @@ from subprocess import run import pytest -@pytest.fixture(scope='session') -def sample_file(tmp_path_factory): +#@pytest.fixture(scope='session') +@pytest.fixture +def sample_file(tmp_path_factory, aclin): directory = tmp_path_factory.mktemp('sample_files') file = directory / 'file_with_user_read_acl' file.touch() assert not file.read_text() # file should exist - run(['setfacl', '-m', 'u:user:r', file], check=True) + requested_acl = aclin + print(requested_acl) + run(['setfacl', '-m', requested_acl, file], check=True) out = run(['getfacl', '-c', file], check=True, capture_output=True) - assert 'user:user:r--' in out.stdout.decode() # file should have the ACL set + assert requested_acl in out.stdout.decode() # file should have the ACL set yield file rmtree(directory) diff --git a/tests/test_pyacl.py b/tests/test_pyacl.py index c82b136..0bd9241 100644 --- a/tests/test_pyacl.py +++ b/tests/test_pyacl.py @@ -8,39 +8,80 @@ 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 pytest import mark + from pyacl import acl - -def test_parse_acl(sample_file): - want = { - 'user': { +testdata = [ + ( + 'user:user:r', + { 'user': { - 'read': True, - 'write': False, - 'execute': False, + '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, + }, }, }, - 'group': { - 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, + }, }, }, - 'mask': { - None: { - 'read': True, - 'write': False, - 'execute': False, - }, - }, - 'other': { - None: { - 'read': True, - 'write': False, - 'execute': False, - }, - }, - } + ), +] + +@mark.parametrize('aclin, aclout', testdata) +def test_parse_acl(sample_file, aclin, aclout): have = acl.parsefromfile(sample_file) - assert want == have + assert aclout == have