Esempio n. 1
0
 def test_align_2(self):
     gp = GraphMapping(self.banks, self.graphs)
     
     nodes1 = Pair("1", "1")
     nodes2 = Pair("1", "2")
     rel = "equals"
     
     gp.add_align(nodes1, rel)
     gp.add_align(nodes2, rel)
     
     rel2 = gp.get_align(nodes1)
     self.assertEqual(rel2, rel)
     
     gp.del_align(nodes1)
     self.assertFalse(gp.get_align(nodes1))
     self.assertTrue(gp.get_align(nodes2))
     self.assertTrue(gp.has_node("1"))
     self.assertTrue(gp.has_node("2"))
     
     gp.del_align(nodes2)
     self.assertFalse(gp.get_align(nodes2))
     self.assertFalse(gp.has_node("1"))
     self.assertFalse(gp.has_node("2"))
Esempio n. 2
0
 def test_shallow_copy(self):
     gp1 = GraphMapping(self.banks, self.graphs, meta_data=[])
     nodes = Pair("n1", "n2")
     gp1.add_align(nodes, "equals")
     
     gp2 = copy.copy(gp1)
     
     self.assertTrue(isinstance(gp2, GraphMapping))
     self.assertTrue(gp1._banks is gp2._banks)
     self.assertTrue(gp1._graphs is gp2._graphs)
     self.assertTrue(gp1._meta_data is gp2._meta_data)
     # also test attibs inherited from DiGraph
     self.assertTrue(gp1.graph is gp2.graph)
     self.assertTrue(gp1.node is gp2.node)
     self.assertTrue(gp1.adj is gp2.adj)
     self.assertTrue(gp1.pred is gp2.pred)
     
     gp2.add_align(nodes, "restates")
     self.assertEqual(gp1.get_align(nodes),
                      gp2.get_align(nodes))
Esempio n. 3
0
 def test_deep_copy(self):
     gp1 = GraphMapping(self.banks, self.graphs, meta_data=[])
     nodes = Pair("n1", "n2")
     gp1.add_align(nodes, "equals")        
     
     gp2 = copy.deepcopy(gp1)
     
     self.assertTrue(isinstance(gp2, GraphMapping))
     self.assertTrue(gp1._banks is gp2._banks)
     self.assertTrue(gp1._graphs is gp2._graphs)
     # for this to work, meta_data must not be string, int, etc.
     self.assertFalse(gp1._meta_data is gp2._meta_data)
     # also test attibs inherited from DiGraph
     self.assertFalse(gp1.graph is gp2.graph)
     self.assertFalse(gp1.node is gp2.node)
     self.assertFalse(gp1.adj is gp2.adj)
     self.assertFalse(gp1.pred is gp2.pred)
     
     gp2.add_align(nodes, "restates")
     self.assertNotEqual(gp1.get_align(nodes),
                         gp2.get_align(nodes))