def test_directory_pagination(admin_client, file_tree_a):
res = admin_client.get(
"/v3/directories",
{
"path": "/dir",
"limit": 5,
**file_tree_a["params"],
},
)
assert res.status_code == 200
assert "offset=5" in res.data["next"]
assert_nested_subdict(
{
"count": 12,
"previous": None,
"results": {
"directory": {"file_count": 15, "size": 15 * 1024},
"directories": [
{"name": "sub1"},
{"name": "sub2"},
{"name": "sub3"},
{"name": "sub4"},
{"name": "sub5"},
],
"files": [],
},
},
res.data,
check_list_length=True,
)
res = admin_client.get(res.data["next"])
assert res.status_code == 200
assert "offset" not in res.data["previous"]
assert "offset=10" in res.data["next"]
assert_nested_subdict(
{
"count": 12,
"results": {
"directory": {"file_count": 15, "size": 15 * 1024},
"directories": [
{"name": "sub6"},
],
"files": [
{"filename": "a.txt"},
{"filename": "b.txt"},
{"filename": "c.txt"},
{"filename": "d.txt"},
],
},
},
res.data,
check_list_length=True,
)
res = admin_client.get(res.data["next"])
assert res.status_code == 200
assert "offset=5" in res.data["previous"]
assert_nested_subdict(
{
"count": 12,
"next": None,
"results": {
"directory": {"file_count": 15, "size": 15 * 1024},
"directories": [],
"files": [
{"filename": "e.txt"},
{"filename": "f.txt"},
],
},
},
res.data,
check_list_length=True,
)