當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。