Пример #1
0
def test_set_permission(filesystem: FileSystemImpl,
                        lpaths: Dict[str, AbstractPath]) -> None:
    if filesystem._supports('permissions'):
        for permission in Permission:
            filesystem._set_permission(lpaths['root'], permission, False)

        for permission in Permission:
            assert not filesystem._has_permission(lpaths['root'], permission)

        for permission in Permission:
            filesystem._set_permission(lpaths['root'], permission, True)
            for p2 in Permission:
                is_same = (permission == p2)
                assert filesystem._has_permission(lpaths['root'],
                                                  p2) == is_same
            filesystem._set_permission(lpaths['root'], permission, False)

        filesystem._chmod(lpaths['root'], 0o0755)
Пример #2
0
def test_chmod(filesystem: FileSystemImpl, lpaths: Dict[str,
                                                        AbstractPath]) -> None:
    if filesystem._supports('permissions'):
        filesystem._chmod(lpaths['root'], 0o0000)
        for permission in Permission:
            assert not filesystem._has_permission(lpaths['root'], permission)
        filesystem._chmod(lpaths['root'], 0o0755)
        granted_permissions = [
            Permission.OWNER_READ, Permission.OWNER_WRITE,
            Permission.OWNER_EXECUTE, Permission.GROUP_READ,
            Permission.GROUP_EXECUTE, Permission.OTHERS_READ,
            Permission.OTHERS_EXECUTE
        ]
        for permission in Permission:
            if permission in granted_permissions:
                assert filesystem._has_permission(lpaths['root'], permission)
            else:
                assert not filesystem._has_permission(lpaths['root'],
                                                      permission)