示例#1
0
    def test_build_edge_map_single_edge_of_each_type(self):
        adjud = RedundantEdgeAdjudicator()
        net = NiceCXNetwork()

        # try empty network
        neighbor, controls, other = adjud._build_edge_map(net)
        self.assertEqual({}, neighbor)
        self.assertEqual({}, controls)
        self.assertEqual({}, other)

        # try network with single neighbor, controls, and an another edge
        nid = net.create_edge(edge_source=0,
                              edge_target=1,
                              edge_interaction='neighbor-of')
        cid = net.create_edge(edge_source=0,
                              edge_target=1,
                              edge_interaction='controls-state-change-of')
        oid = net.create_edge(edge_source=0,
                              edge_target=1,
                              edge_interaction='somethingelse')
        neighbor, controls, other = adjud._build_edge_map(net)
        self.assertEqual(nid, neighbor[0][1])
        self.assertEqual(nid, neighbor[1][0])
        self.assertEqual({cid}, controls[0][1])
        self.assertEqual({oid}, other[0][1])
示例#2
0
    def test_build_edge_map_multiple_edges_of_each_type(self):
        # try network with multiple neighbor, controls, and an another edge
        net = NiceCXNetwork()
        adjud = RedundantEdgeAdjudicator()
        nid = net.create_edge(edge_source=0,
                              edge_target=1,
                              edge_interaction='neighbor-of')
        nidtwo = net.create_edge(edge_source=2,
                                 edge_target=3,
                                 edge_interaction='neighbor-of')
        cid = net.create_edge(edge_source=0,
                              edge_target=1,
                              edge_interaction='controls-state-change-of')
        cidtwo = net.create_edge(edge_source=3,
                                 edge_target=4,
                                 edge_interaction='controls-state-change-of')

        oid = net.create_edge(edge_source=0,
                              edge_target=1,
                              edge_interaction='somethingelse')
        oidtwo = net.create_edge(edge_source=5,
                                 edge_target=6,
                                 edge_interaction='anotherthingy')
        neighbor, controls, other = adjud._build_edge_map(net)
        self.assertEqual(nid, neighbor[0][1])
        self.assertEqual(nid, neighbor[1][0])
        self.assertEqual(nidtwo, neighbor[2][3])
        self.assertEqual(nidtwo, neighbor[3][2])
        self.assertEqual({cid}, controls[0][1])
        self.assertEqual({cidtwo}, controls[3][4])
        self.assertEqual({oid}, other[0][1])
        self.assertEqual({oidtwo}, other[5][6])