调整lsfx mock上传流水条数范围
This commit is contained in:
@@ -40,6 +40,33 @@ def test_upload_file_primary_binding_response(monkeypatch):
|
||||
assert record.account_no_list == ["6222021234567890"]
|
||||
|
||||
|
||||
def test_upload_file_total_records_range(monkeypatch):
|
||||
"""上传文件返回的流水条数必须限制在 150-200 条。"""
|
||||
service = FileService()
|
||||
|
||||
monkeypatch.setattr(
|
||||
service,
|
||||
"_generate_primary_binding",
|
||||
lambda: ("测试主体C", "6222000011112222"),
|
||||
)
|
||||
original_randint = __import__("services.file_service", fromlist=["random"]).random.randint
|
||||
|
||||
def fake_randint(start, end):
|
||||
if (start, end) == (100, 300):
|
||||
return 300
|
||||
return original_randint(start, end)
|
||||
|
||||
monkeypatch.setattr("services.file_service.random.randint", fake_randint)
|
||||
|
||||
background_tasks = BackgroundTasks()
|
||||
file = UploadFile(filename="测试文件.csv", file=io.BytesIO(b"mock"))
|
||||
|
||||
response = asyncio.run(service.upload_file(1001, file, background_tasks))
|
||||
|
||||
total_records = response["data"]["uploadLogList"][0]["totalRecords"]
|
||||
assert 150 <= total_records <= 200
|
||||
|
||||
|
||||
def test_upload_file_then_upload_status_reads_same_record(monkeypatch):
|
||||
"""上传后再查状态时,上传状态接口必须读取同一条真实记录。"""
|
||||
service = FileService()
|
||||
|
||||
Reference in New Issue
Block a user