test_app_api.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. from __future__ import annotations
  2. from contextlib import nullcontext
  3. from pathlib import Path
  4. from uuid import uuid4
  5. from fastapi.testclient import TestClient
  6. from acquisition.domain import AcquisitionRun, Query, QueryBatch
  7. from app.api import app
  8. from app.dependencies import (
  9. get_acquisition_repository,
  10. get_creation_db_config,
  11. get_decode_repository,
  12. get_pipeline_repository,
  13. )
  14. from app.routes import decode as decode_routes
  15. from app.routes import manual_queries
  16. from decode_content.models import (
  17. DecodeJob,
  18. DecodeResult,
  19. IngestRecord,
  20. KnowledgeParticle,
  21. PayloadDraft,
  22. ScopeResult,
  23. )
  24. from pipeline.models import PipelineRun
  25. class FakeAcquisitionRepo:
  26. def __init__(self):
  27. self.batch_id = uuid4()
  28. self.run_id = uuid4()
  29. self.query_id = uuid4()
  30. self.item_id = uuid4()
  31. self.media_id = uuid4()
  32. self.classification_id = uuid4()
  33. def get_query_batch(self, batch_id):
  34. assert batch_id == self.batch_id
  35. return QueryBatch(
  36. id=batch_id,
  37. name="正式 query 批次",
  38. source_type="manual",
  39. target_platforms=["xiaohongshu", "weixin", "douyin"],
  40. status="ready",
  41. )
  42. def list_queries_for_batch(self, batch_id, *, keep=None):
  43. assert batch_id == self.batch_id
  44. return [
  45. Query(
  46. id=self.query_id,
  47. batch_id=batch_id,
  48. query_text="短视频脚本 开头 怎么写",
  49. keep=True,
  50. status="ready",
  51. )
  52. ]
  53. def get_run_summary(self, run_id):
  54. assert run_id == self.run_id
  55. return {
  56. "id": run_id,
  57. "run_key": "run-1",
  58. "batch_id": self.batch_id,
  59. "status": "running",
  60. "query_count": 1,
  61. "job_count": 3,
  62. "candidate_count": 5,
  63. "creation_hit_count": 2,
  64. "queries": [
  65. {
  66. "query_id": self.query_id,
  67. "query_text": "短视频脚本 开头 怎么写",
  68. "candidate_count": 5,
  69. "creation_hit_count": 2,
  70. "platforms": {"xiaohongshu": {"status": "done"}},
  71. }
  72. ],
  73. }
  74. def get_query_detail(self, *, run_id, query_id):
  75. assert run_id == self.run_id
  76. assert query_id == self.query_id
  77. return {
  78. "query": {
  79. "id": query_id,
  80. "batch_id": self.batch_id,
  81. "query_text": "短视频脚本 开头 怎么写",
  82. "axes": {},
  83. "keep": True,
  84. "filter_reason": None,
  85. "status": "ready",
  86. "sort_order": 0,
  87. },
  88. "jobs": [{"id": uuid4(), "platform": "xiaohongshu", "status": "done"}],
  89. "items": [
  90. {
  91. "id": self.item_id,
  92. "platform": "xiaohongshu",
  93. "platform_item_id": "xhs1",
  94. "unique_key": "xhs:xhs1",
  95. "canonical_url": "https://xhs.test/1",
  96. "content_type": "图文",
  97. "content_mode": "image_post",
  98. "title": "脚本开头",
  99. "author_name": "作者",
  100. "body_text": "先定受众,再写开头钩子",
  101. "raw_summary": "先定受众",
  102. "status": "candidate",
  103. }
  104. ],
  105. "media_assets": [
  106. {
  107. "id": self.media_id,
  108. "item_id": self.item_id,
  109. "media_type": "image",
  110. "source_url": "https://origin.test/1.jpg",
  111. "oss_url": "https://oss.test/1.jpg",
  112. "cdn_url": "https://cdn.test/1.jpg",
  113. "position": 1,
  114. "status": "done",
  115. }
  116. ],
  117. "classifications": [
  118. {
  119. "id": self.classification_id,
  120. "item_id": self.item_id,
  121. "is_creation_knowledge": True,
  122. "label": "creation",
  123. "confidence": 0.98,
  124. "reason": "可复用",
  125. "status": "done",
  126. "error_message": None,
  127. }
  128. ],
  129. }
  130. def get_latest_query_result_list(self, query_id):
  131. assert query_id == self.query_id
  132. return {
  133. "query": {
  134. "id": query_id,
  135. "batch_id": self.batch_id,
  136. "query_text": "短视频脚本 开头 怎么写",
  137. "axes": {},
  138. "keep": True,
  139. "filter_reason": None,
  140. "status": "ready",
  141. "sort_order": 0,
  142. },
  143. "run": {
  144. "id": self.run_id,
  145. "batch_id": self.batch_id,
  146. "run_key": "run-1",
  147. "status": "running",
  148. },
  149. "jobs": [{"id": uuid4(), "platform": "xiaohongshu", "status": "done"}],
  150. "items": [
  151. {
  152. "id": self.item_id,
  153. "platform": "xiaohongshu",
  154. "title": "脚本开头",
  155. "raw_summary": "先定受众",
  156. "status": "candidate",
  157. "content_mode": "image_post",
  158. "metadata": {
  159. "page_index": 1,
  160. "matched_candidate": {"raw": "large"},
  161. "source_payload": {"raw": "large"},
  162. },
  163. }
  164. ],
  165. "media_assets": [
  166. {
  167. "id": self.media_id,
  168. "item_id": self.item_id,
  169. "media_type": "image",
  170. "source_url": "https://origin.test/1.jpg",
  171. "oss_url": "https://oss.test/1.jpg",
  172. "cdn_url": "https://cdn.test/1.jpg",
  173. "position": 1,
  174. "status": "done",
  175. }
  176. ],
  177. "classifications": [
  178. {
  179. "id": self.classification_id,
  180. "item_id": self.item_id,
  181. "is_creation_knowledge": True,
  182. "label": "creation",
  183. "confidence": 0.98,
  184. "status": "done",
  185. "error_message": None,
  186. }
  187. ],
  188. "decode_summaries": [
  189. {
  190. "item_id": self.item_id,
  191. "decode_status": "decoded",
  192. "particle_count": 1,
  193. "payload_count": 1,
  194. }
  195. ],
  196. }
  197. def get_candidate_item(self, item_id):
  198. assert item_id == self.item_id
  199. return self.get_query_detail(run_id=self.run_id, query_id=self.query_id)["items"][0]
  200. def list_media_assets_for_item(self, item_id):
  201. assert item_id == self.item_id
  202. return self.get_query_detail(run_id=self.run_id, query_id=self.query_id)["media_assets"]
  203. class FakeDecodeRepo:
  204. def __init__(self):
  205. self.decode_result_id = uuid4()
  206. self.decode_job_id = uuid4()
  207. self.payload_id = uuid4()
  208. self.other_payload_id = uuid4()
  209. self.marked_payload_ids = []
  210. self.saved_ingest_records = []
  211. def get_decode_result_for_item(self, item_id):
  212. return DecodeResult(
  213. id=self.decode_result_id,
  214. item_id=item_id,
  215. status="decoded",
  216. read_result={"text": "读懂后的帖子内容"},
  217. gate_result={"passed": True, "reason": "具备可复用创作方法"},
  218. framing_result={"particles": []},
  219. )
  220. def create_decode_job(self, *, item_id, status="pending", metadata=None):
  221. return DecodeJob(
  222. id=self.decode_job_id,
  223. item_id=item_id,
  224. status=status,
  225. metadata=metadata or {},
  226. )
  227. def list_payload_drafts(self, item_id=None):
  228. return [
  229. PayloadDraft(
  230. id=self.payload_id,
  231. item_id=item_id or uuid4(),
  232. payload={
  233. "source": {"id": "xhs_1", "source_type": "post", "title": "脚本开头", "author": "作者"},
  234. "title": "可审核 payload",
  235. "content": "先定受众,再写开头钩子。",
  236. "dim_attributes": ["how"],
  237. "dim_creations": ["创作"],
  238. "scopes": [{"scope_type": "intent", "value": "吸引注意"}],
  239. "custom_ext": [{"key": "业务阶段", "type": "str", "value": "脚本"}],
  240. },
  241. review_status="pending",
  242. ingest_ready=False,
  243. status="draft",
  244. )
  245. ]
  246. def mark_payload_draft_ingested(self, payload_draft_id):
  247. self.marked_payload_ids.append(payload_draft_id)
  248. return PayloadDraft(
  249. id=payload_draft_id,
  250. item_id=uuid4(),
  251. payload=self.list_payload_drafts()[0].payload,
  252. review_status="approved",
  253. ingest_ready=True,
  254. status="ingested",
  255. )
  256. def save_ingest_record(self, **kwargs):
  257. record = IngestRecord(id=uuid4(), **kwargs)
  258. self.saved_ingest_records.append(record)
  259. return record
  260. def list_knowledge_particles(self, item_id=None):
  261. return [
  262. KnowledgeParticle(
  263. id=uuid4(),
  264. item_id=item_id or uuid4(),
  265. particle_type="what",
  266. title="What I know",
  267. content={"content": "一个可复用知识点"},
  268. status="draft",
  269. )
  270. ]
  271. def list_scope_results(self, item_id=None):
  272. return [
  273. ScopeResult(
  274. id=uuid4(),
  275. item_id=item_id or uuid4(),
  276. scope_type="intent",
  277. scope_value="吸引注意",
  278. status="draft",
  279. )
  280. ]
  281. def list_ingest_records(self, item_id=None):
  282. if self.saved_ingest_records:
  283. return self.saved_ingest_records
  284. return [
  285. IngestRecord(
  286. id=uuid4(),
  287. payload_draft_id=self.payload_id,
  288. target_system="dry-run",
  289. status="ingested",
  290. )
  291. ]
  292. class FakePipelineRepo:
  293. def get_pipeline_run(self, run_id):
  294. return PipelineRun(
  295. id=run_id,
  296. run_key="pipeline-run-1",
  297. status="running",
  298. current_stage="decode",
  299. )
  300. class FakeManualRepo:
  301. def __init__(self):
  302. self.batch_id = uuid4()
  303. self.run_id = uuid4()
  304. self.queries = []
  305. self.runs = []
  306. self.updates = []
  307. def create_query_batch(self, **kwargs):
  308. self.batch_kwargs = kwargs
  309. return QueryBatch(id=self.batch_id, **kwargs)
  310. def add_query(self, **kwargs):
  311. query = Query(id=uuid4(), **kwargs)
  312. self.queries.append(query)
  313. return query
  314. def create_acquisition_run(self, **kwargs):
  315. run = AcquisitionRun(id=self.run_id, **kwargs)
  316. self.runs.append(run)
  317. return run
  318. def update_acquisition_run(self, run_id, **kwargs):
  319. assert run_id == self.run_id
  320. self.updates.append(kwargs)
  321. base = self.runs[-1].model_dump()
  322. base.update(kwargs)
  323. return AcquisitionRun(**base)
  324. def _client(repo: FakeAcquisitionRepo):
  325. app.dependency_overrides[get_acquisition_repository] = lambda: repo
  326. return TestClient(app)
  327. def test_manual_query_batch_api_creates_ready_batch_and_starts_pipeline(monkeypatch, tmp_path):
  328. repo = FakeManualRepo()
  329. popen_calls = []
  330. class FakeProcess:
  331. pid = 12345
  332. def fake_popen(cmd, **kwargs):
  333. popen_calls.append((cmd, kwargs))
  334. return FakeProcess()
  335. monkeypatch.setattr(manual_queries, "transaction", lambda _config: nullcontext(object()))
  336. monkeypatch.setattr(manual_queries, "PostgresAcquisitionRepository", lambda _conn: repo)
  337. monkeypatch.setattr(manual_queries, "RUNTIME_MANUAL_DIR", tmp_path)
  338. monkeypatch.setattr(manual_queries.subprocess, "Popen", fake_popen)
  339. app.dependency_overrides[get_creation_db_config] = lambda: object()
  340. client = TestClient(app)
  341. try:
  342. response = client.post(
  343. "/api/query-batches/manual",
  344. json={
  345. "queries": [
  346. "符号 视频 灵感 怎么做",
  347. "符号 视频 灵感 怎么做",
  348. {"query_text": "叙事体裁 视频 灵感 有哪些", "axes": {"实质": "叙事体裁"}},
  349. ]
  350. },
  351. )
  352. assert response.status_code == 200
  353. data = response.json()
  354. assert data["status"] == "queued"
  355. assert data["batch_id"] == str(repo.batch_id)
  356. assert data["run_id"] == str(repo.run_id)
  357. assert data["pid"] == 12345
  358. assert data["query_count"] == 2
  359. assert data["summary_url"] == f"/api/acquisition/runs/{repo.run_id}/summary"
  360. assert repo.batch_kwargs["generation_method"] == "manual_query_api_v1"
  361. assert repo.batch_kwargs["target_platforms"] == ["xiaohongshu", "weixin", "douyin"]
  362. assert [query.query_text for query in repo.queries] == [
  363. "符号 视频 灵感 怎么做",
  364. "叙事体裁 视频 灵感 有哪些",
  365. ]
  366. assert all(query.keep is True and query.status == "ready" for query in repo.queries)
  367. assert all(query.metadata["family_key"] == "manual" for query in repo.queries)
  368. assert repo.runs[0].status == "pending"
  369. assert repo.runs[0].metadata["log_path"].endswith(".log")
  370. assert repo.runs[0].metadata["command"]
  371. assert popen_calls
  372. cmd, kwargs = popen_calls[0]
  373. assert "scripts/run_creation_pipeline.py" in cmd[1]
  374. assert ["--platform", "xiaohongshu"] == cmd[-6:-4]
  375. assert "--no-dry-ingest-record" not in cmd
  376. assert kwargs["cwd"] == str(manual_queries.ROOT)
  377. assert str(manual_queries.ROOT) in kwargs["env"]["PYTHONPATH"]
  378. assert repo.updates == []
  379. finally:
  380. app.dependency_overrides.clear()
  381. def test_manual_query_batch_api_extracts_family_json(monkeypatch, tmp_path):
  382. repo = FakeManualRepo()
  383. monkeypatch.setattr(manual_queries, "transaction", lambda _config: nullcontext(object()))
  384. monkeypatch.setattr(manual_queries, "PostgresAcquisitionRepository", lambda _conn: repo)
  385. monkeypatch.setattr(manual_queries, "RUNTIME_MANUAL_DIR", tmp_path)
  386. monkeypatch.setattr(manual_queries.subprocess, "Popen", lambda *args, **kwargs: type("P", (), {"pid": 1})())
  387. app.dependency_overrides[get_creation_db_config] = lambda: object()
  388. client = TestClient(app)
  389. try:
  390. response = client.post(
  391. "/api/query-batches/manual",
  392. json={
  393. "families": [
  394. {
  395. "key": "f1",
  396. "name": "实质正交",
  397. "items": [{"query": "公共安全 视频 灵感 怎么做"}],
  398. }
  399. ]
  400. },
  401. )
  402. assert response.status_code == 200
  403. assert repo.queries[0].query_text == "公共安全 视频 灵感 怎么做"
  404. assert repo.queries[0].metadata["family_key"] == "manual"
  405. assert repo.queries[0].metadata["source_family_key"] == "f1"
  406. finally:
  407. app.dependency_overrides.clear()
  408. def test_manual_query_batch_api_rejects_empty_and_invalid_platform():
  409. client = TestClient(app)
  410. assert client.post("/api/query-batches/manual", json={"queries": [" "]}).status_code == 422
  411. assert client.post(
  412. "/api/query-batches/manual",
  413. json={"queries": ["符号 视频 灵感 怎么做"], "target_platforms": ["bilibili"]},
  414. ).status_code == 422
  415. def test_app_health_and_formal_acquisition_routes():
  416. repo = FakeAcquisitionRepo()
  417. client = _client(repo)
  418. try:
  419. assert client.get("/health").json()["entrypoint"] == "app.api:app"
  420. batch = client.get(f"/api/query-batches/{repo.batch_id}").json()
  421. assert batch["batch"]["name"] == "正式 query 批次"
  422. assert batch["queries"][0]["id"] == str(repo.query_id)
  423. summary = client.get(f"/api/acquisition/runs/{repo.run_id}/summary").json()
  424. assert summary["creation_hit_count"] == 2
  425. assert summary["queries"][0]["query_id"] == str(repo.query_id)
  426. detail = client.get(f"/api/acquisition/runs/{repo.run_id}/queries/{repo.query_id}").json()
  427. item = detail["platforms"]["xiaohongshu"]["items"][0]
  428. assert item["content_mode"] == "image_post"
  429. assert item["body_text"] == "先定受众,再写开头钩子"
  430. assert item["media_assets"][0]["cdn_url"] == "https://cdn.test/1.jpg"
  431. assert item["classification"]["is_creation_knowledge"] is True
  432. latest = client.get(f"/api/query-generation/latest/queries/{repo.query_id}").json()
  433. lightweight_item = latest["items"][0]
  434. assert "body_text" not in lightweight_item
  435. assert "source_payload" not in lightweight_item
  436. assert "matched_candidate" not in lightweight_item["metadata"]
  437. assert "source_payload" not in lightweight_item["metadata"]
  438. assert lightweight_item["raw_summary"] == "先定受众"
  439. assert len(lightweight_item["media_assets"]) == 1
  440. assert lightweight_item["decode_summary"]["particle_count"] == 1
  441. assert latest["platforms"]["xiaohongshu"]["item_ids"] == [str(repo.item_id)]
  442. assert "items" not in latest["platforms"]["xiaohongshu"]
  443. finally:
  444. app.dependency_overrides.clear()
  445. def test_app_compresses_large_json_responses():
  446. repo = FakeAcquisitionRepo()
  447. client = _client(repo)
  448. try:
  449. response = client.get(
  450. f"/api/query-generation/latest/queries/{repo.query_id}",
  451. headers={"Accept-Encoding": "gzip"},
  452. )
  453. assert response.status_code == 200
  454. assert response.headers.get("content-encoding") == "gzip"
  455. finally:
  456. app.dependency_overrides.clear()
  457. def test_query_generation_preview_defaults_to_first_two_families():
  458. client = TestClient(app)
  459. data = client.get("/api/query-generation/preview?per=2").json()
  460. assert data["summary"]["family_keys"] == ["f1", "f2"]
  461. assert [family["key"] for family in data["families"]] == ["f1", "f2"]
  462. assert data["summary"]["query_count"] == 4
  463. assert data["metadata"]["active_family_keys"] == ["f1", "f2"]
  464. def test_query_generation_preview_can_return_full_cartesian_combinations():
  465. client = TestClient(app)
  466. data = client.get("/api/query-generation/preview?per=0&batch_n=1").json()
  467. assert data["summary"]["family_keys"] == ["f1", "f2"]
  468. assert data["summary"]["query_count"] == 36
  469. assert [len(family["items"]) for family in data["families"]] == [18, 18]
  470. def test_formal_app_does_not_expose_legacy_static_mounts():
  471. paths = {route.path for route in app.routes if hasattr(route, "path")}
  472. assert "/data" not in paths
  473. assert "/frames" not in paths
  474. assert "/api/creation-search/summary" not in paths
  475. assert "/api/creation-search/query" not in paths
  476. def test_pipeline_route_returns_501_instead_of_legacy_data_when_not_wired():
  477. client = TestClient(app)
  478. run_id = uuid4()
  479. assert client.get(f"/api/pipeline/runs/{run_id}").status_code == 501
  480. def test_formal_decode_payload_pipeline_routes_have_override_success_paths():
  481. acquisition_repo = FakeAcquisitionRepo()
  482. decode_repo = FakeDecodeRepo()
  483. pipeline_repo = FakePipelineRepo()
  484. item_id = acquisition_repo.item_id
  485. run_id = uuid4()
  486. app.dependency_overrides[get_acquisition_repository] = lambda: acquisition_repo
  487. app.dependency_overrides[get_decode_repository] = lambda: decode_repo
  488. app.dependency_overrides[get_pipeline_repository] = lambda: pipeline_repo
  489. client = TestClient(app)
  490. try:
  491. result = client.get(f"/api/decode/items/{item_id}/result").json()
  492. assert result["item_id"] == str(item_id)
  493. assert result["read_result"]["text"] == "读懂后的帖子内容"
  494. job = client.post(f"/api/decode/items/{item_id}/jobs").json()["job"]
  495. assert job["item_id"] == str(item_id)
  496. assert job["status"] == "pending"
  497. drafts = client.get(f"/api/payloads/drafts?item_id={item_id}").json()["items"]
  498. assert drafts[0]["item_id"] == str(item_id)
  499. assert drafts[0]["payload"]["title"] == "可审核 payload"
  500. ingest = client.post(f"/api/decode/items/{item_id}/ingest").json()
  501. assert ingest["dry_run"] is True
  502. assert ingest["total"] == 1
  503. assert ingest["ingested_count"] == 1
  504. assert ingest["failed_count"] == 0
  505. assert decode_repo.marked_payload_ids == [decode_repo.payload_id]
  506. assert decode_repo.saved_ingest_records[0].target_system == "dry-run"
  507. detail = client.get(f"/api/decode/items/{item_id}/detail").json()
  508. assert detail["item"]["id"] == str(item_id)
  509. assert detail["knowledge_particles"][0]["title"] == "What I know"
  510. assert detail["ingest_records"][0]["status"] == "ingested"
  511. run = client.get(f"/api/pipeline/runs/{run_id}").json()["run"]
  512. assert run["id"] == str(run_id)
  513. assert run["current_stage"] == "decode"
  514. finally:
  515. app.dependency_overrides.clear()
  516. def test_item_ingest_real_mode_requires_configured_url(monkeypatch):
  517. acquisition_repo = FakeAcquisitionRepo()
  518. decode_repo = FakeDecodeRepo()
  519. item_id = acquisition_repo.item_id
  520. app.dependency_overrides[get_decode_repository] = lambda: decode_repo
  521. monkeypatch.setattr(decode_routes.IngestApiConfig, "from_env", lambda _env_file: decode_routes.IngestApiConfig())
  522. client = TestClient(app)
  523. try:
  524. response = client.post(f"/api/decode/items/{item_id}/ingest", json={"dry_run": False})
  525. assert response.status_code == 400
  526. assert "CK_INGEST_API_URL" in response.json()["detail"]
  527. assert decode_repo.saved_ingest_records == []
  528. finally:
  529. app.dependency_overrides.clear()
  530. def test_no_legacy_api_dependencies_in_formal_app_sources():
  531. roots = [Path("app"), Path("pipeline")]
  532. text = "\n".join(
  533. path.read_text(encoding="utf-8")
  534. for root in roots
  535. for path in root.rglob("*")
  536. if path.is_file() and path.suffix in {".py", ".jsx", ".js"}
  537. )
  538. assert "acquisition.store" not in text
  539. assert "CK_SQLITE_PATH" not in text
  540. assert "/data/queries" not in text
  541. assert "/api/creation-search" not in text
  542. assert "creation_knowledge.api" not in text
  543. def test_legacy_top_level_package_is_archived():
  544. assert not Path("creation_knowledge").exists()
  545. assert Path("archive/2026-06-30-step6/legacy_creation_knowledge/creation_knowledge").exists()
  546. def test_active_sources_do_not_import_legacy_store_or_package():
  547. roots = [Path("app"), Path("pipeline"), Path("acquisition"), Path("decode_content"), Path("scripts")]
  548. text = "\n".join(
  549. path.read_text(encoding="utf-8")
  550. for root in roots
  551. for path in root.rglob("*")
  552. if path.is_file() and path.suffix in {".py", ".jsx", ".js"}
  553. )
  554. assert "from acquisition import store" not in text
  555. assert "import acquisition.store" not in text
  556. assert "from creation_knowledge" not in text
  557. assert "import creation_knowledge" not in text