Files
sabnzbd/tests/test_utils/test_checkdir.py
Safihre 661b4ae535 Use native API for FAT filesystem detection on macOS
The previous method for detecting FAT filesystems on macOS relied on parsing `df` and `mount` command output, which is brittle and prone to issues with command output variations.

This change replaces the shell command parsing with a more robust and idiomatic approach using Foundation.framework's `NSURL` API. This directly queries the volume's localized format description, ensuring accurate identification of MS-DOS (FAT12/FAT16/FAT32) volumes while correctly distinguishing them from ExFAT.

Adds unit tests for the `isFAT` function to verify basic functionality and error handling.

Closes #3483
2026-07-10 10:28:08 +02:00

38 lines
1.4 KiB
Python

#!/usr/bin/python3 -OO
# Copyright 2007-2026 by The SABnzbd-Team (sabnzbd.org)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
tests.test_utils.test_checkdir - Testing SABnzbd checkdir
"""
from sabnzbd.utils.checkdir import isFAT
class TestIsFAT:
"""test sabnzbd.utils.checkdir.isFAT"""
def test_not_fat(self, tmp_path, capsys):
"""The test system is not expected to run on FAT"""
assert isFAT(str(tmp_path)) is False
# isFAT prints in its exception handler, so no output means no exception was raised
assert capsys.readouterr().out == ""
def test_non_existing_dir(self, capsys):
"""A non-existing dir is not FAT"""
assert isFAT("such_a_dir_does_not_exist") is False
assert capsys.readouterr().out == ""