chore(alembic): merge comparison_milestone 和 savings_report_fields 两个 head (#11)
Co-authored-by: OuYingJun1024 <1034284404@qq.com> Reviewed-on: #11 Co-authored-by: ouzhou <ouzhou@wonderable.ai> Co-committed-by: ouzhou <ouzhou@wonderable.ai>
This commit was merged in pull request #11.
This commit is contained in:
@@ -33,7 +33,7 @@ def _food_payload(trace_id: str) -> dict:
|
||||
],
|
||||
"comparison_results": [
|
||||
{"platform_id": "meituan", "platform_name": "美团", "package": "com.sankuai.meituan",
|
||||
"price": 123.50, "is_source": False, "rank": 1},
|
||||
"price": 123.50, "is_source": False, "rank": 1, "coupon_saved": 7.0},
|
||||
{"platform_id": "taobao_flash", "platform_name": "淘宝闪购", "package": "com.taobao.taobao",
|
||||
"price": 128.50, "is_source": True, "rank": 2},
|
||||
{"platform_id": "jd_waimai", "platform_name": "京东外卖", "package": "com.jingdong.app.mall",
|
||||
@@ -78,6 +78,18 @@ def test_report_and_derive(client) -> None:
|
||||
assert d["raw_payload"]["trace_id"] == "trace-1"
|
||||
|
||||
|
||||
def test_coupon_saved_passthrough(client) -> None:
|
||||
"""红包优惠额 coupon_saved 上报→落库→读出;仅目标平台带值,源平台不带(null)。"""
|
||||
token = _login(client, "13800002010")
|
||||
rid = client.post(
|
||||
"/api/v1/compare/record", json=_food_payload("trace-coupon"), headers=_auth(token)
|
||||
).json()["id"]
|
||||
d = client.get(f"/api/v1/compare/records/{rid}", headers=_auth(token)).json()
|
||||
by_pid = {x["platform_id"]: x for x in d["comparison_results"]}
|
||||
assert by_pid["meituan"]["coupon_saved"] == 7.0 # 目标平台带值
|
||||
assert by_pid["taobao_flash"].get("coupon_saved") is None # 源平台不带/为 null
|
||||
|
||||
|
||||
def test_source_is_cheapest_no_saving(client) -> None:
|
||||
"""源平台本来就最便宜:saved<=0,is_source_best=True,仍记一条 success。"""
|
||||
token = _login(client, "13800002002")
|
||||
|
||||
Reference in New Issue
Block a user