# _update_test_utils.py
#
# Project: AutoArchive
# License: GNU GPLv3
#
# Copyright (C) 2003 - 2026 Róbert Čerňanský



__all__ = ["_UpdateTestUtils"]



from typing import Iterable
from unittest.mock import PropertyMock

from mock import MagicMock

from AutoArchive._infrastructure.app_dir.app_dir import AppDir
from AutoArchive._update._file_system import _FileSystem



class _UpdateTestUtils:

    @staticmethod
    def setupAppDirMock(path: str, isCurrent: bool = None):
        appDirMock = MagicMock(spec_set = AppDir)
        type(appDirMock).path = PropertyMock(return_value = path)
        if isCurrent is not None:
            appDirMock.isCurrentVersion.return_value = isCurrent
        return appDirMock



    @staticmethod
    def setupFileSystemMock(existingPaths: Iterable[str]):
        fileSystemMock = MagicMock(spec_set = _FileSystem)
        fileSystemMock.exists.side_effect = lambda path: path in existingPaths
        return fileSystemMock
