def test_create_and_delete_edge_definition(self): # Create the edge and vertex collections vertex_col_name = generate_col_name(self.db) self.db.create_collection(vertex_col_name) edge_col_name = generate_col_name(self.db) self.db.create_collection(edge_col_name, is_edge=True) # Create the graph graph_name = generate_graph_name(self.db) graph = self.db.create_graph(graph_name) # Create the edge definition to the graph edge_definition = { "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] } graph.create_edge_definition( edge_col_name, [vertex_col_name], [vertex_col_name] ) self.assertEqual( graph.edge_definitions, [edge_definition] ) graph.delete_edge_definition( edge_col_name, drop_collection=True ) self.assertEqual(graph.edge_definitions, []) self.assertNotIn(edge_col_name, self.db.collections["all"])
def setUp(self): self.arango = Arango() self.db_name = generate_db_name(self.arango) self.db = self.arango.create_database(self.db_name) self.col_name = generate_col_name(self.db) self.col = self.db.create_collection(self.col_name) # Create the vertex collection self.vertex_col_name = generate_col_name(self.db) self.vertex_col = self.db.create_collection(self.vertex_col_name) # Create the edge collection self.edge_col_name = generate_col_name(self.db) self.edge_col = self.db.create_collection(self.edge_col_name, is_edge=True) # Create the graph self.graph_name = generate_graph_name(self.db) self.graph = self.db.create_graph( name=self.graph_name, edge_definitions=[{ "collection": self.edge_col_name, "from": [self.vertex_col_name], "to": [self.vertex_col_name] }], ) # Test database cleanup self.addCleanup(self.arango.delete_database, name=self.db_name, safe_delete=True)
def setUp(self): self.arango = Arango() self.db_name = generate_db_name(self.arango) self.db = self.arango.create_database(self.db_name) self.col_name = generate_col_name(self.db) self.col = self.db.create_collection(self.col_name) # Create the vertex collection self.vertex_col_name = generate_col_name(self.db) self.vertex_col = self.db.create_collection(self.vertex_col_name) # Create the edge collection self.edge_col_name = generate_col_name(self.db) self.edge_col = self.db.create_collection( self.edge_col_name, is_edge=True ) # Create the graph self.graph_name = generate_graph_name(self.db) self.graph = self.db.create_graph( name=self.graph_name, edge_definitions=[{ "collection": self.edge_col_name, "from": [self.vertex_col_name], "to": [self.vertex_col_name] }], ) # Test database cleanup self.addCleanup(self.arango.delete_database, name=self.db_name, safe_delete=True)
def test_delete_graph(self): # Create a new collection graph_name = generate_graph_name(self.db) self.db.create_graph(graph_name) self.assertIn(graph_name, self.db.graphs) # Delete the collection and ensure that it's gone self.db.delete_graph(graph_name) self.assertNotIn(graph_name, self.db.graphs)
def test_create_graph_with_defined_cols(self): # Create the orphan collection orphan_col_name = generate_col_name(self.db) self.db.create_collection(orphan_col_name) # Create the vertex collection vertex_col_name = generate_col_name(self.db) self.db.create_collection(vertex_col_name) # Create the edge collection edge_col_name = generate_col_name(self.db) self.db.create_collection(edge_col_name, is_edge=True) # Create the graph graph_name = generate_graph_name(self.db) graph = self.db.create_graph( name=graph_name, edge_definitions=[{ "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] }], orphan_collections=[orphan_col_name] ) self.assertIn(graph_name, self.db.graphs) self.assertEqual( graph.orphan_collections, [orphan_col_name] ) self.assertEqual( graph.edge_definitions, [{ "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] }] ) self.assertEqual( sorted(graph.vertex_collections), sorted([orphan_col_name, vertex_col_name]) ) properties = graph.properties del properties["_rev"] del properties["_id"] self.assertEqual( properties, { "name": graph_name, "edge_definitions": [ { "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] } ], "orphan_collections": [orphan_col_name] } )
def setUp(self): # Create the test database self.arango = Arango() self.db_name = generate_db_name(self.arango) self.db = self.arango.create_database(self.db_name) # Create the test vertex collection self.vertex_col_name = generate_col_name(self.db) self.vertex_col = self.db.create_collection(self.vertex_col_name) # Create the test edge collection self.edge_col_name = generate_col_name(self.db) self.edge_col = self.db.create_collection( self.edge_col_name, is_edge=True ) # Create the test graph self.graph_name = generate_graph_name(self.db) self.graph = self.db.create_graph( name=self.graph_name, edge_definitions=[{ "collection": self.edge_col_name, "from": [self.vertex_col_name], "to": [self.vertex_col_name] }], ) # Create a few test vertices self.graph.create_vertex( self.vertex_col_name, data={ "_key": "vertex01", "value": 1 } ) self.graph.create_vertex( self.vertex_col_name, data={ "_key": "vertex02", "value": 1 } ) self.graph.create_vertex( self.vertex_col_name, data={ "_key": "vertex03", "value": 1 } ) # Test database cleanup self.addCleanup(self.arango.delete_database, name=self.db_name, safe_delete=True)
def test_replace_edge_definition(self): # Create edge and vertex collection set 1 vertex_col_name = generate_col_name(self.db) self.db.create_collection(vertex_col_name) edge_col_name = generate_col_name(self.db) self.db.create_collection(edge_col_name, is_edge=True) # Create edge and vertex collection set 2 vertex_col_name_2 = generate_col_name(self.db) self.db.create_collection(vertex_col_name_2) edge_col_name_2 = generate_col_name(self.db) self.db.create_collection(edge_col_name_2, is_edge=True) # Create the graph graph_name = generate_graph_name(self.db) graph = self.db.create_graph(graph_name) # Create the edge definition to the graph edge_definition = { "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] } graph.create_edge_definition( edge_col_name, [vertex_col_name], [vertex_col_name] ) self.assertEqual( graph.edge_definitions, [edge_definition] ) # Replace the edge definition 1 with 2 edge_definition_2 = { "collection": edge_col_name, "from": [vertex_col_name_2], "to": [vertex_col_name_2] } graph.replace_edge_definition( edge_col_name, [vertex_col_name_2], [vertex_col_name_2] ) self.assertEqual( graph.edge_definitions, [edge_definition_2] )
def test_create_and_delete_vertex_collection(self): # Create the vertex collection vertex_col_name = generate_col_name(self.db) self.db.create_collection(vertex_col_name) # Create the graph graph_name = generate_graph_name(self.db) graph = self.db.create_graph(graph_name) self.assertIn(graph_name, self.db.graphs) self.assertEqual(graph.vertex_collections, []) # Create the vertex collection to the graph graph.create_vertex_collection(vertex_col_name) self.assertEqual(graph.vertex_collections, [vertex_col_name]) # Delete the vertex collection (completely) graph.delete_vertex_collection(vertex_col_name, drop_collection=True) self.assertEqual(graph.vertex_collections, []) self.assertNotIn(vertex_col_name, self.db.collections["all"])
def test_create_graph_with_defined_cols(self): # Create the orphan collection orphan_col_name = generate_col_name(self.db) self.db.create_collection(orphan_col_name) # Create the vertex collection vertex_col_name = generate_col_name(self.db) self.db.create_collection(vertex_col_name) # Create the edge collection edge_col_name = generate_col_name(self.db) self.db.create_collection(edge_col_name, is_edge=True) # Create the graph graph_name = generate_graph_name(self.db) graph = self.db.create_graph(name=graph_name, edge_definitions=[{ "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] }], orphan_collections=[orphan_col_name]) self.assertIn(graph_name, self.db.graphs) self.assertEqual(graph.orphan_collections, [orphan_col_name]) self.assertEqual(graph.edge_definitions, [{ "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] }]) self.assertEqual(sorted(graph.vertex_collections), sorted([orphan_col_name, vertex_col_name])) properties = graph.properties del properties["_rev"] del properties["_id"] self.assertEqual( properties, { "name": graph_name, "edge_definitions": [{ "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] }], "orphan_collections": [orphan_col_name] })
def setUp(self): # Create the test database self.arango = Arango() self.db_name = generate_db_name(self.arango) self.db = self.arango.create_database(self.db_name) # Create the test vertex collection self.vertex_col_name = generate_col_name(self.db) self.vertex_col = self.db.create_collection(self.vertex_col_name) # Create the test edge collection self.edge_col_name = generate_col_name(self.db) self.edge_col = self.db.create_collection(self.edge_col_name, is_edge=True) # Create the test graph self.graph_name = generate_graph_name(self.db) self.graph = self.db.create_graph( name=self.graph_name, edge_definitions=[{ "collection": self.edge_col_name, "from": [self.vertex_col_name], "to": [self.vertex_col_name] }], ) # Create a few test vertices self.graph.create_vertex(self.vertex_col_name, data={ "_key": "vertex01", "value": 1 }) self.graph.create_vertex(self.vertex_col_name, data={ "_key": "vertex02", "value": 1 }) self.graph.create_vertex(self.vertex_col_name, data={ "_key": "vertex03", "value": 1 }) # Test database cleanup self.addCleanup(self.arango.delete_database, name=self.db_name, safe_delete=True)
def test_create_and_delete_edge_definition(self): # Create the edge and vertex collections vertex_col_name = generate_col_name(self.db) self.db.create_collection(vertex_col_name) edge_col_name = generate_col_name(self.db) self.db.create_collection(edge_col_name, is_edge=True) # Create the graph graph_name = generate_graph_name(self.db) graph = self.db.create_graph(graph_name) # Create the edge definition to the graph edge_definition = { "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] } graph.create_edge_definition(edge_col_name, [vertex_col_name], [vertex_col_name]) self.assertEqual(graph.edge_definitions, [edge_definition]) graph.delete_edge_definition(edge_col_name, drop_collection=True) self.assertEqual(graph.edge_definitions, []) self.assertNotIn(edge_col_name, self.db.collections["all"])
def test_create_and_delete_vertex_collection(self): # Create the vertex collection vertex_col_name = generate_col_name(self.db) self.db.create_collection(vertex_col_name) # Create the graph graph_name = generate_graph_name(self.db) graph = self.db.create_graph(graph_name) self.assertIn(graph_name, self.db.graphs) self.assertEqual(graph.vertex_collections, []) # Create the vertex collection to the graph graph.create_vertex_collection(vertex_col_name) self.assertEqual( graph.vertex_collections, [vertex_col_name] ) # Delete the vertex collection (completely) graph.delete_vertex_collection( vertex_col_name, drop_collection=True ) self.assertEqual(graph.vertex_collections, []) self.assertNotIn(vertex_col_name, self.db.collections["all"])
def test_replace_edge_definition(self): # Create edge and vertex collection set 1 vertex_col_name = generate_col_name(self.db) self.db.create_collection(vertex_col_name) edge_col_name = generate_col_name(self.db) self.db.create_collection(edge_col_name, is_edge=True) # Create edge and vertex collection set 2 vertex_col_name_2 = generate_col_name(self.db) self.db.create_collection(vertex_col_name_2) edge_col_name_2 = generate_col_name(self.db) self.db.create_collection(edge_col_name_2, is_edge=True) # Create the graph graph_name = generate_graph_name(self.db) graph = self.db.create_graph(graph_name) # Create the edge definition to the graph edge_definition = { "collection": edge_col_name, "from": [vertex_col_name], "to": [vertex_col_name] } graph.create_edge_definition(edge_col_name, [vertex_col_name], [vertex_col_name]) self.assertEqual(graph.edge_definitions, [edge_definition]) # Replace the edge definition 1 with 2 edge_definition_2 = { "collection": edge_col_name, "from": [vertex_col_name_2], "to": [vertex_col_name_2] } graph.replace_edge_definition(edge_col_name, [vertex_col_name_2], [vertex_col_name_2]) self.assertEqual(graph.edge_definitions, [edge_definition_2])
def setUp(self): # Create the test database self.arango = Arango() self.db_name = generate_db_name(self.arango) self.db = self.arango.create_database(self.db_name) # Create the test vertex "from" collection self.from_col_name = generate_col_name(self.db) self.from_col = self.db.create_collection(self.from_col_name) # Create the test vertex "to" collection self.to_col_name = generate_col_name(self.db) self.to_col = self.db.create_collection(self.to_col_name) # Create the test edge collection self.edge_col_name = generate_col_name(self.db) self.edge_col = self.db.create_collection( self.edge_col_name, is_edge=True ) # Create the test graph self.graph_name = generate_graph_name(self.db) self.graph = self.db.create_graph( name=self.graph_name, edge_definitions=[{ "collection": self.edge_col_name, "from": [self.from_col_name], "to": [self.to_col_name] }], ) # Create a few test "from" vertices self.graph.create_vertex( self.from_col_name, data={"_key": "from01", "value": 1} ) self.graph.create_vertex( self.from_col_name, data={"_key": "from02", "value": 2} ) # Create a few test "to" vertices self.graph.create_vertex( self.to_col_name, data={"_key": "to01", "value": 1} ) self.graph.create_vertex( self.to_col_name, data={"_key": "to02", "value": 2} ) self.graph.create_vertex( self.to_col_name, data={"_key": "to03", "value": 3} ) # Create a few test edges self.graph.create_edge( self.edge_col_name, { "_from": "{}/{}".format(self.from_col_name, "from01"), "_to": "{}/{}".format(self.to_col_name, "to01"), } ) self.graph.create_edge( self.edge_col_name, { "_from": "{}/{}".format(self.from_col_name, "from02"), "_to": "{}/{}".format(self.to_col_name, "to02"), } ) self.graph.create_edge( self.edge_col_name, { "_from": "{}/{}".format(self.from_col_name, "from02"), "_to": "{}/{}".format(self.to_col_name, "to03"), } ) # Test database cleanup self.addCleanup(self.arango.delete_database, name=self.db_name, safe_delete=True)
def test_create_graph(self): graph_name = generate_graph_name(self.db) self.db.create_graph(graph_name) self.assertIn(graph_name, self.db.graphs)
def setUp(self): # Create the test database self.arango = Arango() self.db_name = generate_db_name(self.arango) self.db = self.arango.create_database(self.db_name) # Create the test vertex "from" collection self.from_col_name = generate_col_name(self.db) self.from_col = self.db.create_collection(self.from_col_name) # Create the test vertex "to" collection self.to_col_name = generate_col_name(self.db) self.to_col = self.db.create_collection(self.to_col_name) # Create the test edge collection self.edge_col_name = generate_col_name(self.db) self.edge_col = self.db.create_collection(self.edge_col_name, is_edge=True) # Create the test graph self.graph_name = generate_graph_name(self.db) self.graph = self.db.create_graph( name=self.graph_name, edge_definitions=[{ "collection": self.edge_col_name, "from": [self.from_col_name], "to": [self.to_col_name] }], ) # Create a few test "from" vertices self.graph.create_vertex(self.from_col_name, data={ "_key": "from01", "value": 1 }) self.graph.create_vertex(self.from_col_name, data={ "_key": "from02", "value": 2 }) # Create a few test "to" vertices self.graph.create_vertex(self.to_col_name, data={ "_key": "to01", "value": 1 }) self.graph.create_vertex(self.to_col_name, data={ "_key": "to02", "value": 2 }) self.graph.create_vertex(self.to_col_name, data={ "_key": "to03", "value": 3 }) # Create a few test edges self.graph.create_edge( self.edge_col_name, { "_from": "{}/{}".format(self.from_col_name, "from01"), "_to": "{}/{}".format(self.to_col_name, "to01"), }) self.graph.create_edge( self.edge_col_name, { "_from": "{}/{}".format(self.from_col_name, "from02"), "_to": "{}/{}".format(self.to_col_name, "to02"), }) self.graph.create_edge( self.edge_col_name, { "_from": "{}/{}".format(self.from_col_name, "from02"), "_to": "{}/{}".format(self.to_col_name, "to03"), }) # Test database cleanup self.addCleanup(self.arango.delete_database, name=self.db_name, safe_delete=True)