chore: auto release commit (2026-07-03 12:09:55)
All checks were successful
技能自动化发布 / release (push) Successful in 5s
All checks were successful
技能自动化发布 / release (push) Successful in 5s
This commit is contained in:
44
scripts/service/amazon_report_adapter/mock.py
Normal file
44
scripts/service/amazon_report_adapter/mock.py
Normal file
@@ -0,0 +1,44 @@
|
||||
"""mock / unit 档位:不启动浏览器,返回假 job_id 与假 xlsx 路径。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import time
|
||||
from typing import Optional
|
||||
|
||||
from service.amazon_report_adapter.base import DownloadSettlementAdapterBase, DownloadSettlementResult
|
||||
|
||||
|
||||
class MockDownloadSettlementAdapter(DownloadSettlementAdapterBase):
|
||||
name = "mock"
|
||||
|
||||
def download_settlement(
|
||||
self,
|
||||
*,
|
||||
date_from: str,
|
||||
date_to: str,
|
||||
seller_code: Optional[str] = None,
|
||||
downloads_dir: str = "",
|
||||
artifacts_dir: str = "",
|
||||
) -> DownloadSettlementResult:
|
||||
del artifacts_dir
|
||||
os.makedirs(downloads_dir, exist_ok=True)
|
||||
time.sleep(0.05)
|
||||
ts = int(time.time())
|
||||
job_id = f"MOCK-{ts}"
|
||||
seller = seller_code or "MOCK-SELLER"
|
||||
filename = f"settlement_{seller}_{date_from}_{date_to}_{ts}.xlsx"
|
||||
file_path = os.path.join(downloads_dir, filename)
|
||||
with open(file_path, "wb") as fh:
|
||||
fh.write(b"PK\x03\x04mock-settlement-xlsx")
|
||||
return DownloadSettlementResult(
|
||||
ok=True,
|
||||
job_id=job_id,
|
||||
file_path=file_path,
|
||||
filename=filename,
|
||||
date_from=date_from,
|
||||
date_to=date_to,
|
||||
seller_code=seller,
|
||||
error_msg=None,
|
||||
artifacts={"adapter": self.name},
|
||||
)
|
||||
Reference in New Issue
Block a user