summaryrefslogtreecommitdiffstats
path: root/rtemsqual/tests/test_items_item.py
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-04-30 07:14:44 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-05-28 10:34:46 +0200
commit22ec40f5ec8ba636f9dc5442c7025d3ffb0aba68 (patch)
treef5bb598f6a4d66ce993cf2b43a8dc0128b446f48 /rtemsqual/tests/test_items_item.py
parenttests: Fix issues found by flake8 (diff)
downloadrtems-central-22ec40f5ec8ba636f9dc5442c7025d3ffb0aba68.tar.bz2
items: Add ItemMapper and ItemTemplate classes
Diffstat (limited to 'rtemsqual/tests/test_items_item.py')
-rw-r--r--rtemsqual/tests/test_items_item.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/rtemsqual/tests/test_items_item.py b/rtemsqual/tests/test_items_item.py
index 44efae80..3c26d5b8 100644
--- a/rtemsqual/tests/test_items_item.py
+++ b/rtemsqual/tests/test_items_item.py
@@ -37,6 +37,7 @@ class EmptyCache(ItemCache):
def test_to_abs_uid():
item = Item(EmptyCache(), "/x/y", {})
+ assert item.to_abs_uid(".") == "/x/y"
assert item.to_abs_uid("z") == "/x/z"
assert item.to_abs_uid("/z") == "/z"
assert item.to_abs_uid("../z") == "/z"
@@ -56,6 +57,24 @@ def test_contains():
assert "a" not in item
+def test_get():
+ data = {}
+ data["a"] = {"b": "c", "d": [1, 2, 3]}
+ data["x"] = "y"
+ item = Item(EmptyCache(), "z", data)
+ assert item.get("x") == "y"
+ assert item.get("a/d[2]") == 3
+ assert item.get("a/b/../d[0]") == 1
+ assert item.get("/a/b/../d[0]") == 1
+ assert item.get("../d[0]", "a/b") == 1
+ with pytest.raises(KeyError):
+ assert item.get("y")
+ with pytest.raises(KeyError):
+ assert item.get("[")
+ with pytest.raises(ValueError):
+ assert item.get("x[y]")
+
+
def test_getitem():
data = {}
data["x"] = "y"