neography 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -1
- data/README.md +1 -0
- data/lib/neography/connection.rb +45 -34
- data/lib/neography/node.rb +1 -1
- data/lib/neography/path_traverser.rb +9 -4
- data/lib/neography/property_container.rb +16 -4
- data/lib/neography/rest.rb +86 -2
- data/lib/neography/rest/batch.rb +4 -12
- data/lib/neography/rest/cypher.rb +12 -3
- data/lib/neography/rest/helpers.rb +12 -0
- data/lib/neography/rest/node_labels.rb +60 -0
- data/lib/neography/rest/node_relationships.rb +0 -11
- data/lib/neography/rest/other_node_relationships.rb +1 -12
- data/lib/neography/rest/relationship_types.rb +18 -0
- data/lib/neography/rest/schema_indexes.rb +34 -0
- data/lib/neography/rest/transactions.rb +83 -0
- data/lib/neography/tasks.rb +1 -1
- data/lib/neography/version.rb +1 -1
- data/spec/integration/node_spec.rb +13 -0
- data/spec/integration/rest_batch_spec.rb +11 -15
- data/spec/integration/rest_batch_streaming_spec.rb +2 -2
- data/spec/integration/rest_gremlin_fail_spec.rb +4 -4
- data/spec/integration/rest_header_spec.rb +1 -1
- data/spec/integration/rest_labels_spec.rb +131 -0
- data/spec/integration/rest_plugin_spec.rb +32 -3
- data/spec/integration/rest_relationship_types_spec.rb +18 -0
- data/spec/integration/rest_schema_index_spec.rb +32 -0
- data/spec/integration/rest_transaction_spec.rb +100 -0
- data/spec/spec_helper.rb +8 -1
- data/spec/unit/connection_spec.rb +1 -1
- data/spec/unit/node_spec.rb +1 -1
- data/spec/unit/rest/batch_spec.rb +21 -21
- data/spec/unit/rest/labels_spec.rb +73 -0
- data/spec/unit/rest/relationship_types_spec.rb +16 -0
- data/spec/unit/rest/schema_index_spec.rb +31 -0
- data/spec/unit/rest/transactions_spec.rb +44 -0
- metadata +22 -2
@@ -6,13 +6,13 @@ describe Neography::Rest do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "execute gremlin script" do
|
9
|
-
it "can get the root node id" do
|
9
|
+
it "can get the root node id", :gremlin => true do
|
10
10
|
root_node = @neo.execute_script("g.v(0)")
|
11
11
|
root_node.should have_key("self")
|
12
12
|
root_node["self"].split('/').last.should == "0"
|
13
13
|
end
|
14
14
|
|
15
|
-
it "can get the a node" do
|
15
|
+
it "can get the a node", :gremlin => true do
|
16
16
|
new_node = @neo.create_node
|
17
17
|
id = new_node["self"].split('/').last
|
18
18
|
existing_node = @neo.execute_script("g.v(#{id})")
|
@@ -21,7 +21,7 @@ describe Neography::Rest do
|
|
21
21
|
existing_node["self"].split('/').last.should == id
|
22
22
|
end
|
23
23
|
|
24
|
-
it "can get the a node with a variable" do
|
24
|
+
it "can get the a node with a variable", :gremlin => true do
|
25
25
|
new_node = @neo.create_node
|
26
26
|
id = new_node["self"].split('/').last
|
27
27
|
existing_node = @neo.execute_script("g.v(id)", {:id => id.to_i})
|
@@ -62,6 +62,35 @@ describe Neography::Rest do
|
|
62
62
|
existing_node["data"][0][0]["self"].split('/').last.should == id
|
63
63
|
end
|
64
64
|
|
65
|
+
it "can get the stats of a cypher query" do
|
66
|
+
root_node = @neo.execute_query("start n=node(0) return n", nil, {:stats => true})
|
67
|
+
root_node.should have_key("data")
|
68
|
+
root_node.should have_key("columns")
|
69
|
+
root_node.should have_key("stats")
|
70
|
+
root_node["data"][0][0].should have_key("self")
|
71
|
+
root_node["data"][0][0]["self"].split('/').last.should == "0"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "can get the profile of a cypher query" do
|
75
|
+
root_node = @neo.execute_query("start n=node(0) return n", nil, {:profile => true})
|
76
|
+
root_node.should have_key("data")
|
77
|
+
root_node.should have_key("columns")
|
78
|
+
root_node.should have_key("plan")
|
79
|
+
root_node["data"][0][0].should have_key("self")
|
80
|
+
root_node["data"][0][0]["self"].split('/').last.should == "0"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "can get the stats and profile of a cypher query" do
|
84
|
+
root_node = @neo.execute_query("start n=node(0) return n", nil, {:stats => true, :profile => true})
|
85
|
+
root_node.should have_key("data")
|
86
|
+
root_node.should have_key("columns")
|
87
|
+
root_node.should have_key("stats")
|
88
|
+
root_node.should have_key("plan")
|
89
|
+
root_node["data"][0][0].should have_key("self")
|
90
|
+
root_node["data"][0][0]["self"].split('/').last.should == "0"
|
91
|
+
end
|
92
|
+
|
93
|
+
|
65
94
|
it "can delete everything but start node" do
|
66
95
|
@neo.execute_query("START n=node(*) MATCH n-[r?]-() WHERE ID(n) <> 0 DELETE n,r")
|
67
96
|
expect {
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neography::Rest do
|
4
|
+
before(:each) do
|
5
|
+
@neo = Neography::Rest.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "list relationship types" do
|
9
|
+
it "can get a listing of relationship types" do
|
10
|
+
new_node1 = @neo.create_node
|
11
|
+
new_node2 = @neo.create_node
|
12
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
13
|
+
rel_types = @neo.list_relationship_types
|
14
|
+
rel_types.should_not be_nil
|
15
|
+
rel_types.should include("friends")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neography::Rest do
|
4
|
+
before(:each) do
|
5
|
+
@neo = Neography::Rest.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "create a schema index" do
|
9
|
+
it "can create a schema index" do
|
10
|
+
si = @neo.create_schema_index("person", ["name"])
|
11
|
+
si.should_not be_nil
|
12
|
+
si["property-keys"].should include("name")
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "list schema indexes" do
|
18
|
+
it "can get a listing of node indexes" do
|
19
|
+
si = @neo.get_schema_index("person")
|
20
|
+
si.should_not be_nil
|
21
|
+
si.first["label"].should include("person")
|
22
|
+
si.first["property-keys"].should include("name")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "drop schema indexes" do
|
27
|
+
it "can drop an existing schema index" do
|
28
|
+
si = @neo.delete_schema_index("person", "name")
|
29
|
+
si.should be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neography::Rest do
|
4
|
+
before(:each) do
|
5
|
+
@neo = Neography::Rest.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "start a transaction" do
|
9
|
+
it "can start a transaction" do
|
10
|
+
tx = @neo.begin_transaction
|
11
|
+
tx.should have_key("transaction")
|
12
|
+
tx["results"].should be_empty
|
13
|
+
end
|
14
|
+
|
15
|
+
it "can start a transaction with statements" do
|
16
|
+
tx = @neo.begin_transaction("start n=node(0) return n")
|
17
|
+
tx.should have_key("transaction")
|
18
|
+
tx.should have_key("results")
|
19
|
+
tx["results"].should_not be_empty
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "keep a transaction" do
|
24
|
+
it "can keep a transaction" do
|
25
|
+
tx = @neo.begin_transaction
|
26
|
+
tx.should have_key("transaction")
|
27
|
+
tx["results"].should be_empty
|
28
|
+
sleep(1)
|
29
|
+
existing_tx = @neo.keep_transaction(tx)
|
30
|
+
existing_tx.should have_key("transaction")
|
31
|
+
existing_tx["transaction"]["expires"].should > tx["transaction"]["expires"]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
describe "add to a transaction" do
|
37
|
+
it "can add to a transaction" do
|
38
|
+
tx = @neo.begin_transaction
|
39
|
+
tx.should have_key("transaction")
|
40
|
+
tx["results"].should be_empty
|
41
|
+
existing_tx = @neo.in_transaction(tx, "start n=node(0) return n")
|
42
|
+
existing_tx.should have_key("transaction")
|
43
|
+
existing_tx.should have_key("results")
|
44
|
+
existing_tx["results"].should_not be_empty
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "commit a transaction" do
|
49
|
+
it "can commit an opened empty transaction" do
|
50
|
+
tx = @neo.begin_transaction
|
51
|
+
tx.should have_key("transaction")
|
52
|
+
tx["results"].should be_empty
|
53
|
+
existing_tx = @neo.commit_transaction(tx)
|
54
|
+
existing_tx.should have_key("results")
|
55
|
+
existing_tx["results"].should be_empty
|
56
|
+
end
|
57
|
+
|
58
|
+
it "can commit an opened transaction" do
|
59
|
+
tx = @neo.begin_transaction("start n=node(0) return n")
|
60
|
+
tx.should have_key("transaction")
|
61
|
+
tx["results"].should_not be_empty
|
62
|
+
existing_tx = @neo.commit_transaction(tx)
|
63
|
+
existing_tx.should_not have_key("transaction")
|
64
|
+
existing_tx.should have_key("results")
|
65
|
+
existing_tx["results"].should be_empty
|
66
|
+
end
|
67
|
+
|
68
|
+
it "can commit an opened transaction with new statements" do
|
69
|
+
tx = @neo.begin_transaction
|
70
|
+
tx.should have_key("transaction")
|
71
|
+
tx["results"].should be_empty
|
72
|
+
existing_tx = @neo.commit_transaction(tx, "start n=node(0) return n")
|
73
|
+
existing_tx.should_not have_key("transaction")
|
74
|
+
existing_tx.should have_key("results")
|
75
|
+
existing_tx["results"].should_not be_empty
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "rollback a transaction" do
|
80
|
+
it "can rollback an opened empty transaction" do
|
81
|
+
tx = @neo.begin_transaction
|
82
|
+
tx.should have_key("transaction")
|
83
|
+
tx["results"].should be_empty
|
84
|
+
existing_tx = @neo.rollback_transaction(tx)
|
85
|
+
existing_tx.should have_key("results")
|
86
|
+
existing_tx["results"].should be_empty
|
87
|
+
end
|
88
|
+
|
89
|
+
it "can rollback an opened transaction" do
|
90
|
+
tx = @neo.begin_transaction("start n=node(0) return n")
|
91
|
+
tx.should have_key("transaction")
|
92
|
+
tx["results"].should_not be_empty
|
93
|
+
existing_tx = @neo.rollback_transaction(tx)
|
94
|
+
existing_tx.should have_key("transaction")
|
95
|
+
existing_tx.should have_key("results")
|
96
|
+
existing_tx["results"].should be_empty
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -17,7 +17,7 @@ def generate_text(length=8)
|
|
17
17
|
end
|
18
18
|
|
19
19
|
RSpec.configure do |c|
|
20
|
-
c.filter_run_excluding :slow => true, :
|
20
|
+
c.filter_run_excluding :slow => true, :gremlin => true
|
21
21
|
end
|
22
22
|
|
23
23
|
|
@@ -26,7 +26,14 @@ def json_content_type
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def error_response(attributes)
|
29
|
+
request_uri = double()
|
30
|
+
request_uri.stub(:request_uri).and_return("")
|
31
|
+
|
32
|
+
http_header = double()
|
33
|
+
http_header.stub(:request_uri).and_return(request_uri)
|
34
|
+
|
29
35
|
stub(
|
36
|
+
http_header: http_header,
|
30
37
|
code: attributes[:code],
|
31
38
|
body: {
|
32
39
|
message: attributes[:message],
|
@@ -123,7 +123,7 @@ module Neography
|
|
123
123
|
it "adds the User-Agent to the headers" do
|
124
124
|
connection.client.should_receive(:get).with(
|
125
125
|
"http://localhost:7474/db/data/foo/bar",
|
126
|
-
nil, { "User-Agent" => "Neography/#{Neography::VERSION}" }
|
126
|
+
nil, { "User-Agent" => "Neography/#{Neography::VERSION}", "X-Stream"=>true}
|
127
127
|
) { stub.as_null_object }
|
128
128
|
|
129
129
|
connection.get("/foo/bar", :headers => {})
|
data/spec/unit/node_spec.rb
CHANGED
@@ -13,7 +13,7 @@ module Neography
|
|
13
13
|
{ "id" => 1, "method" => "GET", "to" => "/node/bar" }
|
14
14
|
]
|
15
15
|
|
16
|
-
connection.should_receive(:
|
16
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
17
17
|
subject.execute [:get_node, "foo"], [:get_node, "bar"]
|
18
18
|
end
|
19
19
|
|
@@ -23,7 +23,7 @@ module Neography
|
|
23
23
|
{ "id" => 1, "method" => "POST", "to" => "/node", "body" => { "baz" => "qux" } }
|
24
24
|
]
|
25
25
|
|
26
|
-
connection.should_receive(:
|
26
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
27
27
|
subject.execute [:create_node, { "foo" => "bar" }], [:create_node, { "baz" => "qux" }]
|
28
28
|
end
|
29
29
|
|
@@ -33,7 +33,7 @@ module Neography
|
|
33
33
|
{ "id" => 1, "method" => "DELETE", "to" => "/node/bar" }
|
34
34
|
]
|
35
35
|
|
36
|
-
connection.should_receive(:
|
36
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
37
37
|
subject.execute [:delete_node, "foo"], [:delete_node, "bar"]
|
38
38
|
end
|
39
39
|
|
@@ -43,7 +43,7 @@ module Neography
|
|
43
43
|
{ "id" => 1, "method" => "POST", "to" => "/index/node/quux?unique", "body" => { "key" => "corge", "value" => "grault", "properties" => "garply" } }
|
44
44
|
]
|
45
45
|
|
46
|
-
connection.should_receive(:
|
46
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
47
47
|
subject.execute [:create_unique_node, "foo", "bar", "baz", "qux" ],
|
48
48
|
[:create_unique_node, "quux", "corge", "grault", "garply"]
|
49
49
|
end
|
@@ -54,7 +54,7 @@ module Neography
|
|
54
54
|
{ "id" => 1, "method" => "POST", "to" => "/index/node/quux", "body" => { "uri" => "{0}", "key" => "corge", "value" => "grault" } }
|
55
55
|
]
|
56
56
|
|
57
|
-
connection.should_receive(:
|
57
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
58
58
|
subject.execute [:add_node_to_index, "foo", "bar", "baz", "qux" ],
|
59
59
|
[:add_node_to_index, "quux", "corge", "grault", "{0}"]
|
60
60
|
end
|
@@ -65,7 +65,7 @@ module Neography
|
|
65
65
|
{ "id" => 1, "method" => "GET", "to" => "/index/node/qux/quux/corge" }
|
66
66
|
]
|
67
67
|
|
68
|
-
connection.should_receive(:
|
68
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
69
69
|
subject.execute [:get_node_index, "foo", "bar", "baz" ],
|
70
70
|
[:get_node_index, "qux", "quux", "corge" ]
|
71
71
|
end
|
@@ -77,7 +77,7 @@ module Neography
|
|
77
77
|
{ "id" => 2, "method" => "DELETE", "to" => "/index/node/index3/key3/value3/id3" }
|
78
78
|
]
|
79
79
|
|
80
|
-
connection.should_receive(:
|
80
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
81
81
|
subject.execute [:remove_node_from_index, "index1", "id1", ],
|
82
82
|
[:remove_node_from_index, "index2", "key2", "id2" ],
|
83
83
|
[:remove_node_from_index, "index3", "key3", "value3", "id3" ]
|
@@ -89,7 +89,7 @@ module Neography
|
|
89
89
|
{ "id" => 1, "method" => "PUT", "to" => "/node/index2/properties/key2", "body" => "value2" }
|
90
90
|
]
|
91
91
|
|
92
|
-
connection.should_receive(:
|
92
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
93
93
|
subject.execute [:set_node_property, "index1", { "key1" => "value1" } ],
|
94
94
|
[:set_node_property, "index2", { "key2" => "value2" } ]
|
95
95
|
end
|
@@ -100,7 +100,7 @@ module Neography
|
|
100
100
|
{ "id" => 1, "method" => "PUT", "to" => "/node/index2/properties", "body" => { "key2" => "value2" } }
|
101
101
|
]
|
102
102
|
|
103
|
-
connection.should_receive(:
|
103
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
104
104
|
subject.execute [:reset_node_properties, "index1", { "key1" => "value1" } ],
|
105
105
|
[:reset_node_properties, "index2", { "key2" => "value2" } ]
|
106
106
|
end
|
@@ -111,7 +111,7 @@ module Neography
|
|
111
111
|
{ "id" => 1, "method" => "GET", "to" => "/node/id2/relationships/all" }
|
112
112
|
]
|
113
113
|
|
114
|
-
connection.should_receive(:
|
114
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
115
115
|
subject.execute [:get_node_relationships, "id1", "direction1" ],
|
116
116
|
[:get_node_relationships, "id2" ]
|
117
117
|
end
|
@@ -122,7 +122,7 @@ module Neography
|
|
122
122
|
{ "id" => 1, "method" => "GET", "to" => "/relationship/bar" }
|
123
123
|
]
|
124
124
|
|
125
|
-
connection.should_receive(:
|
125
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
126
126
|
subject.execute [:get_relationship, "foo"], [:get_relationship, "bar"]
|
127
127
|
end
|
128
128
|
|
@@ -132,7 +132,7 @@ module Neography
|
|
132
132
|
{ "id" => 1, "method" => "POST", "to" => "{0}/relationships", "body" => { "to" => "{1}", "type" => "type2", "data" => "data2" } }
|
133
133
|
]
|
134
134
|
|
135
|
-
connection.should_receive(:
|
135
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
136
136
|
subject.execute [:create_relationship, "type1", "from1", "to1", "data1" ],
|
137
137
|
[:create_relationship, "type2", "{0}", "{1}", "data2" ]
|
138
138
|
end
|
@@ -143,7 +143,7 @@ module Neography
|
|
143
143
|
{ "id" => 1, "method" => "DELETE", "to" => "/relationship/bar" }
|
144
144
|
]
|
145
145
|
|
146
|
-
connection.should_receive(:
|
146
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
147
147
|
subject.execute [:delete_relationship, "foo"], [:delete_relationship, "bar"]
|
148
148
|
end
|
149
149
|
|
@@ -153,7 +153,7 @@ module Neography
|
|
153
153
|
{ "id" => 1, "method" => "POST", "to" => "/index/relationship/index2?unique", "body" => { "key" => "key2", "value" => "value2", "type" => "type2", "start" => "{0}", "end" => "{1}" } }
|
154
154
|
]
|
155
155
|
|
156
|
-
connection.should_receive(:
|
156
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
157
157
|
subject.execute [:create_unique_relationship, "index1", "key1", "value1", "type1", "node1", "node2" ],
|
158
158
|
[:create_unique_relationship, "index2", "key2", "value2", "type2", "{0}", "{1}" ]
|
159
159
|
end
|
@@ -164,7 +164,7 @@ module Neography
|
|
164
164
|
{ "id" => 1, "method" => "POST", "to" => "/index/relationship/index2", "body" => { "uri" => "{0}", "key" => "key2", "value" => "value2" } }
|
165
165
|
]
|
166
166
|
|
167
|
-
connection.should_receive(:
|
167
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
168
168
|
subject.execute [:add_relationship_to_index, "index1", "key1", "value1", "rel1" ],
|
169
169
|
[:add_relationship_to_index, "index2", "key2", "value2", "{0}"]
|
170
170
|
end
|
@@ -175,7 +175,7 @@ module Neography
|
|
175
175
|
{ "id" => 1, "method" => "GET", "to" => "/index/relationship/qux/quux/corge" }
|
176
176
|
]
|
177
177
|
|
178
|
-
connection.should_receive(:
|
178
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
179
179
|
subject.execute [:get_relationship_index, "foo", "bar", "baz" ],
|
180
180
|
[:get_relationship_index, "qux", "quux", "corge" ]
|
181
181
|
end
|
@@ -187,7 +187,7 @@ module Neography
|
|
187
187
|
{ "id" => 2, "method" => "DELETE", "to" => "/index/relationship/index3/key3/value3/id3" }
|
188
188
|
]
|
189
189
|
|
190
|
-
connection.should_receive(:
|
190
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
191
191
|
subject.execute [:remove_relationship_from_index, "index1", "id1", ],
|
192
192
|
[:remove_relationship_from_index, "index2", "key2", "id2" ],
|
193
193
|
[:remove_relationship_from_index, "index3", "key3", "value3", "id3" ]
|
@@ -199,7 +199,7 @@ module Neography
|
|
199
199
|
{ "id" => 1, "method" => "PUT", "to" => "/relationship/index2/properties/key2", "body" => "value2" }
|
200
200
|
]
|
201
201
|
|
202
|
-
connection.should_receive(:
|
202
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
203
203
|
subject.execute [:set_relationship_property, "index1", { "key1" => "value1" } ],
|
204
204
|
[:set_relationship_property, "index2", { "key2" => "value2" } ]
|
205
205
|
end
|
@@ -210,7 +210,7 @@ module Neography
|
|
210
210
|
{ "id" => 1, "method" => "PUT", "to" => "{0}/properties", "body" => { "key2" => "value2" } }
|
211
211
|
]
|
212
212
|
|
213
|
-
connection.should_receive(:
|
213
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
214
214
|
subject.execute [:reset_relationship_properties, "index1", { "key1" => "value1" } ],
|
215
215
|
[:reset_relationship_properties, "{0}", { "key2" => "value2" } ]
|
216
216
|
end
|
@@ -221,7 +221,7 @@ module Neography
|
|
221
221
|
{ "id" => 1, "method" => "POST", "to" => "/gremlin", "body" => { "script" => "script2", "params" => "params2" } }
|
222
222
|
]
|
223
223
|
|
224
|
-
connection.should_receive(:
|
224
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
225
225
|
subject.execute [:execute_script, "script1", "params1"],
|
226
226
|
[:execute_script, "script2", "params2"]
|
227
227
|
end
|
@@ -232,7 +232,7 @@ module Neography
|
|
232
232
|
{ "id" => 1, "method" => "POST", "to" => "/cypher", "body" => { "query" => "query2" } }
|
233
233
|
]
|
234
234
|
|
235
|
-
connection.should_receive(:
|
235
|
+
connection.should_receive(:post).with("/batch", json_match(:body, expected_body))
|
236
236
|
subject.execute [:execute_query, "query1", "params1"],
|
237
237
|
[:execute_query, "query2" ]
|
238
238
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Neography
|
4
|
+
class Rest
|
5
|
+
describe NodeLabels do
|
6
|
+
|
7
|
+
let(:connection) { stub }
|
8
|
+
subject { NodeLabels.new(connection) }
|
9
|
+
|
10
|
+
it "list node labels" do
|
11
|
+
connection.should_receive(:get).with("/labels")
|
12
|
+
subject.list
|
13
|
+
end
|
14
|
+
|
15
|
+
it "get labels for node" do
|
16
|
+
connection.should_receive(:get).with("/node/0/labels")
|
17
|
+
subject.get(0)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "get nodes for labels" do
|
21
|
+
connection.should_receive(:get).with("/label/person/nodes")
|
22
|
+
subject.get_nodes("person")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "find nodes for labels and property" do
|
26
|
+
connection.should_receive(:get).with("/label/person/nodes?name=%22max%22")
|
27
|
+
subject.find_nodes("person", {:name => "max"})
|
28
|
+
end
|
29
|
+
|
30
|
+
it "can add a label to a node" do
|
31
|
+
options = {
|
32
|
+
:body => '["Actor"]',
|
33
|
+
:headers => json_content_type
|
34
|
+
}
|
35
|
+
connection.should_receive(:post).with("/node/0/labels", options)
|
36
|
+
subject.add(0, ["Actor"])
|
37
|
+
end
|
38
|
+
|
39
|
+
it "can add labels to a node" do
|
40
|
+
options = {
|
41
|
+
:body => '["Actor","Director"]',
|
42
|
+
:headers => json_content_type
|
43
|
+
}
|
44
|
+
connection.should_receive(:post).with("/node/0/labels", options)
|
45
|
+
subject.add(0, ["Actor", "Director"])
|
46
|
+
end
|
47
|
+
|
48
|
+
it "can set a label to a node" do
|
49
|
+
options = {
|
50
|
+
:body => '["Actor"]',
|
51
|
+
:headers => json_content_type
|
52
|
+
}
|
53
|
+
connection.should_receive(:put).with("/node/0/labels", options)
|
54
|
+
subject.set(0, ["Actor"])
|
55
|
+
end
|
56
|
+
|
57
|
+
it "can add labels to a node" do
|
58
|
+
options = {
|
59
|
+
:body => '["Actor","Director"]',
|
60
|
+
:headers => json_content_type
|
61
|
+
}
|
62
|
+
connection.should_receive(:put).with("/node/0/labels", options)
|
63
|
+
subject.set(0, ["Actor", "Director"])
|
64
|
+
end
|
65
|
+
|
66
|
+
it "can delete a label from a node" do
|
67
|
+
connection.should_receive(:delete).with("/node/0/labels/Actor")
|
68
|
+
subject.delete(0,"Actor")
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|