Пример #1
0
    def test_save(self):
        """Test if an entity exists after saving a topology.
        """
        id = 'test'

        topology = Topology(id=id)
        topology.save(manager=self.manager, context=self.context)

        topology = self.context.get(_type=topology.type, names=id)

        self.assertEqual(topology[Context.NAME], id)
Пример #2
0
 def create_topology(self, topo_name, topoEdge, topoNode):
     '''
         TODO
     '''
     # Initialize the Toplogy Manager
     manager = TopologyManager()
     # Create the topology name
     topo = Topology(id=topo_name)
     # Add the topology Edge
     topo.add_elts(topoEdge)
     # Add the topology nodes
     topo.add_elts(topoNode)
     # Save the topology
     topo.save(manager=manager)
Пример #3
0
    def test_delete(self):
        """Test if topology nodes exist after deleting a topology.
        """

        topology = Topology()
        node = TopoNode()
        topology.add_elts(node)

        topology.save(manager=self.manager)

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

        topology.delete(manager=self.manager)
        node = self.manager.get_elts(node.id)
        self.assertIsNone(node)
Пример #4
0
def generate_topology(name, _type):
    """Generate a topology related to a name and type.
    """

    # delete old topology
    topo = manager.get_graphs(ids=name)
    if topo is not None:
        topo.delete(manager=manager)
    else:
        topo = Topology(id=name)

    if _type == 'context':
        generate_context_topology(topo=topo, name=name)
    elif _type == 'rules':
        generate_rules_topology(topo=topo, name=name)
    elif _type == 'test':
        generate_test(topo=topo, name=name)
    # save topology
    topo.save(manager=manager)