40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""在途调拨测试固定夹具:时钟、收料文件样例、外部替身与数据库隔离。
|
||
|
||
用途:为 tests/services/in_transit_transfer 提供与 TDD 文档一致的固定输入
|
||
(fixed_clock 默认 2026-08-06 09:00:00+08:00、dbs/crane ready 文件、
|
||
same_day_receipt_file),并组装 FakeERP/FakeRPA/FakeWeCom。
|
||
依赖:根 tests/conftest 的 app fixture(SQLite 内存库)、fakes 模块。
|
||
逻辑:纯单元用例(marker pure_unit 且未请求 app)不创建 Flask/DB;
|
||
请求 transfer_db 的用例复用 app fixture 的 create_all/drop_all 隔离。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
import pytest
|
||
|
||
from tests.services.in_transit_transfer.fakes import FakeClock, FakeERP, FakeRPA, FakeWeCom
|
||
|
||
|
||
@pytest.fixture
|
||
def fixed_clock() -> FakeClock:
|
||
"""固定时钟:默认 2026-08-06 09:00:00+08:00(业务日 T=2026-08-06)。"""
|
||
return FakeClock()
|
||
|
||
|
||
@pytest.fixture
|
||
def erp_fake() -> FakeERP:
|
||
"""FakeERP:账面库存与写响应全部可注入,调用记录可断言。"""
|
||
return FakeERP()
|
||
|
||
|
||
@pytest.fixture
|
||
def rpa_fake() -> FakeRPA:
|
||
"""FakeRPA:按来源实例独立注入失败/延迟。"""
|
||
return FakeRPA()
|
||
|
||
|
||
@pytest.fixture
|
||
def wecom_fake() -> FakeWeCom:
|
||
"""FakeWeCom:记录投递事实,可注入附件失败。"""
|
||
return FakeWeCom()
|