import pytest
from pydantic import ValidationError

from overhave.transport import OverhaveS3ManagerSettings


class TestS3ManagerSettings:
    """ Unit tests for :class:`OverhaveS3ManagerSettings`. """

    @pytest.mark.parametrize("test_s3_enabled", [False])
    def test_disabled(self, test_s3_enabled: bool) -> None:
        settings = OverhaveS3ManagerSettings(enabled=test_s3_enabled)
        assert not settings.enabled
        assert not settings.url
        assert not settings.access_key
        assert not settings.secret_key

    @pytest.mark.parametrize("test_s3_enabled", [True])
    def test_empty_enabled(self, test_s3_enabled: bool) -> None:
        with pytest.raises(ValidationError):
            OverhaveS3ManagerSettings(enabled=test_s3_enabled)

    @pytest.mark.parametrize("test_s3_autocreate_buckets", [False, True], indirect=True)
    @pytest.mark.parametrize("test_s3_enabled", [True], indirect=True)
    def test_correct_enabled(
        self,
        test_s3_enabled: bool,
        test_s3_autocreate_buckets: bool,
        test_s3_manager_settings: OverhaveS3ManagerSettings,
    ) -> None:
        assert test_s3_manager_settings.enabled == test_s3_enabled
        assert test_s3_manager_settings.url
        assert test_s3_manager_settings.access_key
        assert test_s3_manager_settings.secret_key
        assert test_s3_manager_settings.verify
        assert test_s3_manager_settings.autocreate_buckets == test_s3_autocreate_buckets

[((209, 260), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""test_s3_enabled"""', '[False]'], {}), "('test_s3_enabled', [False])\n", (232, 260), False, 'import pytest\n'), ((543, 593), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""test_s3_enabled"""', '[True]'], {}), "('test_s3_enabled', [True])\n", (566, 593), False, 'import pytest\n'), ((773, 860), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""test_s3_autocreate_buckets"""', '[False, True]'], {'indirect': '(True)'}), "('test_s3_autocreate_buckets', [False, True],\n    indirect=True)\n", (796, 860), False, 'import pytest\n'), ((862, 927), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""test_s3_enabled"""', '[True]'], {'indirect': '(True)'}), "('test_s3_enabled', [True], indirect=True)\n", (885, 927), False, 'import pytest\n'), ((340, 390), 'overhave.transport.OverhaveS3ManagerSettings', 'OverhaveS3ManagerSettings', ([], {'enabled': 'test_s3_enabled'}), '(enabled=test_s3_enabled)\n', (365, 390), False, 'from overhave.transport import OverhaveS3ManagerSettings\n'), ((672, 702), 'pytest.raises', 'pytest.raises', (['ValidationError'], {}), '(ValidationError)\n', (685, 702), False, 'import pytest\n'), ((716, 766), 'overhave.transport.OverhaveS3ManagerSettings', 'OverhaveS3ManagerSettings', ([], {'enabled': 'test_s3_enabled'}), '(enabled=test_s3_enabled)\n', (741, 766), False, 'from overhave.transport import OverhaveS3ManagerSettings\n')]