refactor: unify data preparations and research input snapshots
Deploy production / deploy (push) Successful in 53s
Deploy production / deploy (push) Successful in 53s
This commit is contained in:
@@ -86,16 +86,24 @@ async def search(client, suffix="/datasets", **params):
|
||||
|
||||
|
||||
async def prepare(client, version, **changes):
|
||||
return await client.post(
|
||||
BASE + "/inputs",
|
||||
json={
|
||||
"scope": SCOPE,
|
||||
"dataset_id": "TEST_FIN",
|
||||
"collection_version": version,
|
||||
"selection": "all",
|
||||
**changes,
|
||||
},
|
||||
)
|
||||
response = await client.post("/api/v1/data-preparations/from-dataset", json={
|
||||
"scope": changes.get("scope", SCOPE), "dataset_id": changes.get("dataset_id", "TEST_FIN"),
|
||||
"collection_version": version,
|
||||
})
|
||||
if response.status_code != 201:
|
||||
return response
|
||||
collection = response.json()
|
||||
if changes.get("excluded_ids"):
|
||||
response = await client.patch(f"/api/v1/data-preparations/{collection['id']}/fields", json={
|
||||
"version": collection["version"], "remove_ids": changes["excluded_ids"]})
|
||||
if response.status_code != 200:
|
||||
return response
|
||||
collection = response.json()
|
||||
response = await client.post("/api/v1/data-preparations/freeze", json={
|
||||
"items": [{"id": collection["id"], "version": collection["version"]}]})
|
||||
if response.status_code != 201:
|
||||
return response
|
||||
return httpx.Response(201, json=response.json()["items"][0])
|
||||
|
||||
|
||||
async def test_complete_workflow_filters_notes_immutable_input(catalog):
|
||||
@@ -112,7 +120,7 @@ async def test_complete_workflow_filters_notes_immutable_input(catalog):
|
||||
response = await prepare(client, version)
|
||||
assert response.status_code == 201, response.text
|
||||
draft = response.json()
|
||||
assert len(draft["field_ids"]) == 123 and draft["status"] == "draft"
|
||||
assert len(draft["field_ids"]) == 123 and draft["preparation_version"] == 1
|
||||
for suffix in ["/datasets/TEST_FIN", "/datasets/TEST_FIN/fields/TEST_FIN_122"]:
|
||||
detail = await search(client, suffix)
|
||||
assert detail["research"]["version"] == 1
|
||||
@@ -135,7 +143,7 @@ async def test_complete_workflow_filters_notes_immutable_input(catalog):
|
||||
assert newer["collection_version"] != version
|
||||
assert (await prepare(client, version)).status_code == 409
|
||||
assert len((await prepare(client, newer["collection_version"])).json()["field_ids"]) == 125
|
||||
assert (await client.get(BASE + "/inputs/" + draft["id"])).json() == draft
|
||||
assert (await client.get("/api/v1/research/input-snapshots/" + draft["id"])).json() == draft
|
||||
assert (await search(client, "/datasets/TEST_FIN/fields/TEST_FIN_122"))["research"][
|
||||
"note"
|
||||
] == "保留研究备注"
|
||||
@@ -219,7 +227,7 @@ async def test_scope_ownership_empty_and_unknown_fields_are_rejected(catalog):
|
||||
await sync(catalog, scope=other)
|
||||
await sync(catalog, "TEST_FIN", scope=other)
|
||||
assert (await prepare(client, version, scope=other)).status_code == 409
|
||||
assert len((await client.get(BASE + "/inputs", params=SCOPE)).json()) == 1
|
||||
assert (await client.get(BASE + "/inputs", params=SCOPE)).status_code == 404
|
||||
|
||||
|
||||
async def test_catalog_authentication_and_origin(app, client):
|
||||
|
||||
Reference in New Issue
Block a user