HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //snap/lxd/current/lib/python3/dist-packages/ceph/tests/test_inventory.py
import json
import os
import pytest

from ceph.deployment.inventory import Devices


@pytest.mark.parametrize("filename",
                         [
                             os.path.dirname(__file__) + '/c-v-inventory.json',
                             os.path.dirname(__file__) + '/../../../pybind/mgr/test_orchestrator/du'
                                                         'mmy_data.json',
                         ])
def test_from_json(filename):
    with open(filename) as f:
        data = json.load(f)
    if 'inventory' in data:
        data = data['inventory']
    ds = Devices.from_json(data)
    assert len(ds.devices) == len(data)
    assert Devices.from_json(ds.to_json()) == ds