Example #1
0
    def test_drop_graph_that_does_not_exist(self):
        graph_name = str(uuid.uuid1()).replace('-', '_')

        self.assertFalse(
            graph_name in ta.get_graph_names(),
            graph_name + " should not exist in the list of graphs")

        self.assertEqual(0, ta.drop_graphs(graph_name),
                         "drop_graphs() shouldn't have deleted any graphs")
Example #2
0
    def test_drop_graph_by_object(self):
        graph_name = str(uuid.uuid1()).replace("-", "_")

        # Create graph and verify that it's in the get_graph_names() list
        graph = ta.Graph(name=graph_name)
        self.assertTrue(graph_name in ta.get_graph_names(), graph_name + " should exist in the list of graphs")

        # Drop graph using the graph object
        self.assertEqual(1, ta.drop_graphs(graph), "drop_graphs() should have deleted one graph.")
        self.assertFalse(graph_name in ta.get_graph_names(), graph_name + " should not exist in the list of graphs")
Example #3
0
    def test_drop_graph_by_object(self):
        graph_name = str(uuid.uuid1()).replace('-', '_')

        # Create graph and verify that it's in the get_graph_names() list
        graph = ta.Graph(name=graph_name)
        self.assertTrue(graph_name in ta.get_graph_names(),
                        graph_name + " should exist in the list of graphs")

        # Drop graph using the graph object
        self.assertEqual(1, ta.drop_graphs(graph),
                         "drop_graphs() should have deleted one graph.")
        self.assertFalse(
            graph_name in ta.get_graph_names(),
            graph_name + " should not exist in the list of graphs")
Example #4
0
graph = ta.Graph()
graph.define_vertex_type('Employee')
graph.define_edge_type('worksunder', 'Employee', 'Employee', directed=False)
graph.vertices['Employee'].add_vertices(employees_frame, 'Manager', [])
graph.vertices['Employee'].add_vertices(employees_frame, 'Employee', ['Title'])
graph.edges['worksunder'].add_edges(employees_frame, 'Employee', 'Manager',
                                    ['Years'])

graph.vertex_count
graph.edge_count
graph.vertices['Employee'].inspect(9)
graph.edges['worksunder'].inspect(20)

#Option 2

ta.drop_graphs(graph)
graph = ta.Graph()
graph.define_vertex_type('Employee')
graph.define_edge_type('worksunder', 'Employee', 'Employee', directed=False)
graph.vertices['Employee'].add_vertices(employees_frame, 'Employee', ['Title'])
graph.edges['worksunder'].add_edges(employees_frame,
                                    'Employee',
                                    'Manager', ['Years'],
                                    create_missing_vertices=True)

graph.vertex_count
graph.edge_count
graph.vertices['Employee'].inspect(9)
graph.edges['worksunder'].inspect(20)
Example #5
0
    def test_drop_graph_that_does_not_exist(self):
        graph_name = str(uuid.uuid1()).replace("-", "_")

        self.assertFalse(graph_name in ta.get_graph_names(), graph_name + " should not exist in the list of graphs")

        self.assertEqual(0, ta.drop_graphs(graph_name), "drop_graphs() shouldn't have deleted any graphs")
Example #6
0
#Notice that this is a funny example since managers are also employees!
#Preseuambly Steve the manager and Steve the employee are the same person

#Option 1

graph = ta.Graph()
graph.define_vertex_type('Employee')
graph.define_edge_type('worksunder', 'Employee', 'Employee', directed=False)
graph.vertices['Employee'].add_vertices(employees_frame, 'Manager', [])
graph.vertices['Employee'].add_vertices(employees_frame, 'Employee', ['Title'])
graph.edges['worksunder'].add_edges(employees_frame, 'Employee', 'Manager', ['Years'])

graph.vertex_count
graph.edge_count
graph.vertices['Employee'].inspect(9)
graph.edges['worksunder'].inspect(20)

#Option 2

ta.drop_graphs(graph)
graph = ta.Graph()
graph.define_vertex_type('Employee')
graph.define_edge_type('worksunder', 'Employee', 'Employee', directed=False)
graph.vertices['Employee'].add_vertices(employees_frame, 'Employee', ['Title'])
graph.edges['worksunder'].add_edges(employees_frame, 'Employee', 'Manager', ['Years'], create_missing_vertices = True)

graph.vertex_count
graph.edge_count
graph.vertices['Employee'].inspect(9)
graph.edges['worksunder'].inspect(20)