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

[((10, 5, 10, 56), 'pytest.mark.parametrize', 'pytest.mark.parametrize', ({(10, 29, 10, 46): '"""test_s3_enabled"""', (10, 48, 10, 55): '[False]'}, {}), "('test_s3_enabled', [False])", False, 'import pytest\n'), ((18, 5, 18, 55), 'pytest.mark.parametrize', 'pytest.mark.parametrize', ({(18, 29, 18, 46): '"""test_s3_enabled"""', (18, 48, 18, 54): '[True]'}, {}), "('test_s3_enabled', [True])", False, 'import pytest\n'), ((23, 5, 23, 88), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (), '', False, 'import pytest\n'), ((24, 5, 24, 70), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (), '', False, 'import pytest\n'), ((12, 19, 12, 69), 'overhave.transport.OverhaveS3ManagerSettings', 'OverhaveS3ManagerSettings', (), '', False, 'from overhave.transport import OverhaveS3ManagerSettings\n'), ((20, 13, 20, 43), 'pytest.raises', 'pytest.raises', ({(20, 27, 20, 42): 'ValidationError'}, {}), '(ValidationError)', False, 'import pytest\n'), ((21, 12, 21, 62), 'overhave.transport.OverhaveS3ManagerSettings', 'OverhaveS3ManagerSettings', (), '', False, 'from overhave.transport import OverhaveS3ManagerSettings\n')]