34 lines
1.7 KiB
Python
34 lines
1.7 KiB
Python
"""协议列表可显式读取 V2 样本方案,其他费用摘要消费者保持原行为。"""
|
|
import pytest
|
|
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
from app.models.base import Base
|
|
from app.models.models import BizProtocolSamplePayment
|
|
from app.services.qc_work_order_fee_summary import build_protocol_payment_summaries
|
|
|
|
|
|
@pytest.mark.parametrize('modes,expected,label', [
|
|
(['dj'], 'dj', '趸交'),
|
|
(['fq', 'fq'], 'fq', '分期'),
|
|
(['fgd'], 'fgd', '分改趸'),
|
|
(['fq', 'dj'], 'djfq', '趸交+分期'),
|
|
(['fgd', 'fq'], 'fq+fgd', '分期+分改趸'),
|
|
])
|
|
def test_protocol_list_uses_active_tenant_v2_payment_modes(modes, expected, label):
|
|
engine = create_engine('sqlite:///:memory:')
|
|
Base.metadata.create_all(engine)
|
|
with sessionmaker(bind=engine)() as db:
|
|
for i, mode in enumerate(modes):
|
|
db.add(BizProtocolSamplePayment(id=str(i), collection_protocol_id='p1', sample_code=str(i), pay_mode=mode, tenant_no='tenant-a', del_flag=0))
|
|
db.add_all([
|
|
BizProtocolSamplePayment(id='deleted', collection_protocol_id='p1', sample_code='deleted', pay_mode='djfq', tenant_no='tenant-a', del_flag=1),
|
|
BizProtocolSamplePayment(id='foreign', collection_protocol_id='p1', sample_code='foreign', pay_mode='djfq', tenant_no='tenant-b', del_flag=0),
|
|
])
|
|
db.commit()
|
|
result = build_protocol_payment_summaries(db, ['p1'], 'tenant-a', include_sample_payment_modes=True)
|
|
assert result['p1']['payMode'] == expected
|
|
assert result['p1']['payModeLabel'] == label
|
|
assert build_protocol_payment_summaries(db, ['p1'], 'tenant-a') == {}
|
|
engine.dispose()
|