Files
NebulaShell/oss/tests/test_fixes.py
2026-05-04 21:19:34 +08:00

36 lines
997 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Simple test to verify our fixes"""
import os
import tempfile
import pytest
from pathlib import Path
from oss.config import Config
from oss.logger.logger import Logger
def test_cors_fix():
config = Config()
# 验证 CORS 配置默认值
cors_origins = config.get("CORS_ALLOWED_ORIGINS")
assert "http://localhost:3000" in cors_origins
assert "http://127.0.0.1:3000" in cors_origins
# 验证环境变量覆盖 CORS 配置(环境变量值为字符串)
os.environ["CORS_ALLOWED_ORIGINS"] = '["http://localhost:8080"]'
config = Config()
cors_origins = config.get("CORS_ALLOWED_ORIGINS")
# 环境变量覆盖时列表类型保持为字符串Config 不做 JSON 解析)
assert cors_origins == '["http://localhost:8080"]'
del os.environ["CORS_ALLOWED_ORIGINS"]
def test_logger_functionality():
# Logger 不接受参数,使用无参构造
logger = Logger()
assert logger is not None
logger.info("测试日志消息")