From 6c9aa762325802fa1a85df55cf351150cad3707e Mon Sep 17 00:00:00 2001 From: Logan Cary Date: Fri, 13 Dec 2024 15:14:26 -0500 Subject: [PATCH] add test --- tests/api2/test_pool_dataset_create.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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