chore: import WonderQ project

This commit is contained in:
duanshuwen committed 2026-08-11 19:19:11 +08:00
commit f5a9e4403a
452 files changed
+34173

No files matched your search

File diff suppressed because it is too large. Load diff
+9
View File
@@ -0,0 +1,9 @@
from fastapi.testclient import TestClient
from app.main import create_app
def test_health_endpoint():
client = TestClient(create_app())
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"ok": True, "service": "miniapp-api"}
+7
View File
@@ -0,0 +1,7 @@
from app.auth import hash_password, verify_password
def test_bcrypt_hash_verifies_password():
password_hash = hash_password("ChangeMe123!", rounds=4)
assert verify_password("ChangeMe123!", password_hash)
assert not verify_password("bad-password", password_hash)
+27
View File
@@ -0,0 +1,27 @@
from app.config import Settings
def test_oss_settings_are_loaded_from_prefixed_environment(monkeypatch):
monkeypatch.setenv("OSS_ACCESS_KEY_ID", "example-access-key-id")
monkeypatch.setenv("OSS_ACCESS_KEY_SECRET", "example-access-key-secret")
monkeypatch.setenv("OSS_ENDPOINT", "oss-cn-example.aliyuncs.com")
monkeypatch.setenv("OSS_BUCKET_NAME", "example-bucket")
settings = Settings(_env_file=None)
assert settings.oss_access_key_id == "example-access-key-id"
assert settings.oss_access_key_secret == "example-access-key-secret"
assert settings.oss_endpoint == "oss-cn-example.aliyuncs.com"
assert settings.oss_bucket_name == "example-bucket"
def test_wechat_miniapp_settings_are_loaded_from_environment(monkeypatch):
monkeypatch.setenv("WECHAT_MINIAPP_APPID", "wx-test-appid")
monkeypatch.setenv("WECHAT_MINIAPP_SECRET", "test-secret")
monkeypatch.setenv("CUSTOMER_JWT_EXPIRES_HOURS", "24")
settings = Settings(_env_file=None)
assert settings.wechat_miniapp_appid == "wx-test-appid"
assert settings.wechat_miniapp_secret == "test-secret"
assert settings.customer_jwt_expires_hours == 24
+13
View File
@@ -0,0 +1,13 @@
import pytest
from pydantic import ValidationError
from app.schemas import LeadCreateIn, ProductCreateIn
def test_lead_phone_is_normalized():
lead = LeadCreateIn(phone=" 187 8617 4929 ")
assert lead.phone == "187 8617 4929"
def test_product_title_requires_two_chars():
with pytest.raises(ValidationError):
ProductCreateIn(title="A")