Esempio n. 1
0
 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)
Esempio n. 4
0
 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):
        self.arango = Arango()
        self.db_name = generate_db_name(self.arango)
        self.db = self.arango.create_database(self.db_name)
        self.col_name01 = generate_col_name(self.db)
        self.col01 = self.db.create_collection(self.col_name01)
        self.col_name02 = generate_col_name(self.db)
        self.col02 = self.db.create_collection(self.col_name02)

        # Test database cleanup
        self.addCleanup(self.arango.delete_database,
                        name=self.db_name, safe_delete=True)
Esempio n. 6
0
 def test_rename_collection(self):
     # Create a new collection
     col_name = generate_col_name(self.db)
     self.db.create_collection(col_name)
     col_id = self.db.collection(col_name).id
     # Rename the collection
     new_col_name = generate_col_name(self.db)
     self.db.rename_collection(col_name, new_col_name)
     self.assertNotIn(col_name, self.db.collections["all"])
     self.assertIn(new_col_name, self.db.collections["all"])
     # Ensure it is the same collection by checking the ID
     self.assertEqual(self.db.collection(new_col_name).id, col_id)
Esempio n. 7
0
 def test_rename_collection(self):
     # Create a new collection
     col_name = generate_col_name(self.db)
     self.db.create_collection(col_name)
     col_id = self.db.collection(col_name).id
     # Rename the collection
     new_col_name = generate_col_name(self.db)
     self.db.rename_collection(col_name, new_col_name)
     self.assertNotIn(col_name, self.db.collections["all"])
     self.assertIn(new_col_name, self.db.collections["all"])
     # Ensure it is the same collection by checking the ID
     self.assertEqual(self.db.collection(new_col_name).id, col_id)
Esempio n. 8
0
    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_name01 = generate_col_name(self.db)
        self.col01 = self.db.create_collection(self.col_name01)
        self.col_name02 = generate_col_name(self.db)
        self.col02 = self.db.create_collection(self.col_name02)

        # Test database cleanup
        self.addCleanup(self.arango.delete_database,
                        name=self.db_name,
                        safe_delete=True)
Esempio n. 9
0
    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)
Esempio n. 10
0
    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]
        )
Esempio n. 11
0
 def test_delete_collection(self):
     # Create a new collection
     col_name = generate_col_name(self.db)
     self.db.create_collection(col_name)
     self.assertIn(col_name, self.db.collections["all"])
     # Delete the collection and ensure that it's gone
     self.db.delete_collection(col_name)
     self.assertNotIn(col_name, self.db.collections)
Esempio n. 12
0
 def test_delete_collection(self):
     # Create a new collection
     col_name = generate_col_name(self.db)
     self.db.create_collection(col_name)
     self.assertIn(col_name, self.db.collections["all"])
     # Delete the collection and ensure that it's gone
     self.db.delete_collection(col_name)
     self.assertNotIn(col_name, self.db.collections)
Esempio n. 13
0
    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)
Esempio n. 14
0
 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]
         })
Esempio n. 15
0
 def test_collection_setters(self):
     # Create a new collection with predefined properties
     col = self.db.create_collection(name=generate_col_name(self.db),
                                     wait_for_sync=False,
                                     journal_size=7774208)
     self.assertFalse(col.wait_for_sync)
     self.assertEqual(col.journal_size, 7774208)
     # Change the properties of the graph and ensure that it went through
     col.wait_for_sync = True
     col.journal_size = 8884208
     self.assertTrue(col.wait_for_sync)
     self.assertEqual(col.journal_size, 8884208)
Esempio n. 16
0
 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)
        self.col.create_geo_index(["coord"])
        self.col.create_skiplist_index(["value"])
        self.col.create_fulltext_index(["text"])

        # Test database cleanup
        self.addCleanup(self.arango.delete_database,
                        name=self.db_name, safe_delete=True)
Esempio n. 18
0
    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)
        self.col.create_geo_index(["coord"])
        self.col.create_skiplist_index(["value"])
        self.col.create_fulltext_index(["text"])

        # Test database cleanup
        self.addCleanup(self.arango.delete_database,
                        name=self.db_name,
                        safe_delete=True)
Esempio n. 19
0
 def test_collection_setters(self):
     # Create a new collection with predefined properties
     col = self.db.create_collection(
         name=generate_col_name(self.db),
         wait_for_sync=False,
         journal_size=7774208
     )
     self.assertFalse(col.wait_for_sync)
     self.assertEqual(col.journal_size, 7774208)
     # Change the properties of the graph and ensure that it went through
     col.wait_for_sync = True
     col.journal_size = 8884208
     self.assertTrue(col.wait_for_sync)
     self.assertEqual(col.journal_size, 8884208)
Esempio n. 20
0
    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])
Esempio n. 21
0
 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"])
Esempio n. 22
0
 def test_collection_create_with_config(self):
     # Create a new collection with custom defined properties
     col_name = generate_col_name(self.db)
     col = self.db.create_collection(
         name=col_name,
         wait_for_sync=True,
         do_compact=False,
         journal_size=7774208,
         is_system=False,
         is_volatile=False,
         key_generator_type="autoincrement",
         allow_user_keys=False,
         key_increment=9,
         key_offset=100,
         is_edge=True,
         number_of_shards=2,
         shard_keys=["test_attr"],
     )
     # Ensure that the new collection's properties are set correctly
     self.assertEqual(col.name, col_name)
     self.assertTrue(col.revision, "0")
     self.assertEqual(col.status, "loaded")
     self.assertEqual(col.journal_size, 7774208)
     self.assertEqual(col.checksum(), 0)
     self.assertEqual(
         col.key_options,
         {
             "allow_user_keys": False,
             "increment": 9,
             "offset": 100,
             "type": "autoincrement"
         }
     )
     self.assertFalse(col.is_system)
     self.assertFalse(col.is_volatile)
     self.assertFalse(col.is_compacted)
     self.assertTrue(col.wait_for_sync)
     self.assertTrue(col.is_edge)
     self.assertTrue(is_string(col.id))
     self.assertTrue(isinstance(col.statistics, dict))
Esempio n. 23
0
 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"])
Esempio n. 24
0
 def test_collection_create_with_config(self):
     # Create a new collection with custom defined properties
     col_name = generate_col_name(self.db)
     col = self.db.create_collection(
         name=col_name,
         wait_for_sync=True,
         do_compact=False,
         journal_size=7774208,
         is_system=False,
         is_volatile=False,
         key_generator_type="autoincrement",
         allow_user_keys=False,
         key_increment=9,
         key_offset=100,
         is_edge=True,
         number_of_shards=2,
         shard_keys=["test_attr"],
     )
     # Ensure that the new collection's properties are set correctly
     self.assertEqual(col.name, col_name)
     self.assertTrue(col.revision, "0")
     self.assertEqual(col.status, "loaded")
     self.assertEqual(col.journal_size, 7774208)
     self.assertEqual(col.checksum(), 0)
     self.assertEqual(
         col.key_options, {
             "allow_user_keys": False,
             "increment": 9,
             "offset": 100,
             "type": "autoincrement"
         })
     self.assertFalse(col.is_system)
     self.assertFalse(col.is_volatile)
     self.assertFalse(col.is_compacted)
     self.assertTrue(col.wait_for_sync)
     self.assertTrue(col.is_edge)
     self.assertTrue(is_string(col.id))
     self.assertTrue(isinstance(col.statistics, dict))
Esempio n. 25
0
 def test_collection_load_unload(self):
     col = self.db.create_collection(generate_col_name(self.db))
     self.assertIn(col.unload(), {"unloaded", "unloading"})
     self.assertIn(col.load(), {"loaded", "loading"})
Esempio n. 26
0
 def test_create_collection(self):
     col_name = generate_col_name(self.db)
     self.db.create_collection(col_name)
     self.assertIn(col_name, self.db.collections["all"])
Esempio n. 27
0
    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)
Esempio n. 28
0
    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)
Esempio n. 29
0
 def test_collection_load_unload(self):
     col = self.db.create_collection(generate_col_name(self.db))
     self.assertIn(col.unload(), {"unloaded", "unloading"})
     self.assertIn(col.load(), {"loaded", "loading"})
Esempio n. 30
0
 def test_collection_rotate_journal(self):
     col = self.db.create_collection(generate_col_name(self.db))
     self.assertRaises(CollectionRotateJournalError, col.rotate_journal)
Esempio n. 31
0
 def test_create_collection(self):
     col_name = generate_col_name(self.db)
     self.db.create_collection(col_name)
     self.assertIn(col_name, self.db.collections["all"])
Esempio n. 32
0
 def test_collection_rotate_journal(self):
     col = self.db.create_collection(generate_col_name(self.db))
     self.assertRaises(
         CollectionRotateJournalError,
         col.rotate_journal
     )