import pytest

from packages.adapters.sqlalchemy_impl.schema_guard import assert_auto_create_schema_allowed


@pytest.mark.parametrize("environment", ["staging", "production", " STAGING ", "Production"])
def test_auto_create_schema_is_forbidden_in_deployed_environments(environment):
    with pytest.raises(RuntimeError, match="AUTO_CREATE_SCHEMA is forbidden"):
        assert_auto_create_schema_allowed(environment, enabled=True)


@pytest.mark.parametrize("environment", ["development", "test", "local", ""])
def test_auto_create_schema_is_allowed_only_for_local_environments(environment):
    assert_auto_create_schema_allowed(environment, enabled=True)


@pytest.mark.parametrize("environment", ["staging", "production"])
def test_disabled_auto_create_schema_is_allowed_everywhere(environment):
    assert_auto_create_schema_allowed(environment, enabled=False)
