from __future__ import annotations from pytest import MonkeyPatch from core.config.settings import Settings def test_social_prefixed_supabase_env_populates_settings( monkeypatch: MonkeyPatch, ) -> None: monkeypatch.setenv("SOCIAL_SUPABASE__PUBLIC_SCHEME", "https") monkeypatch.setenv("SOCIAL_SUPABASE__PUBLIC_HOST", "public.example") monkeypatch.setenv("SOCIAL_SUPABASE__KONG_HTTP_PORT", "8443") monkeypatch.setenv("SOCIAL_SUPABASE__ANON_KEY", "anon-key") monkeypatch.setenv("SOCIAL_SUPABASE__SERVICE_ROLE_KEY", "service-key") monkeypatch.setenv("SOCIAL_SUPABASE__JWT_SECRET", "jwt-secret") monkeypatch.setenv("SOCIAL_SUPABASE__SITE_URL", "https://app.example.com") monkeypatch.setenv( "SOCIAL_SUPABASE__ADDITIONAL_REDIRECT_URLS", '["https://a.example.com", "https://b.example.com/path"]', ) monkeypatch.setenv("SOCIAL_DATABASE__HOST", "db") monkeypatch.setenv("SOCIAL_DATABASE__PORT", "5432") monkeypatch.setenv("SOCIAL_DATABASE__NAME", "app") monkeypatch.setenv("SOCIAL_DATABASE__USER", "user") monkeypatch.setenv("SOCIAL_DATABASE__PASSWORD", "pass") settings = Settings() assert settings.supabase.public_url == "https://public.example:8443" assert settings.supabase.anon_key == "anon-key" assert settings.supabase.service_role_key == "service-key" assert settings.supabase.jwt_secret == "jwt-secret" assert settings.supabase.site_url == "https://app.example.com" assert settings.supabase.additional_redirect_urls == [ "https://a.example.com", "https://b.example.com/path", ] supabase_settings = settings.model_dump()["supabase"] assert supabase_settings["public_url"] == "https://public.example:8443" assert supabase_settings["anon_key"] == "anon-key" assert supabase_settings["service_role_key"] == "service-key" assert supabase_settings["jwt_secret"] == "jwt-secret" assert supabase_settings["site_url"] == "https://app.example.com" assert settings.database_url == "postgresql+asyncpg://user:pass@db:5432/app"