def test_peer(self, find): up_asms = [ create_mock_full({"isd_as()": "1-ff00:0:300"}), # peers with 1-ff00:0:310 create_mock_full({"isd_as()": "1-ff00:0:301"}), # peers with 1-ff00:0:312 create_mock_full({"isd_as()": "1-ff00:0:302"}), ] up_seg = create_mock_full({"iter_asms()": up_asms}) down_asms = [ create_mock_full({"isd_as()": "1-ff00:0:310"}), # peers with 1-ff00:0:300 create_mock_full({"isd_as()": "1-ff00:0:311"}), create_mock_full({"isd_as()": "1-ff00:0:312"}), # peers with 1-ff00:0:301 ] down_seg = create_mock_full({"iter_asms()": down_asms}) peer_revs = create_mock() def matching_peers(a, b, c): return (a == up_asms[0] and b == down_asms[0]) or (a == up_asms[1] and b == down_asms[2]) find.side_effect = matching_peers # Call ntools.eq_(path_combinator._get_xovr_peer(up_seg, down_seg, peer_revs), (None, (2, 3)))
def test_xovr(self, find): up_asms = [ create_mock_full({"isd_as()": "1-ff00:0:300"}), create_mock_full({"isd_as()": "1-ff00:0:301"}), create_mock_full({"isd_as()": "1-ff00:0:302"}), ] up_seg = create_mock_full({"iter_asms()": up_asms}) down_asms = [ create_mock_full({"isd_as()": "1-ff00:0:300"}), create_mock_full({"isd_as()": "1-ff00:0:301"}), create_mock_full({"isd_as()": "1-ff00:0:303"}), ] down_seg = create_mock_full({"iter_asms()": down_asms}) find.return_value = False peer_revs = create_mock() # Call ntools.eq_(path_combinator._get_xovr_peer(up_seg, down_seg, peer_revs), ((2, 2), None))
def test_none(self): seg = create_mock_full({"iter_asms()": []}) peer_revs = create_mock() # Call ntools.eq_(path_combinator._get_xovr_peer(seg, seg, peer_revs), (None, None))