Reduce conversion memory footprint
This commit is contained in:
34
tests/test_storage.py
Normal file
34
tests/test_storage.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from pathlib import Path
|
||||
|
||||
from app.services.storage import persist_result
|
||||
|
||||
|
||||
def test_persist_result_writes_csv_and_collects_preview(tmp_path: Path):
|
||||
metadata, export_result = persist_result(
|
||||
output_dir=tmp_path,
|
||||
records=[
|
||||
{
|
||||
"v015xxxxdate": "2024-05-01",
|
||||
"time": "10:00:00",
|
||||
"policy": "Prod Policy",
|
||||
"severity_level": "high",
|
||||
},
|
||||
{
|
||||
"v015xxxxdate": "2024-05-02",
|
||||
"time": "11:00:00",
|
||||
"policy": "Other Policy",
|
||||
"severity_level": "low",
|
||||
},
|
||||
],
|
||||
union_keys=["v015xxxxdate", "time", "policy", "severity_level"],
|
||||
mode="full",
|
||||
output_format="csv",
|
||||
preview_record_limit=1,
|
||||
)
|
||||
|
||||
written = Path(metadata.file_path).read_text(encoding="utf-8")
|
||||
|
||||
assert metadata.download_name == "waf-report.csv"
|
||||
assert "v015xxxxdate,time,policy,severity_level" in written
|
||||
assert "2024-05-01,10:00:00,Prod Policy,high" in written
|
||||
assert export_result.preview(1).count("\n") == 1
|
||||
Reference in New Issue
Block a user