def test_constructor_and__str__(self):
        ne = NetworkEdge()
        self.assertEqual(None, ne.get_attributes())
        self.assertEqual(None, ne.get_id())
        self.assertEqual(None, ne.get_source_node_id())
        self.assertEqual(None, ne.get_target_node_id())
        self.assertEqual(None, ne.get_interaction())
        self.assertEqual(None, ne.get_source_node_name())
        self.assertEqual(None, ne.get_target_node_name())

        self.assertEqual('po=None, s=None (None), t=None (None), i=None',
                         str(ne))

        # try with values set
        ne = NetworkEdge(edge_id=1,
                         source_node_id=2,
                         source_node_name='src',
                         target_node_id=3,
                         target_node_name='target',
                         interaction='interaction',
                         attributes=[])
        self.assertEqual([], ne.get_attributes())
        self.assertEqual(1, ne.get_id())
        self.assertEqual(2, ne.get_source_node_id())
        self.assertEqual(3, ne.get_target_node_id())
        self.assertEqual('interaction', ne.get_interaction())
        self.assertEqual('src', ne.get_source_node_name())
        self.assertEqual('target', ne.get_target_node_name())

        self.assertEqual('po=1, s=2 (src), t=3 (target), i=interaction',
                         str(ne))
    def test_get_edge_key(self):
        remover = ProteinFamilyNodeMemberRemover()

        # try with 1 edge no attributes
        ne = NetworkEdge(source_node_id=3, target_node_id=2,
                         interaction='activates')
        res = remover._get_edge_dict([ne])
        self.assertEqual(1, len(res))
        key = 's=3, t=2, i=activates, directed=False'
        self.assertTrue(key in res)
        self.assertEqual(1, len(res[key]))
        self.assertTrue(ne.get_source_node_id() ==
                        res[key][0].get_source_node_id())

        # try 3 edges where two edges have source/target are flipped and
        # directed is same value
        ne_one = NetworkEdge(source_node_id=1, target_node_id=2,
                             interaction='activates',
                             attributes=[Attribute(name='directed',
                                                   value=False,
                                                   data_type='boolean')])
        ne_two = NetworkEdge(source_node_id=2, target_node_id=1,
                             interaction='activates',
                             attributes=[Attribute(name='directed',
                                                   value=False,
                                                   data_type='boolean')])
        res = remover._get_edge_dict([ne_one, ne_two, ne])

        self.assertEqual(2, len(res))
        self.assertTrue(key in res)
        self.assertEqual(1, len(res[key]))
        self.assertTrue(ne.get_source_node_id() ==
                        res[key][0].get_source_node_id())
        mkey = 's=1, t=2, i=activates, directed=False'
        self.assertTrue(mkey in res)
        self.assertEqual(2, len(res[mkey]))
    def test_getters_and_setters(self):
        ne = NetworkEdge()
        ne.set_attributes([])
        ne.set_id(1)
        ne.set_source_node_id(2)
        ne.set_target_node_id(3)
        ne.set_source_node_name('src')
        ne.set_target_node_name('target')
        ne.set_interaction('interaction')

        self.assertEqual([], ne.get_attributes())
        self.assertEqual(1, ne.get_id())
        self.assertEqual(2, ne.get_source_node_id())
        self.assertEqual(3, ne.get_target_node_id())
        self.assertEqual('interaction', ne.get_interaction())
        self.assertEqual('src', ne.get_source_node_name())
        self.assertEqual('target', ne.get_target_node_name())