36 lines
997 B
Python
36 lines
997 B
Python
"""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("测试日志消息")
|