test_config.py 842 B

12345678910111213141516171819202122232425
  1. import pytest
  2. from pydantic import ValidationError
  3. from zhifu.core.config import Settings
  4. def test_state_and_cache_require_separate_services():
  5. with pytest.raises(ValidationError, match="独立 Redis"):
  6. Settings(
  7. _env_file=None,
  8. database_url="mysql+asyncmy://user:password@localhost/database",
  9. cache_url="redis://localhost:6379/0",
  10. state_url="redis://localhost:6379/1",
  11. )
  12. def test_production_rejects_development_credentials():
  13. with pytest.raises(ValidationError, match="独立凭据"):
  14. Settings(
  15. _env_file=None,
  16. environment="production",
  17. database_url="mysql+asyncmy://user:zhifu_local_only@localhost/database",
  18. cache_url="redis://localhost:6379/0",
  19. state_url="redis://localhost:6380/0",
  20. )