test: lwm2m: Implement Read-Composite Operation on root path

Test case:
LightweightM2M-1.1-int-235 - Read-Composite Operation on root path
is now working as Leshan added a support for reading the root path.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit is contained in:
Seppo Takalo 2023-11-13 16:36:03 +02:00 committed by Carles Cufí
commit 2135e009e4
3 changed files with 10 additions and 3 deletions

View file

@ -160,7 +160,7 @@ Tests are written from test spec;
|LightweightM2M-1.1-int-232 - Querying basic information in SenML CBOR format|:white_check_mark:| |
|LightweightM2M-1.1-int-233 - Setting basic information in SenML CBOR format|:white_check_mark:| |
|LightweightM2M-1.1-int-234 - Setting basic information in SenML JSON format|:white_check_mark:| |
|LightweightM2M-1.1-int-235 - Read-Composite Operation on root path|:large_orange_diamond:|Root Path is not yet supported by Leshan.|
|LightweightM2M-1.1-int-235 - Read-Composite Operation on root path|:white_check_mark:| |
|LightweightM2M-1.1-int-236 - Read-Composite - Partial Presence|:white_check_mark:| |
|LightweightM2M-1.1-int-237 - Read on Object without specifying Content-Type|:white_check_mark:| |
|LightweightM2M-1.1-int-241 - Executable Resource: Rebooting the device|:white_check_mark:| |

View file

@ -271,6 +271,10 @@ class Leshan:
raise RuntimeError(f'No content received')
payload = payload['content']
for path, content in payload.items():
if path == "/":
for obj in content['objects']:
data.update(cls._decode_obj(obj))
continue
keys = [int(key) for key in path.lstrip("/").split('/')]
if len(keys) == 1:
data.update(cls._decode_obj(content))

View file

@ -367,9 +367,12 @@ def test_LightweightM2M_1_1_int_234(shell: Shell, leshan: Leshan, endpoint: str)
"""LightweightM2M-1.1-int-234 - Setting basic information in SenML JSON format"""
setting_basic_senml(shell, leshan, endpoint, 'SENML_JSON')
@pytest.mark.skip("Leshan does not allow reading root path")
def test_LightweightM2M_1_1_int_235():
def test_LightweightM2M_1_1_int_235(leshan: Leshan, endpoint: str):
"""LightweightM2M-1.1-int-235 - Read-Composite Operation on root path"""
resp = leshan.composite_read(endpoint, ['/'])
expected_keys = [16, 1, 3, 5]
missing_keys = [key for key in expected_keys if key not in resp.keys()]
assert len(missing_keys) == 0
def test_LightweightM2M_1_1_int_236(shell: Shell, leshan: Leshan, endpoint: str):
"""LightweightM2M-1.1-int-236 - Read-Composite - Partial Presence"""