diff --git a/tests/api2/test_pool_dataset_create.py b/tests/api2/test_pool_dataset_create.py index c7a729d12bb38..f7b741e75c371 100644 --- a/tests/api2/test_pool_dataset_create.py +++ b/tests/api2/test_pool_dataset_create.py @@ -1,3 +1,5 @@ +from itertools import product + import pytest from middlewared.test.integration.assets.pool import dataset @@ -10,3 +12,22 @@ def test_pool_dataset_create_ancestors(child): name = f"{test_ds}/{child}" call("pool.dataset.create", {"name": name, "create_ancestors": True}) call("pool.dataset.get_instance", name) + + +def test_pool_dataset_query(): + fields = ("id", "name") + ops = ("=", "in") + flats = (True, False) + + with dataset("query_test") as ds: + # Try all combinations + results = (call( + "pool.dataset.query", + [[field, op, ds if op == "=" else [ds]]], + {"extra": {"flat": flat, "properties": []}} + ) for field, op, flat in product(fields, ops, flats)) + + # Check all the returns are the same + first = next(results) + for next_ds in results: + assert next_ds == first