def test_directory_field_values(admin_client, file_tree_b):
dataset = factories.PublishedDatasetFactory()
factories.FileSetFactory(
dataset=dataset,
storage=file_tree_b["storage"],
files=file_tree_b["files"].values(),
)
res = admin_client.get(
"/v3/directories",
{
"include_nulls": True,
"pagination": False,
**file_tree_b["params"],
},
)
assert res.status_code == 200
assert_nested_subdict(
{
"directory": {
"storage_service": "ida",
"csc_project": "project_x",
"name": "",
"pathname": "/",
"file_count": 3,
"size": 3210,
"created": file_tree_b["files"]["/rootfile.txt"].modified,
"modified": file_tree_b["files"]["/dir/last"].modified,
"parent_url": None,
},
"directories": [
{
"storage_service": "ida",
"csc_project": "project_x",
"name": "dir",
"pathname": "/dir/",
"file_count": 2,
"size": 3200,
"created": file_tree_b["files"]["/dir/first"].modified,
"modified": file_tree_b["files"]["/dir/last"].modified,
"url": (
"http://testserver/v3/directories"
"?include_nulls=True&pagination=False&csc_project=project_x&storage_service=ida&path=/dir/"
),
}
],
"files": [
{
"id": "00000000-0000-0000-0000-000000000000",
"pathname": "/rootfile.txt",
"filename": "rootfile.txt",
"size": 10,
"csc_project": "project_x",
"storage_service": "ida",
"storage_identifier": "file_rootfile.txt_00000000-0000-0000-0000-000000000000",
"checksum": "md5:f00f",
"modified": file_tree_b["files"]["/rootfile.txt"].modified,
"frozen": file_tree_b["files"]["/rootfile.txt"].frozen,
"removed": None,
"user": None,
"published": matchers.DateTimeStr(),
"characteristics": None,
"characteristics_extension": None,
}
],
},
res.data,
check_all_keys_equal=True,
)