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



__all__ = ["TestInternalGetAvailableBackupTypes", "TestExternalGetAvailableBackupTypes"]



import unittest
from abc import abstractmethod

from AutoArchive._services.archiver._external_tar_archiver_provider.external_tar_archiver_provider import ExternalTarArchiverProvider
from AutoArchive._services.archiver._internal_tar_archiver_provider import _InternalTarArchiverProvider
from AutoArchive._services.archiver.tar_archiver_provider_base import TarArchiverProviderBase
from AutoArchive._services.archiver.tests import ArchiverTestUtils
from AutoArchive.tests import ComponentTestUtils



class _TestGetAvailableBackupTypes(unittest.TestCase):
    """Base class for tests of tar archiver providers for getting available backup types."""



    @classmethod
    def setUpClass(cls):
        ArchiverTestUtils._setUpClassArchiverComponent()



    @classmethod
    def tearDownClass(cls):
        ArchiverTestUtils._tearDownClassArchiverComponent()



    def setUp(self):
        self.archiverProvider_: TarArchiverProviderBase = self.createTestSubject_()



    def tearDown(self):
        pass



    @abstractmethod
    def createTestSubject_(self) -> TarArchiverProviderBase:
        """Creates an instance of tested archiver provider."""



    def test_getAvailableBackupTypes(self):
        """Tests getAvailableBackupTypes method."""

        availableBackupTypes = list(self.archiverProvider_.getAvailableBackupTypes())
        self.assertSequenceEqual(list(self.archiverProvider_.supportedBackupTypes), availableBackupTypes)



class TestInternalGetAvailableBackupTypes(_TestGetAvailableBackupTypes):
    """Tests of internal tar archiver provider for getting available backup types."""

    def createTestSubject_(self):
        return _InternalTarArchiverProvider(ComponentTestUtils.getComponentTestContext().workDir)



class TestExternalGetAvailableBackupTypes(_TestGetAvailableBackupTypes):
    """Tests of external tar archiver provider for getting available backup types."""

    def createTestSubject_(self):
        return ExternalTarArchiverProvider(ComponentTestUtils.getComponentTestContext().workDir)
