Files
xiaoxia-saas/tests/unit/test_schema_guard.py
T
Xiaoxia AI 309906cb53
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 13s
Deploy / Deploy Staging (push) Successful in 1m56s
Deploy / Deploy Production (push) Has been skipped
fix(schema): forbid auto create schema in deployed envs
2026-06-21 07:36:46 +08:00

20 lines
866 B
Python

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)