Detect unconnected nodes via span generators

Change-Id: I6962b9f193723dc7856b324d5da94d2f46b21c06
This commit is contained in:
Jan Kundrát
2021-04-30 16:33:44 +02:00
parent 3ac08f59e2
commit 340840840f
2 changed files with 18 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
from pathlib import Path
import pytest
from gnpy.core.exceptions import NetworkTopologyError
from gnpy.core.network import span_loss
from gnpy.tools.json_io import load_equipment, load_network
@@ -29,8 +30,6 @@ NETWORK_FILENAME = TEST_DIR / 'data/bugfixiteratortopo.json'
# fourth span
['fiber6', 17],
['fused7', 17],
# not connected anywhere
['fused4', 1],
# all other nodes
['Site_A', 0],
['nodeA', 0],
@@ -50,3 +49,13 @@ def test_span_loss(node, attenuation):
assert attenuation == span_loss(network, x)
return
assert not f'node "{node}" referenced from test but not found in the topology' # pragma: no cover
@pytest.mark.parametrize("node", ['fused4'])
def test_span_loss_unconnected(node):
'''Fused node that has no next and no previous nodes should be detected'''
equipment = load_equipment(EQPT_FILENAME)
network = load_network(NETWORK_FILENAME, equipment)
x = next(x for x in network.nodes() if x.uid == node)
with pytest.raises(NetworkTopologyError):
span_loss(network, x)