Erick's site as one table, ResultadoSubrogado
This commit is contained in:
+10
-8
@@ -36,20 +36,22 @@ def test_an_operator_connects_a_site_and_settles_its_review(api, platform, site,
|
||||
|
||||
# What the site has, and what one of its tables holds (documents shown by size).
|
||||
found = ok(api.post("/ingest/sources/resources", json={"source": SQL, "args": database}))
|
||||
assert found == ["ArchivosUni", "ResultadosSubrogados"]
|
||||
assert found == ["ResultadoSubrogado"]
|
||||
missing = {"credentials": "mssql+pymssql://sa:x@nowhere.invalid:1433/Pruebas"}
|
||||
unreachable = api.post("/ingest/sources/resources", json={"source": SQL, "args": missing})
|
||||
assert unreachable.status_code == 422, unreachable.text
|
||||
reports = {"id": "reports", "kind": "source", "source": SQL, "args": database}
|
||||
sample = ok(
|
||||
api.post("/ingest/sources/preview?limit=3", json=reports | {"resource": "ArchivosUni"})
|
||||
api.post(
|
||||
"/ingest/sources/preview?limit=3", json=reports | {"resource": "ResultadoSubrogado"}
|
||||
)
|
||||
)
|
||||
assert len(sample) == 3 and all(r["Archivo"].endswith(" bytes>") for r in sample)
|
||||
|
||||
# A file someone uploads (a report sent by mail) becomes a source like any other.
|
||||
engine = create_engine(site.url)
|
||||
with engine.connect() as con:
|
||||
pdf = con.execute(text("select Archivo from dbo.ArchivosUni where Id = 1")).scalar()
|
||||
pdf = con.execute(text("select Archivo from dbo.ResultadoSubrogado where Id = 1")).scalar()
|
||||
engine.dispose()
|
||||
uploaded = ok(api.post("/ingest/uploads", files={"file": ("informe.pdf", pdf)}))
|
||||
mailed = {
|
||||
@@ -96,12 +98,12 @@ def test_an_operator_connects_a_site_and_settles_its_review(api, platform, site,
|
||||
# Run it, and look at what any node produced.
|
||||
run(api, "site")
|
||||
record_of = {}
|
||||
for table, node in (("ArchivosUni", "archivos"), ("ResultadosSubrogados", "subrogados")):
|
||||
rows = ok(api.get(f"/ingest/pipelines/site/nodes/{node}/rows?limit=500"))
|
||||
record_of |= {f"{table}:{r['id']}": r["_record"] for r in rows}
|
||||
assert ok(api.get("/ingest/pipelines/site/nodes/resultados/rows?limit=3"))
|
||||
held_by = platform.query("select id, _record from bronze.n__site__resultados")
|
||||
record_of |= {f"ResultadoSubrogado:{i}": r for i, r in held_by}
|
||||
assert len(record_of) == len(truth)
|
||||
forms = sum(1 for r in truth if r["where"].startswith("ArchivosUni:")
|
||||
and r["entity"] == "cervical_cytology") # fmt: skip
|
||||
forms = sum(1 for r in truth
|
||||
if r["entity"] == "cervical_cytology" and "document" not in r) # fmt: skip
|
||||
assert len(ok(api.get("/ingest/pipelines/site/nodes/cytology/rows?limit=500"))) == forms
|
||||
|
||||
# Review: reports that contradict each other, rows held because their person is torn
|
||||
|
||||
Reference in New Issue
Block a user