Fix selection bug to require that arguments be consumed by a branch
This commit is contained in:
parent
c31467fb04
commit
06c84fb20e
@ -261,6 +261,7 @@ class Qube:
|
|||||||
selection: dict[str, str | list[str]],
|
selection: dict[str, str | list[str]],
|
||||||
mode: Literal["strict", "relaxed"] = "relaxed",
|
mode: Literal["strict", "relaxed"] = "relaxed",
|
||||||
prune=True,
|
prune=True,
|
||||||
|
consume=True,
|
||||||
) -> "Qube":
|
) -> "Qube":
|
||||||
# make all values lists
|
# make all values lists
|
||||||
selection = {k: v if isinstance(v, list) else [v] for k, v in selection.items()}
|
selection = {k: v if isinstance(v, list) else [v] for k, v in selection.items()}
|
||||||
|
27
tests/test_selection.py
Normal file
27
tests/test_selection.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
from qubed import Qube
|
||||||
|
|
||||||
|
q = Qube.from_dict(
|
||||||
|
{
|
||||||
|
"class=od": {
|
||||||
|
"expver=0001": {"param=1": {}, "param=2": {}},
|
||||||
|
"expver=0002": {"param=1": {}, "param=2": {}},
|
||||||
|
},
|
||||||
|
"class=rd": {"param=1": {}, "param=2": {}, "param=3": {}},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_consumption():
|
||||||
|
assert q.select({"expver": "0001"}) == Qube.from_dict(
|
||||||
|
{"class=od": {"expver=0001": {"param=1": {}, "param=2": {}}}}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_consumption_off():
|
||||||
|
expected = Qube.from_dict(
|
||||||
|
{
|
||||||
|
"class=od": {"expver=0001": {"param=1": {}, "param=2": {}}},
|
||||||
|
"class=rd": {"param=1": {}, "param=2": {}, "param=3": {}},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
assert q.select({"expver": "0001"}, consume=False) == expected
|
Loading…
x
Reference in New Issue
Block a user