18 lines
688 B
Python
18 lines
688 B
Python
from pathlib import Path
|
|
|
|
from fao.ingest.adapters.demo_json import DemoJsonAdapter
|
|
|
|
|
|
def test_demo_json_builds_demo_source(tmp_path: Path) -> None:
|
|
sample = tmp_path / "x.json"
|
|
sample.write_text(
|
|
'{"schema_version":1,"items":[{"variety_code":"x","variety_name":"X","biz_date":"2026-04-23","avg_price_yuan_per_kg":1.2,"market_code":"M","unit":"yuan_per_kg"}]}',
|
|
encoding="utf-8",
|
|
)
|
|
r = DemoJsonAdapter(sample_path=sample).run()
|
|
assert r.source_code == "DEMO"
|
|
assert r.adapter_name == "demo_json"
|
|
assert len(r.content_fingerprint) == 64
|
|
assert r.payload["kind"] == "price_quote_batch"
|
|
assert r.payload["items"][0]["variety_code"] == "x"
|