当前位置: 首页>>代码示例>>Python>>正文


Python arango.Arango类代码示例

本文整理汇总了Python中arango.Arango的典型用法代码示例。如果您正苦于以下问题:Python Arango类的具体用法?Python Arango怎么用?Python Arango使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Arango类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BatchRequestTest

class BatchRequestTest(unittest.TestCase):

    def setUp(self):
        self.arango = Arango()
        self.db_name = get_next_db_name(self.arango)
        self.db = self.arango.add_database(self.db_name)
        self.col_name01 = get_next_col_name(self.db)
        self.col01 = self.db.add_collection(self.col_name01)
        self.col_name02 = get_next_col_name(self.db)
        self.col02 = self.db.add_collection(self.col_name02)

    def tearDown(self):
        self.arango.remove_database(self.db_name)

    def test_execute_transaction(self):
        action = """
            function () {
                var db = require('internal').db;
                db.%s.save({ _key: 'doc01'});
                db.%s.save({ _key: 'doc02'});
                return 'success!';
            }
        """ % (self.col_name01, self.col_name02)

        res = self.db.execute_transaction(
            action=action,
            read_collections=[self.col_name01, self.col_name02],
            write_collections=[self.col_name01, self.col_name02],
            wait_for_sync=True,
            lock_timeout=10000
        )
        self.assertEqual(res, "success!")
        self.assertIn("doc01", self.col01)
        self.assertIn("doc02", self.col02)
开发者ID:avinash240,项目名称:py-arango,代码行数:34,代码来源:test_transaction.py

示例2: __init__

	def __init__(self):
		conn = Arango(host="localhost", port=8529)
		ilanlar=conn.db("ilanlar")
		collections=ilanlar.collections
		self.jobtitles = ilanlar.collection("jobtitles")
		self.ads = ilanlar.collection("ads")
		self.sites = ilanlar.collection("sites")
		self.my_graph = ilanlar.graph("my_graph")
		"""self.my_graph.create_vertex_collection("jobtitles")
开发者ID:tansuaksan,项目名称:ScrapingThingsFromWeb,代码行数:9,代码来源:pipelines.py

示例3: AQLFunctionManagementTest

class AQLFunctionManagementTest(unittest.TestCase):

    def setUp(self):
        self.arango = Arango()
        self.db_name = get_next_db_name(self.arango)
        self.db = self.arango.add_database(self.db_name)

    def tearDown(self):
        self.arango.remove_database(self.db_name)

    def test_add_valid_aql_function(self):
        self.db.add_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
            "function (celsius) { return celsius * 1.8 + 32; }"
        )
        self.assertEqual(
            self.db.aql_functions,
            {
                "myfunctions::temperature::celsiustofahrenheit": (
                    "function (celsius) { return celsius * 1.8 + 32; }"
                )
            }
        )

    def test_add_invalid_aql_function(self):
        self.assertRaises(
            AQLFunctionAddError,
            self.db.add_aql_function,
            "myfunctions::temperature::celsiustofahrenheit",
            "function (celsius) { invalid syntax }"
        )

    def test_remove_aql_function(self):
        self.db.add_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
            "function (celsius) { return celsius * 1.8 + 32; }"
        )
        self.db.remove_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
        )
        self.assertEqual(self.db.aql_functions, {})

    # TODO create functions within function
    def test_remove_aql_functions_by_group(self):
        self.db.add_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
            "function (celsius) { return celsius * 1.8 + 32; }"
        )
        self.db.remove_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
            group=True
        )
        self.assertEqual(self.db.aql_functions, {})
开发者ID:avinash240,项目名称:py-arango,代码行数:53,代码来源:test_aql_functions.py

示例4: MonitoringTest

class MonitoringTest(unittest.TestCase):

    def setUp(self):
        self.arango = Arango()

    def test_get_log(self):
        self.arango.get_log()

    def test_get_statistics(self):
        self.arango.statistics
        self.arango.statistics_description

    def test_get_server_role(self):
        self.arango.server_role
开发者ID:allanino,项目名称:python-arango,代码行数:14,代码来源:test_monitoring.py

示例5: setUp

    def setUp(self):
        self.arango = Arango()
        self.username = generate_user_name(self.arango)

        # Test user cleanup
        self.addCleanup(self.arango.delete_user,
                        username=self.username, safe_delete=True)
开发者ID:allanino,项目名称:python-arango,代码行数:7,代码来源:test_users.py

示例6: setUp

    def setUp(self):
        self.arango = Arango()
        self.db_name = get_next_db_name(self.arango)

        # Test database cleaup
        self.addCleanup(self.arango.delete_database,
                        name=self.db_name, safe_delete=True)
开发者ID:zopyx,项目名称:python-arango,代码行数:7,代码来源:test_databases.py

示例7: setUp

 def setUp(self):
     self.arango = Arango()
     self.db_name = get_next_db_name(self.arango)
     self.db = self.arango.create_database(self.db_name)
     self.col_name = get_next_col_name(self.db)
     self.col = self.db.create_collection(self.col_name)
     # Create the vertex collection
     self.vertex_col_name = get_next_col_name(self.db)
     self.vertex_col = self.db.create_collection(self.vertex_col_name)
     # Create the edge collection
     self.edge_col_name = get_next_col_name(self.db)
     self.edge_col = self.db.create_collection(
         self.edge_col_name, is_edge=True
     )
     # Create the graph
     self.graph_name = get_next_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 cleaup
     self.addCleanup(self.arango.delete_database,
                     name=self.db_name, safe_delete=True)
开发者ID:zopyx,项目名称:python-arango,代码行数:27,代码来源:test_vertexes.py

示例8: setUp

    def setUp(self):
        self.arango = Arango()
        self.db_name = generate_db_name(self.arango)
        self.db = self.arango.create_database(self.db_name)

        # Test database cleanup
        self.addCleanup(self.arango.delete_database,
                        name=self.db_name, safe_delete=True)
开发者ID:allanino,项目名称:python-arango,代码行数:8,代码来源:test_graphs.py

示例9: setUp

 def setUp(self):
     self.arango = Arango()
     self.db_name = get_next_db_name(self.arango)
     self.db = self.arango.add_database(self.db_name)
     self.col_name01 = get_next_col_name(self.db)
     self.col01 = self.db.add_collection(self.col_name01)
     self.col_name02 = get_next_col_name(self.db)
     self.col02 = self.db.add_collection(self.col_name02)
开发者ID:avinash240,项目名称:py-arango,代码行数:8,代码来源:test_transaction.py

示例10: DatabaseManagementTest

class DatabaseManagementTest(unittest.TestCase):
    """Tests for managing ArangoDB databases."""

    def setUp(self):
        self.arango = Arango()
        self.db_name = get_next_db_name(self.arango)

        # Test database cleaup
        self.addCleanup(self.arango.delete_database,
                        name=self.db_name, safe_delete=True)

    def test_database_create_and_delete(self):
        self.arango.create_database(self.db_name)
        self.assertIn(self.db_name, self.arango.databases["all"])

        # Check the properties of the new database
        self.assertEqual(self.arango.database(self.db_name).name,
                         self.db_name)
        self.assertEqual(self.arango.database(self.db_name).is_system, False)

        # Delete the test database
        self.arango.delete_database(self.db_name)
        self.assertNotIn(self.db_name, self.arango.databases["all"])

    def test_database_properties(self):
        db = self.arango.database("_system")
        self.assertEqual(db.name, "_system")
        self.assertTrue(isinstance(db.properties, dict))
        self.assertTrue(is_string(db.id))
        self.assertTrue(is_string(db.path))
        self.assertEqual(db.is_system, True)
开发者ID:zopyx,项目名称:python-arango,代码行数:31,代码来源:test_databases.py

示例11: setUp

 def setUp(self):
     self.arango = Arango()
     self.db_name = get_next_db_name(self.arango)
     self.db = self.arango.add_database(self.db_name)
     self.col_name = get_next_col_name(self.db)
     self.col = self.db.add_collection(self.col_name)
     self.col.add_geo_index(["coord"])
     self.col.add_skiplist_index(["value"])
     self.col.add_fulltext_index(["text"])
开发者ID:avinash240,项目名称:py-arango,代码行数:9,代码来源:test_document.py

示例12: setUp

    def setUp(self):
        self.arango = Arango()
        self.db_name = get_next_db_name(self.arango)
        self.db = self.arango.create_database(self.db_name)
        self.col_name = get_next_col_name(self.db)
        self.col = self.db.create_collection(self.col_name)

        # Test database cleaup
        self.addCleanup(self.arango.delete_database, name=self.db_name, safe_delete=True)
开发者ID:zopyx,项目名称:python-arango,代码行数:9,代码来源:test_indexes.py

示例13: AQLFunctionManagementTest

class AQLFunctionManagementTest(unittest.TestCase):
    """Tests for ArangoDB AQL functions."""

    def setUp(self):
        self.arango = Arango()
        self.db_name = get_next_db_name(self.arango)
        self.db = self.arango.create_database(self.db_name)

        # Test database cleaup
        self.addCleanup(self.arango.delete_database,
                        name=self.db_name, safe_delete=True)

    def test_create_valid_aql_function(self):
        self.db.create_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
            "function (celsius) { return celsius * 1.8 + 32; }"
        )
        self.assertEqual(
            self.db.aql_functions,
            {
                "myfunctions::temperature::celsiustofahrenheit": (
                    "function (celsius) { return celsius * 1.8 + 32; }"
                )
            }
        )

    def test_create_invalid_aql_function(self):
        self.assertRaises(
            AQLFunctionCreateError,
            self.db.create_aql_function,
            "myfunctions::temperature::celsiustofahrenheit",
            "function (celsius) { invalid syntax }"
        )

    def test_delete_aql_function(self):
        self.db.create_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
            "function (celsius) { return celsius * 1.8 + 32; }"
        )
        self.db.delete_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
        )
        self.assertEqual(self.db.aql_functions, {})

    # TODO create functions within function
    def test_delete_aql_functions_by_group(self):
        self.db.create_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
            "function (celsius) { return celsius * 1.8 + 32; }"
        )
        self.db.delete_aql_function(
            "myfunctions::temperature::celsiustofahrenheit",
            group=True
        )
        self.assertEqual(self.db.aql_functions, {})
开发者ID:zopyx,项目名称:python-arango,代码行数:55,代码来源:test_aql_functions.py

示例14: setUp

    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)
开发者ID:allanino,项目名称:python-arango,代码行数:12,代码来源:test_transactions.py

示例15: DatabaseManagementTest

class DatabaseManagementTest(unittest.TestCase):

    def setUp(self):
        self.arango = Arango()

    def test_database_add_and_remove(self):
        db_name = get_next_db_name(self.arango)
        self.arango.add_database(db_name)
        self.assertIn(db_name, self.arango.databases["all"])

        # Check the properties of the new database
        self.assertEqual(self.arango.db(db_name).name, db_name)
        self.assertEqual(self.arango.db(db_name).is_system, False)

        # Remove the test database
        self.arango.remove_database(db_name)
        self.assertNotIn(db_name, self.arango.databases["all"])

    def test_database_properties(self):
        db = self.arango.database("_system")
        self.assertEqual(db.name, "_system")
        self.assertTrue(isinstance(db.properties, dict))
        self.assertTrue(is_string(db.id))
        self.assertTrue(is_string(db.path))
        self.assertEqual(db.is_system, True)
开发者ID:avinash240,项目名称:py-arango,代码行数:25,代码来源:test_database.py


注:本文中的arango.Arango类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。