def test_setup_conflict_edges_multiple(self):
        """
        Test that the code works, and that edges are created between DIFFERENT
        nodes. Also ensures that edges refer to the node index, not the Proposal
        object stored within the node.
        """
        self.network = setup_conflict_edges(self.network, rate=1)
        edges = get_edges_by_type(self.network, "conflict")

        self.assertEqual(len(edges), 20)
        for e in edges:
            self.assertIsInstance(e[0], int)
            self.assertIsInstance(e[1], int)
            self.assertNotEqual(e[0], e[1])
Esempio n. 2
0
    def test_setup_conflict_edges_single(self):
        """
        Test that the code works, and that edges are created between DIFFERENT
        nodes. Also ensures that edges refer to the node index, not the Proposal
        object stored within the node.
        """
        proposal_count = len(get_proposals(self.network))

        self.network = setup_conflict_edges(self.network,
                                            self.params["random_number_func"],
                                            1,
                                            rate=1)
        edges = get_edges_by_type(self.network, "conflict")
        self.assertEqual(len(edges), proposal_count - 1)
        for e in edges:
            self.assertIsInstance(e[0], int)
            self.assertIsInstance(e[1], int)
            self.assertNotEqual(e[0], e[1])
    def test_find_in_edges_of_type_for_proposal(self):
        """
        Ensure that only edges of the specified type are included in the answer
        """
        self.network = setup_support_edges(self.network)
        self.network = setup_conflict_edges(self.network, rate=1)

        s_edges = find_in_edges_of_type_for_proposal(self.network, 9,
                                                     "support")
        s_edges_expected = [(0, 9, 'support'), (2, 9, 'support'),
                            (4, 9, 'support'), (6, 9, 'support'),
                            (8, 9, 'support')]
        self.assertEqual(s_edges, s_edges_expected)

        c_edges = find_in_edges_of_type_for_proposal(self.network, 9,
                                                     "conflict")
        c_edges_expected = [(1, 9, 'conflict'), (3, 9, 'conflict'),
                            (5, 9, 'conflict'), (7, 9, 'conflict')]
        self.assertEqual(c_edges, c_edges_expected)