keymaker 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +71 -11
- data/Rakefile +1 -1
- data/keymaker.gemspec +46 -15
- data/lib/keymaker.rb +25 -12
- data/lib/keymaker/configuration.rb +4 -0
- data/lib/keymaker/errors.rb +22 -0
- data/lib/keymaker/match_method.rb +24 -0
- data/lib/keymaker/request.rb +2 -1
- data/lib/keymaker/{add_node_to_index_request.rb → requests/add_node_to_index_request.rb} +0 -0
- data/lib/keymaker/requests/batch_get_nodes_request.rb +24 -0
- data/lib/keymaker/requests/batch_request.rb +18 -0
- data/lib/keymaker/{create_node_request.rb → requests/create_node_request.rb} +0 -0
- data/lib/keymaker/{create_relationship_request.rb → requests/create_relationship_request.rb} +0 -0
- data/lib/keymaker/requests/delete_node_request.rb +18 -0
- data/lib/keymaker/{delete_relationship_request.rb → requests/delete_relationship_request.rb} +0 -0
- data/lib/keymaker/{execute_cypher_request.rb → requests/execute_cypher_request.rb} +0 -0
- data/lib/keymaker/{execute_gremlin_request.rb → requests/execute_gremlin_request.rb} +0 -0
- data/lib/keymaker/requests/get_node_request.rb +16 -0
- data/lib/keymaker/requests/get_relationship_types_request.rb +18 -0
- data/lib/keymaker/{path_traverse_request.rb → requests/path_traverse_request.rb} +0 -0
- data/lib/keymaker/{remove_node_from_index_request.rb → requests/remove_node_from_index_request.rb} +0 -0
- data/lib/keymaker/requests/service_root_request.rb +11 -0
- data/lib/keymaker/{update_node_properties_request.rb → requests/update_node_properties_request.rb} +0 -0
- data/lib/keymaker/response.rb +8 -1
- data/lib/keymaker/service.rb +17 -43
- data/spec/cassettes/Keymaker_AddNodeToIndexRequest/returns_a_201_status_code.yml +204 -0
- data/spec/cassettes/Keymaker_AddNodeToIndexRequest/returns_application/json.yml +204 -0
- data/spec/cassettes/Keymaker_AddNodeToIndexRequest/returns_the_Neo4j_REST_API_starting_point_response_request.yml +204 -0
- data/spec/cassettes/Keymaker_BatchRequest/when_a_resource_is_not_found/raises_BatchRequestError.yml +120 -0
- data/spec/cassettes/Keymaker_BatchRequest/when_to_and_method_are_not_set/raises_BatchRequestError.yml +106 -0
- data/spec/cassettes/Keymaker_BatchRequest/with_valid_options/returns_a_200_status_code.yml +129 -0
- data/spec/cassettes/Keymaker_BatchRequest/with_valid_options/runs_the_commands_and_returns_their_respective_results.yml +129 -0
- data/spec/cassettes/Keymaker_GetNodeRequest/with_a_non-existent_node_id/raises_ResourceNotFound.yml +101 -0
- data/spec/cassettes/Keymaker_GetNodeRequest/with_an_empty_node_id/raises_ClientError.yml +111 -0
- data/spec/cassettes/Keymaker_GetRelationshipTypesRequest/with_existing_relationships/returns_a_unique_array_of_relationship_types.yml +220 -0
- data/spec/cassettes/Keymaker_ServiceRootRequest/returns_a_200_status_code.yml +105 -0
- data/spec/cassettes/Keymaker_ServiceRootRequest/returns_application/json.yml +105 -0
- data/spec/cassettes/Keymaker_ServiceRootRequest/returns_the_Neo4j_REST_API_starting_point_response_request.yml +105 -0
- data/spec/{keymaker/configuration_spec.rb → configuration_spec.rb} +0 -0
- data/spec/keymaker/requests/add_node_to_index_request_spec.rb +41 -0
- data/spec/keymaker/requests/batch_get_nodes_request_spec.rb +23 -0
- data/spec/keymaker/requests/batch_request_spec.rb +115 -0
- data/spec/keymaker/requests/delete_node_request_spec.rb +37 -0
- data/spec/keymaker/requests/get_node_request_spec.rb +24 -0
- data/spec/keymaker/requests/get_relationship_types_request_spec.rb +17 -0
- data/spec/keymaker/requests/service_root_request_spec.rb +35 -0
- data/spec/{keymaker/service_spec.rb → service_spec.rb} +0 -0
- data/spec/support/vcr.rb +8 -0
- metadata +116 -19
- data/lib/keymaker/batch_get_nodes_request.rb +0 -19
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:7477/db/data/ext/GremlinPlugin/graphdb/execute_script
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"script":"g.clear();g.V()"}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: !!null
|
16
|
+
headers:
|
17
|
+
content-length:
|
18
|
+
- '3'
|
19
|
+
content-encoding:
|
20
|
+
- UTF-8
|
21
|
+
content-type:
|
22
|
+
- application/json
|
23
|
+
access-control-allow-origin:
|
24
|
+
- ! '*'
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
server:
|
28
|
+
- Jetty(6.1.25)
|
29
|
+
body:
|
30
|
+
encoding: US-ASCII
|
31
|
+
string: ! '[ ]'
|
32
|
+
http_version: !!null
|
33
|
+
recorded_at: Fri, 06 Jul 2012 01:30:16 GMT
|
34
|
+
- request:
|
35
|
+
method: delete
|
36
|
+
uri: http://localhost:7477/db/data/index/node/users
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ''
|
40
|
+
headers: {}
|
41
|
+
response:
|
42
|
+
status:
|
43
|
+
code: 404
|
44
|
+
message: !!null
|
45
|
+
headers:
|
46
|
+
content-length:
|
47
|
+
- '470'
|
48
|
+
content-encoding:
|
49
|
+
- UTF-8
|
50
|
+
content-type:
|
51
|
+
- application/json
|
52
|
+
access-control-allow-origin:
|
53
|
+
- ! '*'
|
54
|
+
connection:
|
55
|
+
- close
|
56
|
+
server:
|
57
|
+
- Jetty(6.1.25)
|
58
|
+
body:
|
59
|
+
encoding: US-ASCII
|
60
|
+
string: ! "{\n \"message\" : \"No node index named 'users'.\",\n \"exception\"
|
61
|
+
: \"org.neo4j.graphdb.NotFoundException: No node index named 'users'.\",\n
|
62
|
+
\ \"stacktrace\" : [ \"org.neo4j.server.rest.web.DatabaseActions.removeNodeIndex(DatabaseActions.java:421)\",
|
63
|
+
\"org.neo4j.server.rest.web.RestfulGraphDatabase.deleteNodeIndex(RestfulGraphDatabase.java:729)\",
|
64
|
+
\"java.lang.reflect.Method.invoke(Method.java:597)\", \"org.neo4j.server.statistic.StatisticFilter.doFilter(StatisticFilter.java:62)\"
|
65
|
+
]\n}"
|
66
|
+
http_version: !!null
|
67
|
+
recorded_at: Fri, 06 Jul 2012 01:30:16 GMT
|
68
|
+
- request:
|
69
|
+
method: get
|
70
|
+
uri: http://localhost:7477/db/data/
|
71
|
+
body:
|
72
|
+
encoding: US-ASCII
|
73
|
+
string: ''
|
74
|
+
headers: {}
|
75
|
+
response:
|
76
|
+
status:
|
77
|
+
code: 200
|
78
|
+
message: !!null
|
79
|
+
headers:
|
80
|
+
content-length:
|
81
|
+
- '748'
|
82
|
+
content-encoding:
|
83
|
+
- UTF-8
|
84
|
+
content-type:
|
85
|
+
- application/json
|
86
|
+
access-control-allow-origin:
|
87
|
+
- ! '*'
|
88
|
+
connection:
|
89
|
+
- close
|
90
|
+
server:
|
91
|
+
- Jetty(6.1.25)
|
92
|
+
body:
|
93
|
+
encoding: US-ASCII
|
94
|
+
string: ! "{\n \"cypher\" : \"http://localhost:7477/db/data/cypher\",\n \"relationship_index\"
|
95
|
+
: \"http://localhost:7477/db/data/index/relationship\",\n \"node\" : \"http://localhost:7477/db/data/node\",\n
|
96
|
+
\ \"relationship_types\" : \"http://localhost:7477/db/data/relationship/types\",\n
|
97
|
+
\ \"neo4j_version\" : \"1.8.M04-1-g892e348\",\n \"batch\" : \"http://localhost:7477/db/data/batch\",\n
|
98
|
+
\ \"extensions_info\" : \"http://localhost:7477/db/data/ext\",\n \"node_index\"
|
99
|
+
: \"http://localhost:7477/db/data/index/node\",\n \"extensions\" : {\n \"CypherPlugin\"
|
100
|
+
: {\n \"execute_query\" : \"http://localhost:7477/db/data/ext/CypherPlugin/graphdb/execute_query\"\n
|
101
|
+
\ },\n \"GremlinPlugin\" : {\n \"execute_script\" : \"http://localhost:7477/db/data/ext/GremlinPlugin/graphdb/execute_script\"\n
|
102
|
+
\ }\n }\n}"
|
103
|
+
http_version: !!null
|
104
|
+
recorded_at: Fri, 06 Jul 2012 01:30:16 GMT
|
105
|
+
recorded_with: VCR 2.2.2
|
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:7477/db/data/ext/GremlinPlugin/graphdb/execute_script
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"script":"g.clear();g.V()"}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: !!null
|
16
|
+
headers:
|
17
|
+
content-length:
|
18
|
+
- '3'
|
19
|
+
content-encoding:
|
20
|
+
- UTF-8
|
21
|
+
content-type:
|
22
|
+
- application/json
|
23
|
+
access-control-allow-origin:
|
24
|
+
- ! '*'
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
server:
|
28
|
+
- Jetty(6.1.25)
|
29
|
+
body:
|
30
|
+
encoding: US-ASCII
|
31
|
+
string: ! '[ ]'
|
32
|
+
http_version: !!null
|
33
|
+
recorded_at: Fri, 06 Jul 2012 01:43:06 GMT
|
34
|
+
- request:
|
35
|
+
method: delete
|
36
|
+
uri: http://localhost:7477/db/data/index/node/users
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ''
|
40
|
+
headers: {}
|
41
|
+
response:
|
42
|
+
status:
|
43
|
+
code: 404
|
44
|
+
message: !!null
|
45
|
+
headers:
|
46
|
+
content-length:
|
47
|
+
- '470'
|
48
|
+
content-encoding:
|
49
|
+
- UTF-8
|
50
|
+
content-type:
|
51
|
+
- application/json
|
52
|
+
access-control-allow-origin:
|
53
|
+
- ! '*'
|
54
|
+
connection:
|
55
|
+
- close
|
56
|
+
server:
|
57
|
+
- Jetty(6.1.25)
|
58
|
+
body:
|
59
|
+
encoding: US-ASCII
|
60
|
+
string: ! "{\n \"message\" : \"No node index named 'users'.\",\n \"exception\"
|
61
|
+
: \"org.neo4j.graphdb.NotFoundException: No node index named 'users'.\",\n
|
62
|
+
\ \"stacktrace\" : [ \"org.neo4j.server.rest.web.DatabaseActions.removeNodeIndex(DatabaseActions.java:421)\",
|
63
|
+
\"org.neo4j.server.rest.web.RestfulGraphDatabase.deleteNodeIndex(RestfulGraphDatabase.java:729)\",
|
64
|
+
\"java.lang.reflect.Method.invoke(Method.java:597)\", \"org.neo4j.server.statistic.StatisticFilter.doFilter(StatisticFilter.java:62)\"
|
65
|
+
]\n}"
|
66
|
+
http_version: !!null
|
67
|
+
recorded_at: Fri, 06 Jul 2012 01:43:06 GMT
|
68
|
+
- request:
|
69
|
+
method: get
|
70
|
+
uri: http://localhost:7477/db/data/
|
71
|
+
body:
|
72
|
+
encoding: US-ASCII
|
73
|
+
string: ''
|
74
|
+
headers: {}
|
75
|
+
response:
|
76
|
+
status:
|
77
|
+
code: 200
|
78
|
+
message: !!null
|
79
|
+
headers:
|
80
|
+
content-length:
|
81
|
+
- '748'
|
82
|
+
content-encoding:
|
83
|
+
- UTF-8
|
84
|
+
content-type:
|
85
|
+
- application/json
|
86
|
+
access-control-allow-origin:
|
87
|
+
- ! '*'
|
88
|
+
connection:
|
89
|
+
- close
|
90
|
+
server:
|
91
|
+
- Jetty(6.1.25)
|
92
|
+
body:
|
93
|
+
encoding: US-ASCII
|
94
|
+
string: ! "{\n \"cypher\" : \"http://localhost:7477/db/data/cypher\",\n \"relationship_index\"
|
95
|
+
: \"http://localhost:7477/db/data/index/relationship\",\n \"node\" : \"http://localhost:7477/db/data/node\",\n
|
96
|
+
\ \"relationship_types\" : \"http://localhost:7477/db/data/relationship/types\",\n
|
97
|
+
\ \"neo4j_version\" : \"1.8.M04-1-g892e348\",\n \"batch\" : \"http://localhost:7477/db/data/batch\",\n
|
98
|
+
\ \"extensions_info\" : \"http://localhost:7477/db/data/ext\",\n \"node_index\"
|
99
|
+
: \"http://localhost:7477/db/data/index/node\",\n \"extensions\" : {\n \"CypherPlugin\"
|
100
|
+
: {\n \"execute_query\" : \"http://localhost:7477/db/data/ext/CypherPlugin/graphdb/execute_query\"\n
|
101
|
+
\ },\n \"GremlinPlugin\" : {\n \"execute_script\" : \"http://localhost:7477/db/data/ext/GremlinPlugin/graphdb/execute_script\"\n
|
102
|
+
\ }\n }\n}"
|
103
|
+
http_version: !!null
|
104
|
+
recorded_at: Fri, 06 Jul 2012 01:43:06 GMT
|
105
|
+
recorded_with: VCR 2.2.2
|
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:7477/db/data/ext/GremlinPlugin/graphdb/execute_script
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"script":"g.clear();g.V()"}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
response:
|
13
|
+
status:
|
14
|
+
code: 200
|
15
|
+
message: !!null
|
16
|
+
headers:
|
17
|
+
content-length:
|
18
|
+
- '3'
|
19
|
+
content-encoding:
|
20
|
+
- UTF-8
|
21
|
+
content-type:
|
22
|
+
- application/json
|
23
|
+
access-control-allow-origin:
|
24
|
+
- ! '*'
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
server:
|
28
|
+
- Jetty(6.1.25)
|
29
|
+
body:
|
30
|
+
encoding: US-ASCII
|
31
|
+
string: ! '[ ]'
|
32
|
+
http_version: !!null
|
33
|
+
recorded_at: Thu, 05 Jul 2012 21:30:16 GMT
|
34
|
+
- request:
|
35
|
+
method: delete
|
36
|
+
uri: http://localhost:7477/db/data/index/node/users
|
37
|
+
body:
|
38
|
+
encoding: US-ASCII
|
39
|
+
string: ''
|
40
|
+
headers: {}
|
41
|
+
response:
|
42
|
+
status:
|
43
|
+
code: 404
|
44
|
+
message: !!null
|
45
|
+
headers:
|
46
|
+
content-length:
|
47
|
+
- '470'
|
48
|
+
content-encoding:
|
49
|
+
- UTF-8
|
50
|
+
content-type:
|
51
|
+
- application/json
|
52
|
+
access-control-allow-origin:
|
53
|
+
- ! '*'
|
54
|
+
connection:
|
55
|
+
- close
|
56
|
+
server:
|
57
|
+
- Jetty(6.1.25)
|
58
|
+
body:
|
59
|
+
encoding: US-ASCII
|
60
|
+
string: ! "{\n \"message\" : \"No node index named 'users'.\",\n \"exception\"
|
61
|
+
: \"org.neo4j.graphdb.NotFoundException: No node index named 'users'.\",\n
|
62
|
+
\ \"stacktrace\" : [ \"org.neo4j.server.rest.web.DatabaseActions.removeNodeIndex(DatabaseActions.java:421)\",
|
63
|
+
\"org.neo4j.server.rest.web.RestfulGraphDatabase.deleteNodeIndex(RestfulGraphDatabase.java:729)\",
|
64
|
+
\"java.lang.reflect.Method.invoke(Method.java:597)\", \"org.neo4j.server.statistic.StatisticFilter.doFilter(StatisticFilter.java:62)\"
|
65
|
+
]\n}"
|
66
|
+
http_version: !!null
|
67
|
+
recorded_at: Thu, 05 Jul 2012 21:30:16 GMT
|
68
|
+
- request:
|
69
|
+
method: get
|
70
|
+
uri: http://localhost:7477/db/data/
|
71
|
+
body:
|
72
|
+
encoding: US-ASCII
|
73
|
+
string: ''
|
74
|
+
headers: {}
|
75
|
+
response:
|
76
|
+
status:
|
77
|
+
code: 200
|
78
|
+
message: !!null
|
79
|
+
headers:
|
80
|
+
content-length:
|
81
|
+
- '748'
|
82
|
+
content-encoding:
|
83
|
+
- UTF-8
|
84
|
+
content-type:
|
85
|
+
- application/json
|
86
|
+
access-control-allow-origin:
|
87
|
+
- ! '*'
|
88
|
+
connection:
|
89
|
+
- close
|
90
|
+
server:
|
91
|
+
- Jetty(6.1.25)
|
92
|
+
body:
|
93
|
+
encoding: US-ASCII
|
94
|
+
string: ! "{\n \"cypher\" : \"http://localhost:7477/db/data/cypher\",\n \"relationship_index\"
|
95
|
+
: \"http://localhost:7477/db/data/index/relationship\",\n \"node\" : \"http://localhost:7477/db/data/node\",\n
|
96
|
+
\ \"relationship_types\" : \"http://localhost:7477/db/data/relationship/types\",\n
|
97
|
+
\ \"neo4j_version\" : \"1.8.M04-1-g892e348\",\n \"batch\" : \"http://localhost:7477/db/data/batch\",\n
|
98
|
+
\ \"extensions_info\" : \"http://localhost:7477/db/data/ext\",\n \"node_index\"
|
99
|
+
: \"http://localhost:7477/db/data/index/node\",\n \"extensions\" : {\n \"CypherPlugin\"
|
100
|
+
: {\n \"execute_query\" : \"http://localhost:7477/db/data/ext/CypherPlugin/graphdb/execute_query\"\n
|
101
|
+
\ },\n \"GremlinPlugin\" : {\n \"execute_script\" : \"http://localhost:7477/db/data/ext/GremlinPlugin/graphdb/execute_script\"\n
|
102
|
+
\ }\n }\n}"
|
103
|
+
http_version: !!null
|
104
|
+
recorded_at: Thu, 05 Jul 2012 21:30:16 GMT
|
105
|
+
recorded_with: VCR 2.2.2
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'keymaker'
|
3
|
+
|
4
|
+
describe Keymaker::AddNodeToIndexRequest, vcr: true do
|
5
|
+
|
6
|
+
include_context "John and Sarah nodes"
|
7
|
+
|
8
|
+
let(:options) {{index_name: "users", key: "email", node_id: john_node_id, value: john_email}}
|
9
|
+
let(:add_node_to_index_request) { Keymaker::AddNodeToIndexRequest.new(Keymaker.service, options).submit }
|
10
|
+
|
11
|
+
it "returns the Neo4j REST API starting point response request" do
|
12
|
+
add_node_to_index_request.body.should include(
|
13
|
+
{
|
14
|
+
"indexed" => "http://localhost:7477/db/data/index/node/users/email/john%40resistance.net/1004",
|
15
|
+
"outgoing_relationships" => "http://localhost:7477/db/data/node/1004/relationships/out",
|
16
|
+
"data" => {"email" => "john@resistance.net"},
|
17
|
+
"traverse" => "http://localhost:7477/db/data/node/1004/traverse/{returnType}",
|
18
|
+
"all_typed_relationships" => "http://localhost:7477/db/data/node/1004/relationships/all/{-list|&|types}",
|
19
|
+
"property" => "http://localhost:7477/db/data/node/1004/properties/{key}",
|
20
|
+
"self" => "http://localhost:7477/db/data/node/1004",
|
21
|
+
"properties" => "http://localhost:7477/db/data/node/1004/properties",
|
22
|
+
"outgoing_typed_relationships" => "http://localhost:7477/db/data/node/1004/relationships/out/{-list|&|types}",
|
23
|
+
"incoming_relationships" => "http://localhost:7477/db/data/node/1004/relationships/in",
|
24
|
+
"extensions" => {},
|
25
|
+
"create_relationship" => "http://localhost:7477/db/data/node/1004/relationships",
|
26
|
+
"paged_traverse" => "http://localhost:7477/db/data/node/1004/paged/traverse/{returnType}{?pageSize,leaseTime}",
|
27
|
+
"all_relationships" => "http://localhost:7477/db/data/node/1004/relationships/all",
|
28
|
+
"incoming_typed_relationships" => "http://localhost:7477/db/data/node/1004/relationships/in/{-list|&|types}"
|
29
|
+
}
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns a 201 status code" do
|
34
|
+
add_node_to_index_request.status.should == 201
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns application/json" do
|
38
|
+
add_node_to_index_request.faraday_response.headers["content-type"].should include("application/json")
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'keymaker'
|
3
|
+
|
4
|
+
describe Keymaker::BatchGetNodesRequest do
|
5
|
+
|
6
|
+
describe "#build_opts_collection" do
|
7
|
+
|
8
|
+
let(:node_ids) { [1,2,3,4] }
|
9
|
+
let(:batch_get_nodes_request) do
|
10
|
+
Keymaker::BatchGetNodesRequest.new(Keymaker.service, node_ids)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "builds the job descriptions collection" do
|
14
|
+
batch_get_nodes_request.opts.should == [
|
15
|
+
{id: 0, to: "http://localhost:7477/db/data/node/1", method: "GET"},
|
16
|
+
{id: 1, to: "http://localhost:7477/db/data/node/2", method: "GET"},
|
17
|
+
{id: 2, to: "http://localhost:7477/db/data/node/3", method: "GET"},
|
18
|
+
{id: 3, to: "http://localhost:7477/db/data/node/4", method: "GET"}
|
19
|
+
]
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'keymaker'
|
3
|
+
|
4
|
+
describe Keymaker::BatchRequest, :vcr => true do
|
5
|
+
|
6
|
+
let(:batch_request) { Keymaker::BatchRequest.new(Keymaker.service, options).submit }
|
7
|
+
|
8
|
+
context "when :to and :method are not set" do
|
9
|
+
let(:options) do
|
10
|
+
[ { foo: "WET", ot: "/node/1" } ]
|
11
|
+
end
|
12
|
+
it "raises BatchRequestError" do
|
13
|
+
expect { batch_request }.to raise_error(Keymaker::BatchRequestError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when a resource is not found" do
|
18
|
+
let(:options) do
|
19
|
+
[ { method: "GET", to: "/node/999999999" } ]
|
20
|
+
end
|
21
|
+
it "raises BatchRequestError" do
|
22
|
+
expect { batch_request }.to raise_error(Keymaker::BatchRequestError)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with valid options" do
|
27
|
+
let(:options) do
|
28
|
+
[ {
|
29
|
+
method: "POST",
|
30
|
+
to: "/node",
|
31
|
+
id: 0,
|
32
|
+
body: {
|
33
|
+
name: "John Connor"
|
34
|
+
}
|
35
|
+
}, {
|
36
|
+
method: "POST",
|
37
|
+
to: "/node",
|
38
|
+
id: 1,
|
39
|
+
body: {
|
40
|
+
name: "Sarah Connor"
|
41
|
+
}
|
42
|
+
}, {
|
43
|
+
method: "POST",
|
44
|
+
to: "{0}/relationships",
|
45
|
+
id: 3,
|
46
|
+
body: {
|
47
|
+
to: "{1}",
|
48
|
+
data: {
|
49
|
+
since: "1985"
|
50
|
+
},
|
51
|
+
type: "knows"
|
52
|
+
}
|
53
|
+
} ]
|
54
|
+
end
|
55
|
+
|
56
|
+
let(:results) do
|
57
|
+
[ {"id"=>0,
|
58
|
+
"location"=>"http://localhost:7477/db/data/node/26",
|
59
|
+
"body"=>{"outgoing_relationships"=>"http://localhost:7477/db/data/node/26/relationships/out",
|
60
|
+
"data"=>{"name"=>"John Connor"},
|
61
|
+
"traverse"=>"http://localhost:7477/db/data/node/26/traverse/{returnType}",
|
62
|
+
"all_typed_relationships"=>"http://localhost:7477/db/data/node/26/relationships/all/{-list|&|types}",
|
63
|
+
"property"=>"http://localhost:7477/db/data/node/26/properties/{key}",
|
64
|
+
"self"=>"http://localhost:7477/db/data/node/26",
|
65
|
+
"properties"=>"http://localhost:7477/db/data/node/26/properties",
|
66
|
+
"outgoing_typed_relationships"=>"http://localhost:7477/db/data/node/26/relationships/out/{-list|&|types}",
|
67
|
+
"incoming_relationships"=>"http://localhost:7477/db/data/node/26/relationships/in",
|
68
|
+
"extensions"=>{},
|
69
|
+
"create_relationship"=>"http://localhost:7477/db/data/node/26/relationships",
|
70
|
+
"paged_traverse"=>"http://localhost:7477/db/data/node/26/paged/traverse/{returnType}{?pageSize,leaseTime}",
|
71
|
+
"all_relationships"=>"http://localhost:7477/db/data/node/26/relationships/all",
|
72
|
+
"incoming_typed_relationships"=>"http://localhost:7477/db/data/node/26/relationships/in/{-list|&|types}"},
|
73
|
+
"from"=>"/node"},
|
74
|
+
{"id"=>1,
|
75
|
+
"location"=>"http://localhost:7477/db/data/node/27",
|
76
|
+
"body"=>{"outgoing_relationships"=>"http://localhost:7477/db/data/node/27/relationships/out",
|
77
|
+
"data"=>{"name"=>"Sarah Connor"},
|
78
|
+
"traverse"=>"http://localhost:7477/db/data/node/27/traverse/{returnType}",
|
79
|
+
"all_typed_relationships"=>"http://localhost:7477/db/data/node/27/relationships/all/{-list|&|types}",
|
80
|
+
"property"=>"http://localhost:7477/db/data/node/27/properties/{key}",
|
81
|
+
"self"=>"http://localhost:7477/db/data/node/27",
|
82
|
+
"properties"=>"http://localhost:7477/db/data/node/27/properties",
|
83
|
+
"outgoing_typed_relationships"=>"http://localhost:7477/db/data/node/27/relationships/out/{-list|&|types}",
|
84
|
+
"incoming_relationships"=>"http://localhost:7477/db/data/node/27/relationships/in",
|
85
|
+
"extensions"=>{},
|
86
|
+
"create_relationship"=>"http://localhost:7477/db/data/node/27/relationships",
|
87
|
+
"paged_traverse"=>"http://localhost:7477/db/data/node/27/paged/traverse/{returnType}{?pageSize,leaseTime}",
|
88
|
+
"all_relationships"=>"http://localhost:7477/db/data/node/27/relationships/all",
|
89
|
+
"incoming_typed_relationships"=>"http://localhost:7477/db/data/node/27/relationships/in/{-list|&|types}"},
|
90
|
+
"from"=>"/node"},
|
91
|
+
{"id"=>3,
|
92
|
+
"location"=>"http://localhost:7477/db/data/relationship/2",
|
93
|
+
"body"=>{"start"=>"http://localhost:7477/db/data/node/26",
|
94
|
+
"data"=>{"since"=>"1985"},
|
95
|
+
"self"=>"http://localhost:7477/db/data/relationship/2",
|
96
|
+
"property"=>"http://localhost:7477/db/data/relationship/2/properties/{key}",
|
97
|
+
"properties"=>"http://localhost:7477/db/data/relationship/2/properties",
|
98
|
+
"type"=>"knows",
|
99
|
+
"extensions"=>{},
|
100
|
+
"end"=>"http://localhost:7477/db/data/node/27"},
|
101
|
+
"from"=>"http://localhost:7477/db/data/node/26/relationships"}
|
102
|
+
]
|
103
|
+
end
|
104
|
+
|
105
|
+
it "runs the commands and returns their respective results" do
|
106
|
+
batch_request.body.should == results
|
107
|
+
end
|
108
|
+
|
109
|
+
it "returns a 200 status code" do
|
110
|
+
batch_request.status.should == 200
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|