本文整理汇总了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)
示例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")
示例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, {})
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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"])
示例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)
示例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, {})
示例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)
示例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)