def test_compatible(self): bridge = Bridge() assert bridge.compatible(Component.from_string('0/1')) assert not bridge.compatible(Component.from_string('1/1')) bridge = bridge.add(Component.from_string('0/1')) assert bridge.compatible(Component.from_string('2/1')) assert bridge.compatible(Component.from_string('1/2'))
def test_str(self): component = Component.from_string('0/1') assert str(component) == '0/1'
def test_two_parallel(self): assert set(map(str, Bridge._all_bridges_from_components([ Component.from_string('0/1'), Component.from_string('0/2')]))) == \ {'0/1', '0/2'}
def test_single_incompatible(self): assert set(map(str, Bridge._all_bridges_from_components([ Component.from_string('1/1')]))) == set()
def test_single(self): assert set(map(str, Bridge._all_bridges_from_components([ Component.from_string('0/1')]))) == {'0/1'}
def test_from_string(self): component = Component.from_string('0/1') assert component.ports == [0, 1] assert component._available_ports == [0, 1]
def test_str(self): bridge = Bridge() bridge = bridge.add(Component.from_string('0/1')) bridge = bridge.add(Component.from_string('10/1')) assert str(bridge) == '0/1--10/1'