From: John Mulligan Date: Sat, 9 Apr 2022 18:47:01 +0000 (-0400) Subject: pybind/mgr: add a test case for the ReturnValueAdapter X-Git-Tag: v18.0.0~841^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29d8be428c7aa0125ab5c6636cd4b8712e60f71b;p=ceph.git pybind/mgr: add a test case for the ReturnValueAdapter Signed-off-by: John Mulligan --- diff --git a/src/pybind/mgr/tests/test_object_format.py b/src/pybind/mgr/tests/test_object_format.py index 1d551d4f786..5a1a4b5a227 100644 --- a/src/pybind/mgr/tests/test_object_format.py +++ b/src/pybind/mgr/tests/test_object_format.py @@ -103,3 +103,28 @@ def test_format_yaml(obj: Any, compatible: bool, yaml_val: str): ).format_yaml() == yaml_val ) + + +class Retty: + def __init__(self, v) -> None: + self.value = v + + def mgr_return_value(self) -> int: + return self.value + + +@pytest.mark.parametrize( + "obj, ret", + [ + ({}, 0), + ({"fish": "sticks"}, 0), + (-55, 0), + (Retty(0), 0), + (Retty(-55), -55), + ], +) +def test_return_value(obj: Any, ret: int): + rva = object_format.ReturnValueAdapter(obj) + # a ReturnValueAdapter instance meets the ReturnValueProvider protocol. + assert object_format._is_return_value_provider(rva) + assert rva.mgr_return_value() == ret