Ejemplo n.º 1
0
    def test_delete_orphans(self):
        """
        Test if graph vertices exist after deleting a graph.
        """

        graph = Graph()
        vertice = Vertice()
        graph.add_elts(vertice)

        graph.save(manager=self.manager)

        vertice = self.manager.get_elts(vertice.id)
        self.assertIsNotNone(vertice)

        graph.delete(manager=self.manager)
        vertice = self.manager.get_elts(vertice.id)
        self.assertIsNone(vertice)
Ejemplo n.º 2
0
 def test_orphans(self):
     """
     Test get orphans method.
     """
     # check if no orphans exist
     orphans = self.manager.get_orphans()
     self.assertFalse(orphans)
     # generate self.count vertices and edges
     [Vertice().save(self.manager) for i in range(self.count)]
     [Edge().save(self.manager) for i in range(self.count)]
     # check if previous vertices and edges are orphans
     orphans = self.manager.get_orphans()
     self.assertEqual(len(orphans), 2 * self.count)
     # create a graph and add orphans to the graph
     graph = Graph()
     graph.add_elts(orphans)
     graph.save(manager=self.manager)
     # check if only the graph is an orphan
     orphans = self.manager.get_orphans()
     self.assertEqual(len(orphans), 1)
     # delete the graph and check if vertices and edges became orphans
     graph.delete(manager=self.manager, del_orphans=False)
     orphans = self.manager.get_orphans()
     self.assertEqual(len(orphans), 2 * self.count)