From fb4195c7750ebb201033e27673a8b380acff6d95 Mon Sep 17 00:00:00 2001 From: EstherLerouzic Date: Sat, 1 Jun 2024 19:00:15 +0200 Subject: [PATCH] Feat: Enable multiple type_varieties for ROADM This commit introduces the 'type_variety' attribute for ROADM elements, allowing the use of different types of ROADM specifications instead of being limited to the default one. If no type variety name is provided in the eqpt_config, the 'default' name is used for backward compatibility with libraries. Additionally, if no type variety is defined in the ROADM element in the topology, the default one is used for backward compatibility with topologies. The 'type_variety' attribute is included in the 'to_json' and 'display' methods for ROADM elements. Signed-off-by: EstherLerouzic Change-Id: I61a2491f994e47ad0b08cf8eaef30d6d855aa706 --- gnpy/core/elements.py | 4 +- gnpy/example-data/eqpt_config.json | 10 ++ gnpy/tools/json_io.py | 15 +-- ..._Global_Topology_auto_design_expected.json | 100 ++++++++++++++++++ tests/data/eqpt_config.json | 10 ++ ...opologyExampleV2_auto_design_expected.json | 7 +- .../testTopology_auto_design_expected.json | 13 +++ tests/invocation/logs_path_request | 3 + .../logs_path_requests_run_CD_PMD_PDL_missing | 3 + tests/invocation/logs_power_sweep_example | 3 + tests/invocation/logs_transmission_saturated | 3 + .../openroadm-v4-Stockholm-Gothenburg | 6 ++ .../openroadm-v5-Stockholm-Gothenburg | 6 ++ .../spectrum1_transmission_main_example | 2 + .../spectrum2_transmission_main_example | 2 + tests/invocation/transmission_long_pow | 5 + tests/invocation/transmission_long_psd | 5 + tests/invocation/transmission_long_psw | 5 + .../invocation/transmission_main_example_long | 5 + tests/invocation/transmission_saturated | 2 + tests/test_equalization.py | 2 + tests/test_parser.py | 51 ++++++++- tests/test_roadm_restrictions.py | 24 ++++- 23 files changed, 276 insertions(+), 10 deletions(-) diff --git a/gnpy/core/elements.py b/gnpy/core/elements.py index 47427a7f1..15c438545 100644 --- a/gnpy/core/elements.py +++ b/gnpy/core/elements.py @@ -273,9 +273,10 @@ def to_json(self): to_json = { 'uid': self.uid, 'type': type(self).__name__, + 'type_variety': self.type_variety, 'params': { equalisation: value, - 'restrictions': self.restrictions, + 'restrictions': self.restrictions }, 'metadata': { 'location': self.metadata['location']._asdict() @@ -299,6 +300,7 @@ def __str__(self): total_pch = pretty_summary_print(per_label_average(self.pch_out_dbm, self.propagated_labels)) return '\n'.join([f'{type(self).__name__} {self.uid}', + f' type_variety: {self.type_variety}', f' effective loss (dB): {self.ref_effective_loss:.2f}', f' reference pch out (dBm): {self.ref_pch_out_dbm:.2f}', f' actual pch out (dBm): {total_pch}']) diff --git a/gnpy/example-data/eqpt_config.json b/gnpy/example-data/eqpt_config.json index ecac31e39..556816188 100644 --- a/gnpy/example-data/eqpt_config.json +++ b/gnpy/example-data/eqpt_config.json @@ -208,6 +208,16 @@ "preamp_variety_list": [], "booster_variety_list": [] } + }, { + "type_variety": "roadm_type_1", + "target_pch_out_db": -18, + "add_drop_osnr": 35, + "pmd": 0, + "pdl": 0, + "restrictions": { + "preamp_variety_list": [], + "booster_variety_list": [] + } } ], "SI": [{ diff --git a/gnpy/tools/json_io.py b/gnpy/tools/json_io.py index dbf30cb55..ce8cc5311 100644 --- a/gnpy/tools/json_io.py +++ b/gnpy/tools/json_io.py @@ -95,6 +95,7 @@ def __init__(self, **kwargs): class Roadm(_JsonThing): default_values = { + 'type_variety': 'default', 'add_drop_osnr': 100, 'pmd': 0, 'pdl': 0, @@ -361,11 +362,13 @@ def _update_dual_stage(equipment): def _roadm_restrictions_sanity_check(equipment): """verifies that booster and preamp restrictions specified in roadm equipment are listed in the edfa.""" - restrictions = equipment['Roadm']['default'].restrictions['booster_variety_list'] + \ - equipment['Roadm']['default'].restrictions['preamp_variety_list'] - for amp_name in restrictions: - if amp_name not in equipment['Edfa']: - raise EquipmentConfigError(f'ROADM restriction {amp_name} does not refer to a defined EDFA name') + for roadm_type, roadm_eqpt in equipment['Roadm'].items(): + restrictions = roadm_eqpt.restrictions['booster_variety_list'] + \ + roadm_eqpt.restrictions['preamp_variety_list'] + for amp_name in restrictions: + if amp_name not in equipment['Edfa']: + raise EquipmentConfigError(f'ROADM {roadm_type} restriction {amp_name} does not refer to a ' + + 'defined EDFA name') def _check_fiber_vs_raman_fiber(equipment): @@ -481,7 +484,7 @@ def network_from_json(json_data, equipment): temp = merge_amplifier_restrictions(temp, extra_params) el_config['params'] = temp el_config['type_variety'] = variety - elif (typ in ['Fiber', 'RamanFiber']): + elif (typ in ['Fiber', 'RamanFiber', 'Roadm']): raise ConfigurationError(f'The {typ} of variety type {variety} was not recognized:' '\nplease check it is properly defined in the eqpt_config json file') elif typ == 'Edfa': diff --git a/tests/data/CORONET_Global_Topology_auto_design_expected.json b/tests/data/CORONET_Global_Topology_auto_design_expected.json index 86120d591..6417fdbd0 100644 --- a/tests/data/CORONET_Global_Topology_auto_design_expected.json +++ b/tests/data/CORONET_Global_Topology_auto_design_expected.json @@ -1203,6 +1203,7 @@ { "uid": "roadm Abilene", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1226,6 +1227,7 @@ { "uid": "roadm Albany", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1249,6 +1251,7 @@ { "uid": "roadm Albuquerque", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1274,6 +1277,7 @@ { "uid": "roadm Atlanta", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1298,6 +1302,7 @@ { "uid": "roadm Austin", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1321,6 +1326,7 @@ { "uid": "roadm Baltimore", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1345,6 +1351,7 @@ { "uid": "roadm Baton_Rouge", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1368,6 +1375,7 @@ { "uid": "roadm Billings", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1392,6 +1400,7 @@ { "uid": "roadm Birmingham", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1416,6 +1425,7 @@ { "uid": "roadm Bismarck", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1439,6 +1449,7 @@ { "uid": "roadm Boston", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1462,6 +1473,7 @@ { "uid": "roadm Buffalo", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1485,6 +1497,7 @@ { "uid": "roadm Charleston", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1508,6 +1521,7 @@ { "uid": "roadm Charlotte", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1531,6 +1545,7 @@ { "uid": "roadm Chicago", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1555,6 +1570,7 @@ { "uid": "roadm Cincinnati", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1579,6 +1595,7 @@ { "uid": "roadm Cleveland", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1603,6 +1620,7 @@ { "uid": "roadm Columbus", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1627,6 +1645,7 @@ { "uid": "roadm Dallas", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1653,6 +1672,7 @@ { "uid": "roadm Denver", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1678,6 +1698,7 @@ { "uid": "roadm Detroit", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1701,6 +1722,7 @@ { "uid": "roadm El_Paso", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1726,6 +1748,7 @@ { "uid": "roadm Fresno", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1750,6 +1773,7 @@ { "uid": "roadm Greensboro", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1775,6 +1799,7 @@ { "uid": "roadm Hartford", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1798,6 +1823,7 @@ { "uid": "roadm Houston", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1822,6 +1848,7 @@ { "uid": "roadm Jacksonville", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1846,6 +1873,7 @@ { "uid": "roadm Kansas_City", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1870,6 +1898,7 @@ { "uid": "roadm Las_Vegas", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1895,6 +1924,7 @@ { "uid": "roadm Little_Rock", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1918,6 +1948,7 @@ { "uid": "roadm Long_Island", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1941,6 +1972,7 @@ { "uid": "roadm Los_Angeles", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1966,6 +1998,7 @@ { "uid": "roadm Louisville", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1991,6 +2024,7 @@ { "uid": "roadm Memphis", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2014,6 +2048,7 @@ { "uid": "roadm Miami", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2038,6 +2073,7 @@ { "uid": "roadm Milwaukee", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2061,6 +2097,7 @@ { "uid": "roadm Minneapolis", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2085,6 +2122,7 @@ { "uid": "roadm Nashville", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2109,6 +2147,7 @@ { "uid": "roadm New_Orleans", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2133,6 +2172,7 @@ { "uid": "roadm New_York", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2159,6 +2199,7 @@ { "uid": "roadm Newark", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2182,6 +2223,7 @@ { "uid": "roadm Norfolk", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2205,6 +2247,7 @@ { "uid": "roadm Oakland", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2231,6 +2274,7 @@ { "uid": "roadm Oklahoma_City", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2254,6 +2298,7 @@ { "uid": "roadm Omaha", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2278,6 +2323,7 @@ { "uid": "roadm Orlando", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2301,6 +2347,7 @@ { "uid": "roadm Philadelphia", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2325,6 +2372,7 @@ { "uid": "roadm Phoenix", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2349,6 +2397,7 @@ { "uid": "roadm Pittsburgh", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2373,6 +2422,7 @@ { "uid": "roadm Portland", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2398,6 +2448,7 @@ { "uid": "roadm Providence", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2421,6 +2472,7 @@ { "uid": "roadm Raleigh", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2445,6 +2497,7 @@ { "uid": "roadm Richmond", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2468,6 +2521,7 @@ { "uid": "roadm Rochester", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2491,6 +2545,7 @@ { "uid": "roadm Sacramento", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2514,6 +2569,7 @@ { "uid": "roadm Salt_Lake_City", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2539,6 +2595,7 @@ { "uid": "roadm San_Antonio", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2562,6 +2619,7 @@ { "uid": "roadm San_Diego", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2585,6 +2643,7 @@ { "uid": "roadm San_Francisco", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2608,6 +2667,7 @@ { "uid": "roadm San_Jose", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2631,6 +2691,7 @@ { "uid": "roadm Santa_Barbara", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2654,6 +2715,7 @@ { "uid": "roadm Scranton", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2679,6 +2741,7 @@ { "uid": "roadm Seattle", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2702,6 +2765,7 @@ { "uid": "roadm Spokane", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2725,6 +2789,7 @@ { "uid": "roadm Springfield", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2748,6 +2813,7 @@ { "uid": "roadm St_Louis", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2772,6 +2838,7 @@ { "uid": "roadm Syracuse", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2796,6 +2863,7 @@ { "uid": "roadm Tallahassee", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2819,6 +2887,7 @@ { "uid": "roadm Tampa", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2842,6 +2911,7 @@ { "uid": "roadm Toledo", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2865,6 +2935,7 @@ { "uid": "roadm Tucson", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2888,6 +2959,7 @@ { "uid": "roadm Tulsa", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2911,6 +2983,7 @@ { "uid": "roadm Washington_DC", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2936,6 +3009,7 @@ { "uid": "roadm West_Palm_Beach", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2959,6 +3033,7 @@ { "uid": "roadm Wilmington", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -2982,6 +3057,7 @@ { "uid": "roadm Amsterdam", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3007,6 +3083,7 @@ { "uid": "roadm Berlin", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3030,6 +3107,7 @@ { "uid": "roadm Brussels", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3053,6 +3131,7 @@ { "uid": "roadm Bucharest", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3076,6 +3155,7 @@ { "uid": "roadm Frankfurt", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3099,6 +3179,7 @@ { "uid": "roadm Istanbul", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3123,6 +3204,7 @@ { "uid": "roadm London", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3147,6 +3229,7 @@ { "uid": "roadm Madrid", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3170,6 +3253,7 @@ { "uid": "roadm Paris", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3194,6 +3278,7 @@ { "uid": "roadm Rome", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3219,6 +3304,7 @@ { "uid": "roadm Vienna", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3243,6 +3329,7 @@ { "uid": "roadm Warsaw", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3267,6 +3354,7 @@ { "uid": "roadm Zurich", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3290,6 +3378,7 @@ { "uid": "roadm Bangkok", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3313,6 +3402,7 @@ { "uid": "roadm Beijing", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3336,6 +3426,7 @@ { "uid": "roadm Delhi", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3360,6 +3451,7 @@ { "uid": "roadm Hong_Kong", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3385,6 +3477,7 @@ { "uid": "roadm Honolulu", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3409,6 +3502,7 @@ { "uid": "roadm Mumbai", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3433,6 +3527,7 @@ { "uid": "roadm Seoul", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3456,6 +3551,7 @@ { "uid": "roadm Shanghai", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3479,6 +3575,7 @@ { "uid": "roadm Singapore", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3502,6 +3599,7 @@ { "uid": "roadm Sydney", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3526,6 +3624,7 @@ { "uid": "roadm Taipei", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -3551,6 +3650,7 @@ { "uid": "roadm Tokyo", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { diff --git a/tests/data/eqpt_config.json b/tests/data/eqpt_config.json index 3dff6ba97..414b8db61 100644 --- a/tests/data/eqpt_config.json +++ b/tests/data/eqpt_config.json @@ -78,6 +78,16 @@ } ], "Roadm": [{ + "type_variety": "example_test", + "target_pch_out_db": -18, + "add_drop_osnr": 35, + "pmd": 1e-12, + "pdl": 0.5, + "restrictions": { + "preamp_variety_list": [], + "booster_variety_list": [] + } + }, { "target_pch_out_db": -20, "add_drop_osnr": 38, "pmd": 0, diff --git a/tests/data/perdegreemeshTopologyExampleV2_auto_design_expected.json b/tests/data/perdegreemeshTopologyExampleV2_auto_design_expected.json index 1e7e25b94..d9e383817 100644 --- a/tests/data/perdegreemeshTopologyExampleV2_auto_design_expected.json +++ b/tests/data/perdegreemeshTopologyExampleV2_auto_design_expected.json @@ -63,6 +63,7 @@ { "uid": "roadm Lannion_CAS", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -18.6, "restrictions": { @@ -87,6 +88,7 @@ { "uid": "roadm Lorient_KMA", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -111,6 +113,7 @@ { "uid": "roadm Vannes_KBE", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -134,6 +137,7 @@ { "uid": "roadm Rennes_STA", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -157,6 +161,7 @@ { "uid": "roadm Brest_KLA", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -1668,4 +1673,4 @@ "to_node": "fiber (Ploermel → Vannes_KBE)-" } ] -} \ No newline at end of file +} diff --git a/tests/data/testTopology_auto_design_expected.json b/tests/data/testTopology_auto_design_expected.json index cd611236f..daca6b824 100644 --- a/tests/data/testTopology_auto_design_expected.json +++ b/tests/data/testTopology_auto_design_expected.json @@ -159,6 +159,7 @@ { "uid": "roadm Lannion_CAS", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -183,6 +184,7 @@ { "uid": "roadm Lorient_KMA", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -207,6 +209,7 @@ { "uid": "roadm Vannes_KBE", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -230,6 +233,7 @@ { "uid": "roadm Rennes_STA", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -253,6 +257,7 @@ { "uid": "roadm Brest_KLA", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -276,6 +281,7 @@ { "uid": "roadm a", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -301,6 +307,7 @@ { "uid": "roadm b", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -326,6 +333,7 @@ { "uid": "roadm c", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -350,6 +358,7 @@ { "uid": "roadm d", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -373,6 +382,7 @@ { "uid": "roadm e", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -396,6 +406,7 @@ { "uid": "roadm f", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -420,6 +431,7 @@ { "uid": "roadm g", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { @@ -443,6 +455,7 @@ { "uid": "roadm h", "type": "Roadm", + "type_variety": "default", "params": { "target_pch_out_db": -20, "restrictions": { diff --git a/tests/invocation/logs_path_request b/tests/invocation/logs_path_request index 4be3d0b5b..3db28623b 100644 --- a/tests/invocation/logs_path_request +++ b/tests/invocation/logs_path_request @@ -1,4 +1,7 @@ INFO gnpy.tools.cli_examples:cli_examples.py Computing path requests meshTopologyExampleV2.xls into JSON format +WARNING gnpy.tools.json_io:json_io.py + WARNING missing type_variety attribute in eqpt_config.json[Roadm] + default value is type_variety = default INFO gnpy.tools.json_io:json_io.py Automatically converting requests from XLS to JSON INFO gnpy.topology.request:request.py request 0 diff --git a/tests/invocation/logs_path_requests_run_CD_PMD_PDL_missing b/tests/invocation/logs_path_requests_run_CD_PMD_PDL_missing index 7a902bd5b..24b3a8fef 100644 --- a/tests/invocation/logs_path_requests_run_CD_PMD_PDL_missing +++ b/tests/invocation/logs_path_requests_run_CD_PMD_PDL_missing @@ -1,4 +1,7 @@ INFO gnpy.tools.cli_examples:cli_examples.py Computing path requests CORONET_services.json into JSON format +WARNING gnpy.tools.json_io:json_io.py + WARNING missing type_variety attribute in eqpt_config.json[Roadm] + default value is type_variety = default INFO gnpy.topology.request:request.py request 0 Computing path from trx Abilene to trx Albany diff --git a/tests/invocation/logs_power_sweep_example b/tests/invocation/logs_power_sweep_example index a3d4e771b..b94957400 100644 --- a/tests/invocation/logs_power_sweep_example +++ b/tests/invocation/logs_power_sweep_example @@ -1,3 +1,6 @@ +WARNING gnpy.tools.json_io:json_io.py + WARNING missing type_variety attribute in eqpt_config.json[Roadm] + default value is type_variety = default INFO gnpy.tools.cli_examples:cli_examples.py source = 'brest' INFO gnpy.tools.cli_examples:cli_examples.py destination = 'rennes' WARNING gnpy.core.network:network.py diff --git a/tests/invocation/logs_transmission_saturated b/tests/invocation/logs_transmission_saturated index ea272d327..6b2e42876 100644 --- a/tests/invocation/logs_transmission_saturated +++ b/tests/invocation/logs_transmission_saturated @@ -1,3 +1,6 @@ +WARNING gnpy.tools.json_io:json_io.py + WARNING missing type_variety attribute in eqpt_config.json[Roadm] + default value is type_variety = default INFO gnpy.tools.cli_examples:cli_examples.py source = 'lannion' INFO gnpy.tools.cli_examples:cli_examples.py destination = 'lorient' WARNING gnpy.core.network:network.py diff --git a/tests/invocation/openroadm-v4-Stockholm-Gothenburg b/tests/invocation/openroadm-v4-Stockholm-Gothenburg index bbba8ab64..66d7395a8 100644 --- a/tests/invocation/openroadm-v4-Stockholm-Gothenburg +++ b/tests/invocation/openroadm-v4-Stockholm-Gothenburg @@ -17,6 +17,7 @@ Transceiver trx_Stockholm PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm_Stockholm + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -78,6 +79,7 @@ Edfa Edfa_preamp_roadm_Norrköping_from_fiber (Stockholm → Norrköping)_(2/2) actual pch out (dBm): 2.03 output VOA (dB): 0.00 Roadm roadm_Norrköping + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -117,6 +119,7 @@ Edfa Edfa_preamp_roadm_Linköping_from_fiber (Norrköping → Linköping) actual pch out (dBm): 2.01 output VOA (dB): 0.00 Roadm roadm_Linköping + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -156,6 +159,7 @@ Edfa Edfa_preamp_roadm_Jönköping_from_fiber (Linköping → Jönköping) actual pch out (dBm): 2.05 output VOA (dB): 0.00 Roadm roadm_Jönköping + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -195,6 +199,7 @@ Edfa Edfa_preamp_roadm_Borås_from_fiber (Jönköping → Borås) actual pch out (dBm): 2.02 output VOA (dB): 0.00 Roadm roadm_Borås + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -234,6 +239,7 @@ Edfa Edfa_preamp_roadm_Gothenburg_from_fiber (Borås → Gothenburg) actual pch out (dBm): 2.02 output VOA (dB): 0.00 Roadm roadm_Gothenburg + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 diff --git a/tests/invocation/openroadm-v5-Stockholm-Gothenburg b/tests/invocation/openroadm-v5-Stockholm-Gothenburg index b0c06ddae..090b51ff3 100644 --- a/tests/invocation/openroadm-v5-Stockholm-Gothenburg +++ b/tests/invocation/openroadm-v5-Stockholm-Gothenburg @@ -17,6 +17,7 @@ Transceiver trx_Stockholm PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm_Stockholm + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -78,6 +79,7 @@ Edfa Edfa_preamp_roadm_Norrköping_from_fiber (Stockholm → Norrköping)_(2/2) actual pch out (dBm): 2.03 output VOA (dB): 0.00 Roadm roadm_Norrköping + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -117,6 +119,7 @@ Edfa Edfa_preamp_roadm_Linköping_from_fiber (Norrköping → Linköping) actual pch out (dBm): 2.01 output VOA (dB): 0.00 Roadm roadm_Linköping + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -156,6 +159,7 @@ Edfa Edfa_preamp_roadm_Jönköping_from_fiber (Linköping → Jönköping) actual pch out (dBm): 2.04 output VOA (dB): 0.00 Roadm roadm_Jönköping + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -195,6 +199,7 @@ Edfa Edfa_preamp_roadm_Borås_from_fiber (Jönköping → Borås) actual pch out (dBm): 2.02 output VOA (dB): 0.00 Roadm roadm_Borås + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -234,6 +239,7 @@ Edfa Edfa_preamp_roadm_Gothenburg_from_fiber (Borås → Gothenburg) actual pch out (dBm): 2.02 output VOA (dB): 0.00 Roadm roadm_Gothenburg + type_variety: default effective loss (dB): 22.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 diff --git a/tests/invocation/spectrum1_transmission_main_example b/tests/invocation/spectrum1_transmission_main_example index 610d6f2d3..f699f794b 100644 --- a/tests/invocation/spectrum1_transmission_main_example +++ b/tests/invocation/spectrum1_transmission_main_example @@ -18,6 +18,7 @@ Transceiver trx Lannion_CAS PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm Lannion_CAS + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -79,6 +80,7 @@ Edfa west edfa in Lorient_KMA to Loudeac actual pch out (dBm): 1.05 output VOA (dB): 0.00 Roadm roadm Lorient_KMA + type_variety: default effective loss (dB): 21.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 diff --git a/tests/invocation/spectrum2_transmission_main_example b/tests/invocation/spectrum2_transmission_main_example index d4b8ab587..c5442838f 100644 --- a/tests/invocation/spectrum2_transmission_main_example +++ b/tests/invocation/spectrum2_transmission_main_example @@ -18,6 +18,7 @@ Transceiver trx Lannion_CAS PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm Lannion_CAS + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -20.00 @@ -79,6 +80,7 @@ Edfa west edfa in Lorient_KMA to Loudeac actual pch out (dBm): mode_1: 1.04, mode_2: 1.09 output VOA (dB): 0.00 Roadm roadm Lorient_KMA + type_variety: default effective loss (dB): 21.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -20.00 diff --git a/tests/invocation/transmission_long_pow b/tests/invocation/transmission_long_pow index f7d2e3763..4b4aca9cf 100644 --- a/tests/invocation/transmission_long_pow +++ b/tests/invocation/transmission_long_pow @@ -18,6 +18,7 @@ Transceiver Site_A PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm Site A + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -20.00 @@ -145,6 +146,7 @@ Edfa Edfa5 actual pch out (dBm): mode_1: 0.05, mode_2: 0.08 output VOA (dB): 0.00 Roadm roadm Site C + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -20.00 @@ -272,6 +274,7 @@ Edfa Edfa10 actual pch out (dBm): mode_1: 0.05, mode_2: 0.08 output VOA (dB): 0.00 Roadm roadm Site D + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -20.00 @@ -333,6 +336,7 @@ Edfa Edfa12 actual pch out (dBm): mode_1: 0.03, mode_2: 0.04 output VOA (dB): 0.00 Roadm roadm Site E + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -20.00 @@ -416,6 +420,7 @@ Edfa Edfa15 actual pch out (dBm): mode_1: 0.03, mode_2: 0.05 output VOA (dB): 0.00 Roadm roadm Site B + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -20.00 diff --git a/tests/invocation/transmission_long_psd b/tests/invocation/transmission_long_psd index 774ded705..7b54bb2db 100644 --- a/tests/invocation/transmission_long_psd +++ b/tests/invocation/transmission_long_psd @@ -18,6 +18,7 @@ Transceiver Site_A PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm Site A + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -16.99 @@ -145,6 +146,7 @@ Edfa Edfa5 actual pch out (dBm): mode_1: 0.06, mode_2: 3.07 output VOA (dB): 0.00 Roadm roadm Site C + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -16.99 @@ -272,6 +274,7 @@ Edfa Edfa10 actual pch out (dBm): mode_1: 0.06, mode_2: 3.07 output VOA (dB): 0.00 Roadm roadm Site D + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -16.99 @@ -333,6 +336,7 @@ Edfa Edfa12 actual pch out (dBm): mode_1: 0.03, mode_2: 3.04 output VOA (dB): 0.00 Roadm roadm Site E + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -16.99 @@ -416,6 +420,7 @@ Edfa Edfa15 actual pch out (dBm): mode_1: 0.04, mode_2: 3.05 output VOA (dB): 0.00 Roadm roadm Site B + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -16.99 diff --git a/tests/invocation/transmission_long_psw b/tests/invocation/transmission_long_psw index 1a11cbbd2..e4d8803c6 100644 --- a/tests/invocation/transmission_long_psw +++ b/tests/invocation/transmission_long_psw @@ -18,6 +18,7 @@ Transceiver Site_A PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm Site A + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -18.24 @@ -145,6 +146,7 @@ Edfa Edfa5 actual pch out (dBm): mode_1: 0.05, mode_2: 1.82 output VOA (dB): 0.00 Roadm roadm Site C + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -18.24 @@ -272,6 +274,7 @@ Edfa Edfa10 actual pch out (dBm): mode_1: 0.05, mode_2: 1.82 output VOA (dB): 0.00 Roadm roadm Site D + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -18.24 @@ -333,6 +336,7 @@ Edfa Edfa12 actual pch out (dBm): mode_1: 0.03, mode_2: 1.79 output VOA (dB): 0.00 Roadm roadm Site E + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -18.24 @@ -416,6 +420,7 @@ Edfa Edfa15 actual pch out (dBm): mode_1: 0.03, mode_2: 1.80 output VOA (dB): 0.00 Roadm roadm Site B + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): mode_1: -20.00, mode_2: -18.24 diff --git a/tests/invocation/transmission_main_example_long b/tests/invocation/transmission_main_example_long index de509eedb..e31e19c75 100644 --- a/tests/invocation/transmission_main_example_long +++ b/tests/invocation/transmission_main_example_long @@ -17,6 +17,7 @@ Transceiver Site_A PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm Site A + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -144,6 +145,7 @@ Edfa Edfa5 actual pch out (dBm): 0.06 output VOA (dB): 0.00 Roadm roadm Site C + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -271,6 +273,7 @@ Edfa Edfa10 actual pch out (dBm): 0.06 output VOA (dB): 0.00 Roadm roadm Site D + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -332,6 +335,7 @@ Edfa Edfa12 actual pch out (dBm): 0.03 output VOA (dB): 0.00 Roadm roadm Site E + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -415,6 +419,7 @@ Edfa Edfa15 actual pch out (dBm): 0.04 output VOA (dB): 0.00 Roadm roadm Site B + type_variety: default effective loss (dB): 20.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 diff --git a/tests/invocation/transmission_saturated b/tests/invocation/transmission_saturated index ab608e08f..2cb4e0182 100644 --- a/tests/invocation/transmission_saturated +++ b/tests/invocation/transmission_saturated @@ -17,6 +17,7 @@ Transceiver trx Lannion_CAS PDL (dB): 0.00 Latency (ms): 0.00 Roadm roadm Lannion_CAS + type_variety: default effective loss (dB): 23.00 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 @@ -78,6 +79,7 @@ Edfa west edfa in Lorient_KMA to Loudeac actual pch out (dBm): 1.21 output VOA (dB): 0.00 Roadm roadm Lorient_KMA + type_variety: default effective loss (dB): 21.18 reference pch out (dBm): -20.00 actual pch out (dBm): -20.00 diff --git a/tests/test_equalization.py b/tests/test_equalization.py index 1277c753d..9f76fe3dd 100644 --- a/tests/test_equalization.py +++ b/tests/test_equalization.py @@ -54,6 +54,7 @@ def test_equalization_combination_degree(delta_pdb_per_channel, degree, equaliza roadm_config = { "uid": "roadm Lannion_CAS", + "type_variety": "default", "params": { "per_degree_pch_out_db": { "east edfa in Lannion_CAS to Corlay": -16 @@ -85,6 +86,7 @@ def test_equalization_combination_degree(delta_pdb_per_channel, degree, equaliza to_json_before_propagation = { 'uid': 'roadm Lannion_CAS', 'type': 'Roadm', + "type_variety": "default", 'params': { equalization_type: target, 'restrictions': {'preamp_variety_list': [], 'booster_variety_list': []}, diff --git a/tests/test_parser.py b/tests/test_parser.py index 27a09c7c4..8eba6815e 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -25,7 +25,7 @@ from copy import deepcopy from gnpy.core.utils import automatic_nch, lin2db from gnpy.core.network import build_network, add_missing_elements_in_network -from gnpy.core.exceptions import ServiceError +from gnpy.core.exceptions import ServiceError, ConfigurationError from gnpy.topology.request import (jsontocsv, requests_aggregation, compute_path_dsjctn, deduplicate_disjunctions, compute_path_with_disjunction, ResultElement, PathRequest) from gnpy.topology.spectrum_assignment import build_oms_list, pth_assign_spectrum @@ -565,3 +565,52 @@ def test_service_json_constraint_order(): rqs = requests_from_json(data, equipment) assert rqs[0].nodes_list == ['roadm Brest_KLA', 'roadm Lannion_CAS', 'roadm Lorient_KMA', 'roadm Vannes_KBE'] assert rqs[0].loose_list == ['STRICT', 'LOOSE', 'STRICT', 'STRICT'] + + +@pytest.mark.parametrize('type_variety, target_pch_out_db, correct_variety', [(None, -20, True), + ('example_test', -18, True), + ('example', None, False)]) +def test_roadm_type_variety(type_variety, target_pch_out_db, correct_variety): + """Checks that if element has no variety, the default one is applied, and if it has one + that the type_variety is correctly applied + """ + json_data = { + "elements": [{ + "uid": "roadm Oakland", + "type": "Roadm", + }], + "connections": [] + } + expected_roadm = { + "uid": "roadm Oakland", + "type": "Roadm", + "params": { + "restrictions": { + "preamp_variety_list": [], + "booster_variety_list": [] + } + }, + 'metadata': { + 'location': { + 'city': None, + 'latitude': 0, + 'longitude': 0, + 'region': None + } + } + } + if type_variety is not None: + json_data['elements'][0]['type_variety'] = type_variety + expected_roadm['type_variety'] = type_variety + else: + # Do not add type variety in json_data to test that it creates a 'default' type_variety + expected_roadm['type_variety'] = 'default' + expected_roadm['params']['target_pch_out_db'] = target_pch_out_db + equipment = load_equipment(eqpt_filename) + if correct_variety: + network = network_from_json(json_data, equipment) + roadm = [n for n in network.nodes()][0] + assert roadm.to_json == expected_roadm + else: + with pytest.raises(ConfigurationError): + network = network_from_json(json_data, equipment) diff --git a/tests/test_roadm_restrictions.py b/tests/test_roadm_restrictions.py index 4055bb8d7..a37f3cbaf 100644 --- a/tests/test_roadm_restrictions.py +++ b/tests/test_roadm_restrictions.py @@ -19,11 +19,12 @@ from gnpy.core.elements import Fused, Roadm, Edfa, Transceiver, EdfaOperational, EdfaParams, Fiber from gnpy.core.parameters import FiberParams, RoadmParams, FusedParams from gnpy.core.network import build_network, design_network -from gnpy.tools.json_io import network_from_json, load_equipment, load_json, Amp +from gnpy.tools.json_io import network_from_json, load_equipment, load_json, Amp, _equipment_from_json from gnpy.core.equipment import trx_mode_params from gnpy.topology.request import PathRequest, compute_constrained_path, propagate from gnpy.core.info import create_input_spectral_information, Carrier from gnpy.core.utils import db2lin, dbm2watt +from gnpy.core.exceptions import ConfigurationError TEST_DIR = Path(__file__).parent @@ -527,3 +528,24 @@ def test_compare_design_propagation_settings(power_dbm, req_power, amp_with_delt getattr(getattr(element_copy, key), subkey), rtol=1e-12) else: assert getattr(getattr(element, key), subkey) == getattr(getattr(element_copy, key), subkey) + + +@pytest.mark.parametrize("restrictions, fail", [ + ({'preamp_variety_list': [], 'booster_variety_list':[]}, False), + ({'preamp_variety_list': ['std_medium_gain', 'std_low_gain'], 'booster_variety_list':['std_medium_gain']}, False), + # the two next amp type_variety do not exist + ({'preamp_variety_list': [], 'booster_variety_list':['booster_medium_gain']}, True), + ({'preamp_variety_list': ['std_medium_gain', 'preamp_high_gain'], 'booster_variety_list':[]}, True)]) +def test_wrong_restrictions(restrictions, fail): + """Check that sanity_check correctly raises an error when restriction is incorrect and that library + correctly includes restrictions. + """ + json_data = load_json(EQPT_LIBRARY_NAME) + # define wrong restriction + json_data['Roadm'][0]['restrictions'] = restrictions + if fail: + with pytest.raises(ConfigurationError): + _ = _equipment_from_json(json_data, EQPT_LIBRARY_NAME) + else: + equipment = _equipment_from_json(json_data, EQPT_LIBRARY_NAME) + assert equipment['Roadm']['example_test'].restrictions == restrictions