summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/tests/test_object_format.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-23 16:45:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-23 16:45:44 +0000
commit17d6a993fc17d533460c5f40f3908c708e057c18 (patch)
tree1a3bd93e0ecd74fa02f93a528fe2f87e5314c4b5 /src/pybind/mgr/tests/test_object_format.py
parentReleasing progress-linux version 18.2.2-0progress7.99u1. (diff)
downloadceph-17d6a993fc17d533460c5f40f3908c708e057c18.tar.xz
ceph-17d6a993fc17d533460c5f40f3908c708e057c18.zip
Merging upstream version 18.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/pybind/mgr/tests/test_object_format.py')
-rw-r--r--src/pybind/mgr/tests/test_object_format.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/pybind/mgr/tests/test_object_format.py b/src/pybind/mgr/tests/test_object_format.py
index d2fd20870..2e674c698 100644
--- a/src/pybind/mgr/tests/test_object_format.py
+++ b/src/pybind/mgr/tests/test_object_format.py
@@ -115,12 +115,18 @@ def test_format_yaml(obj: Any, compatible: bool, yaml_val: str):
class Retty:
- def __init__(self, v) -> None:
+ def __init__(self, v, status="") -> None:
self.value = v
+ self.status = status
def mgr_return_value(self) -> int:
return self.value
+ def mgr_status_value(self) -> str:
+ if self.status:
+ return self.status
+ return "NOPE"
+
@pytest.mark.parametrize(
"obj, ret",
@@ -139,6 +145,24 @@ def test_return_value(obj: Any, ret: int):
assert rva.mgr_return_value() == ret
+@pytest.mark.parametrize(
+ "obj, ret",
+ [
+ ({}, ""),
+ ({"fish": "sticks"}, ""),
+ (-55, ""),
+ (Retty(0), "NOPE"),
+ (Retty(-55, "cake"), "cake"),
+ (Retty(-50, "pie"), "pie"),
+ ],
+)
+def test_return_status(obj: Any, ret: str):
+ rva = object_format.StatusValueAdapter(obj)
+ # a StatusValueAdapter instance meets the StatusValueProvider protocol.
+ assert object_format._is_status_value_provider(rva)
+ assert rva.mgr_status_value() == ret
+
+
def test_valid_formats():
ofa = object_format.ObjectFormatAdapter({"fred": "wilma"})
vf = ofa.valid_formats()