mirror of
https://github.com/Telecominfraproject/oopt-gnpy.git
synced 2025-11-01 10:38:10 +00:00
fix: use loaded json instead of Path for extra configs
In order to be used by API. Co-authored-by: Renato Ambrosone <renato.ambrosone@polito.it> Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com> Change-Id: I12111427c8a90b85b3158cdd95f4ee771cb39316
This commit is contained in:
56
tests/test_json_io.py
Normal file
56
tests/test_json_io.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# test_gain_mode
|
||||
# Copyright (C) 2025 Telecom Infra Project and GNPy contributors
|
||||
# see AUTHORS.rst for a list of contributors
|
||||
|
||||
"""
|
||||
checks behaviour of gain mode
|
||||
- if all amps have their gains set, check that these gains are used, even if power_dbm or req_power change
|
||||
- check that saturation is correct in gain mode
|
||||
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from gnpy.tools.json_io import load_json, load_eqpt_topo_from_json
|
||||
import networkx as nx
|
||||
|
||||
|
||||
TEST_DIR = Path(__file__).parent
|
||||
DATA_DIR = TEST_DIR / 'data'
|
||||
EQPT_FILENAME = DATA_DIR / 'eqpt_config.json'
|
||||
NETWORK_FILENAME = DATA_DIR / 'LinkforTest.json'
|
||||
EXTRA_CONFIGS = {"std_medium_gain_advanced_config.json": load_json(DATA_DIR / "std_medium_gain_advanced_config.json")}
|
||||
|
||||
|
||||
def test_load_eqpt_topo_from_json():
|
||||
eqpt = load_json(EQPT_FILENAME)
|
||||
topology = load_json(NETWORK_FILENAME)
|
||||
extra_equipments = None
|
||||
extra_configs = EXTRA_CONFIGS
|
||||
|
||||
equipment, network = load_eqpt_topo_from_json(eqpt, topology, extra_equipments, extra_configs)
|
||||
|
||||
assert isinstance(equipment, dict)
|
||||
assert isinstance(network, nx.DiGraph)
|
||||
|
||||
assert len(network.nodes) > 0
|
||||
assert len(network.edges) > 0
|
||||
|
||||
|
||||
def test_load_eqpt_topo_from_json_default_extra():
|
||||
eqpt = load_json(EQPT_FILENAME)
|
||||
topology = load_json(NETWORK_FILENAME)
|
||||
|
||||
equipment, network = load_eqpt_topo_from_json(eqpt, topology)
|
||||
|
||||
assert isinstance(equipment, dict)
|
||||
assert isinstance(network, nx.DiGraph)
|
||||
# Check that some expected nodes exist (example: 'A', 'B')
|
||||
assert len(network.nodes) > 0
|
||||
assert len(network.edges) > 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user