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



__all__ = ["TestUserConfigPathMigrator"]



import unittest

from mock import MagicMock, ANY

from AutoArchive._update.tests._update_test_utils import _UpdateTestUtils
from AutoArchive._update._user_config_path_migrator import _UserConfigPathMigrator



class TestUserConfigPathMigrator(unittest.TestCase):

    __OLD_CONFIG_DIR_PATH = "test old user configuration directory path"
    __NEW_CONFIG_DIR_PATH = "test new user configuration directory path"



    def test_PathsAreDifferent_OldDirExistsAndIsNotCurrent_NewDirNotExists(self):
        oldConfigDirMock = _UpdateTestUtils.setupAppDirMock(path = self.__OLD_CONFIG_DIR_PATH, isCurrent = False)
        newConfigDirMock = _UpdateTestUtils.setupAppDirMock(path = self.__NEW_CONFIG_DIR_PATH)
        fileSystemMock = _UpdateTestUtils.setupFileSystemMock(existingPaths = [self.__OLD_CONFIG_DIR_PATH])

        _UserConfigPathMigrator(fileSystemMock, oldConfigDirMock, newConfigDirMock, MagicMock()).migrate()

        fileSystemMock.moveWithBackup.assert_called_once_with(
            self.__OLD_CONFIG_DIR_PATH, self.__NEW_CONFIG_DIR_PATH, ANY)
        oldConfigDirMock.setToCurrentVersion.assert_not_called()
        newConfigDirMock.setToCurrentVersion.assert_called_once()
