mirror of https://gitee.com/bigwinds/arangodb
Added tests for vertex and edge collection lists in http interface. Added docu for _list in general-graph module
This commit is contained in:
parent
7541149200
commit
fdece972d0
|
@ -28,6 +28,11 @@ def edge_endpoint(graph_name, collection)
|
||||||
return URLPREFIX + "/" + graph_name + "/edge/" + collection
|
return URLPREFIX + "/" + graph_name + "/edge/" + collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def list_edge_collections (graph_name)
|
||||||
|
cmd = URLPREFIX + "/" + graph_name + "/edge"
|
||||||
|
doc = ArangoDB.get(cmd)
|
||||||
|
return doc
|
||||||
|
end
|
||||||
|
|
||||||
def additional_edge_definition (graph_name, edge_definitions)
|
def additional_edge_definition (graph_name, edge_definitions)
|
||||||
cmd = URLPREFIX + "/" + graph_name + "/edge"
|
cmd = URLPREFIX + "/" + graph_name + "/edge"
|
||||||
|
@ -47,6 +52,12 @@ def delete_edge_definition (graph_name, definition_name)
|
||||||
return doc
|
return doc
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def list_vertex_collections (graph_name)
|
||||||
|
cmd = URLPREFIX + "/" + graph_name + "/vertex"
|
||||||
|
doc = ArangoDB.get(cmd)
|
||||||
|
return doc
|
||||||
|
end
|
||||||
|
|
||||||
def additional_vertex_collection (graph_name, collection_name)
|
def additional_vertex_collection (graph_name, collection_name)
|
||||||
cmd = URLPREFIX + "/" + graph_name + "/vertex"
|
cmd = URLPREFIX + "/" + graph_name + "/vertex"
|
||||||
body = { :collection => collection_name }
|
body = { :collection => collection_name }
|
||||||
|
@ -286,6 +297,30 @@ describe ArangoDB do
|
||||||
doc.parsed_response['error'].should eq("graph already exists")
|
doc.parsed_response['error'].should eq("graph already exists")
|
||||||
doc.parsed_response['code'].should eq(409)
|
doc.parsed_response['code'].should eq(409)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "can get a list of vertex collections" do
|
||||||
|
definition = { "collection" => friend_collection, "from" => [user_collection], "to" => [user_collection] }
|
||||||
|
create_graph(graph_name, [definition])
|
||||||
|
additional_vertex_collection(graph_name, product_collection)
|
||||||
|
|
||||||
|
doc = list_vertex_collections(graph_name)
|
||||||
|
doc.code.should eq(200)
|
||||||
|
doc.parsed_response['error'].should eq(false)
|
||||||
|
doc.parsed_response['code'].should eq(200)
|
||||||
|
doc.parsed_response['collections'].should eq([product_collection, user_collection])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can get a list of edge collections" do
|
||||||
|
definition1 = { "collection" => friend_collection, "from" => [user_collection], "to" => [user_collection] }
|
||||||
|
definition2 = { "collection" => bought_collection, "from" => [user_collection], "to" => [product_collection] }
|
||||||
|
create_graph(graph_name, [definition1, definition2])
|
||||||
|
|
||||||
|
doc = list_edge_collections(graph_name)
|
||||||
|
doc.code.should eq(200)
|
||||||
|
doc.parsed_response['error'].should eq(false)
|
||||||
|
doc.parsed_response['code'].should eq(200)
|
||||||
|
doc.parsed_response['collections'].should eq([bought_collection, friend_collection])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "check vertex operations" do
|
context "check vertex operations" do
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
var g = Graph._graph(name);
|
var g = Graph._graph(name);
|
||||||
setResponse(res, "collections", _.map(g._vertexCollections(), function(c) {
|
setResponse(res, "collections", _.map(g._vertexCollections(), function(c) {
|
||||||
return c.name();
|
return c.name();
|
||||||
}));
|
}).sort());
|
||||||
})
|
})
|
||||||
.pathParam("graph", {
|
.pathParam("graph", {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
@ -206,7 +206,7 @@
|
||||||
var g = Graph._graph(name);
|
var g = Graph._graph(name);
|
||||||
setResponse(res, "collections", _.map(g._edgeCollections(), function(c) {
|
setResponse(res, "collections", _.map(g._edgeCollections(), function(c) {
|
||||||
return c.name();
|
return c.name();
|
||||||
}));
|
}).sort());
|
||||||
})
|
})
|
||||||
.pathParam("graph", {
|
.pathParam("graph", {
|
||||||
type: "string",
|
type: "string",
|
||||||
|
|
|
@ -1403,7 +1403,20 @@ var _directedRelationDefinition = function (
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief create a list of all graph names
|
/// @startDocuBlock JSF_general_graph_list
|
||||||
|
///
|
||||||
|
/// `general-graph._list()`
|
||||||
|
/// *List all graphs.*
|
||||||
|
///
|
||||||
|
/// Lists all graph names stored in this database.
|
||||||
|
///
|
||||||
|
/// @EXAMPLES
|
||||||
|
///
|
||||||
|
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDirectedRelationDefinition}
|
||||||
|
/// var graph = require("org/arangodb/general-graph");
|
||||||
|
/// graph._list();
|
||||||
|
/// @END_EXAMPLE_ARANGOSH_OUTPUT
|
||||||
|
/// @endDocuBlock
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var _list = function() {
|
var _list = function() {
|
||||||
|
|
Loading…
Reference in New Issue