def test_files_datasets_for_service_with_relations(admin_client, file_tree_with_datasets):
tree = file_tree_with_datasets
res = admin_client.post(
"/v3/files/datasets?storage_service=ida&relations=true",
[
tree["files"]["/dir/a.txt"].storage_identifier, # dataset a
tree["files"]["/dir/b.txt"].storage_identifier, # dataset b
tree["files"]["/dir/c.txt"].storage_identifier, # dataset a,b,c
tree["files"]["/dir/d.txt"].storage_identifier, # no dataset
],
content_type="application/json",
)
assert res.status_code == 200
res.json()[str(tree["files"]["/dir/c.txt"].storage_identifier)].sort()
expected_result = {
tree["files"]["/dir/a.txt"].storage_identifier: [str(tree["dataset_a"].id)],
tree["files"]["/dir/b.txt"].storage_identifier: [str(tree["dataset_b"].id)],
tree["files"]["/dir/c.txt"].storage_identifier: [
str(tree["dataset_a"].id),
str(tree["dataset_b"].id),
str(tree["dataset_c"].id),
],
}
expected_result[tree["files"]["/dir/c.txt"].storage_identifier].sort()
assert res.json() == expected_result