neography-down 1.6.4
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.project +12 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +939 -0
- data/CONTRIBUTORS +18 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/LICENSE +19 -0
- data/README.md +281 -0
- data/Rakefile +14 -0
- data/examples/facebook.rb +40 -0
- data/examples/facebook_v2.rb +25 -0
- data/examples/greatest.rb +43 -0
- data/examples/linkedin.rb +39 -0
- data/examples/linkedin_v2.rb +22 -0
- data/examples/traversal_example1.rb +65 -0
- data/examples/traversal_example2.rb +54 -0
- data/lib/neography.rb +45 -0
- data/lib/neography/config.rb +64 -0
- data/lib/neography/connection.rb +263 -0
- data/lib/neography/equal.rb +21 -0
- data/lib/neography/errors.rb +60 -0
- data/lib/neography/index.rb +52 -0
- data/lib/neography/multi_json_parser.rb +28 -0
- data/lib/neography/neography.rb +10 -0
- data/lib/neography/node.rb +63 -0
- data/lib/neography/node_path.rb +29 -0
- data/lib/neography/node_relationship.rb +37 -0
- data/lib/neography/node_traverser.rb +146 -0
- data/lib/neography/path_traverser.rb +100 -0
- data/lib/neography/property.rb +110 -0
- data/lib/neography/property_container.rb +28 -0
- data/lib/neography/railtie.rb +19 -0
- data/lib/neography/relationship.rb +78 -0
- data/lib/neography/relationship_traverser.rb +80 -0
- data/lib/neography/rest.rb +99 -0
- data/lib/neography/rest/batch.rb +414 -0
- data/lib/neography/rest/clean.rb +17 -0
- data/lib/neography/rest/constraints.rb +38 -0
- data/lib/neography/rest/cypher.rb +29 -0
- data/lib/neography/rest/extensions.rb +21 -0
- data/lib/neography/rest/gremlin.rb +20 -0
- data/lib/neography/rest/helpers.rb +96 -0
- data/lib/neography/rest/node_auto_indexes.rb +60 -0
- data/lib/neography/rest/node_indexes.rb +139 -0
- data/lib/neography/rest/node_labels.rb +49 -0
- data/lib/neography/rest/node_paths.rb +49 -0
- data/lib/neography/rest/node_properties.rb +52 -0
- data/lib/neography/rest/node_relationships.rb +33 -0
- data/lib/neography/rest/node_traversal.rb +25 -0
- data/lib/neography/rest/nodes.rb +94 -0
- data/lib/neography/rest/other_node_relationships.rb +38 -0
- data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
- data/lib/neography/rest/relationship_indexes.rb +142 -0
- data/lib/neography/rest/relationship_properties.rb +52 -0
- data/lib/neography/rest/relationship_types.rb +11 -0
- data/lib/neography/rest/relationships.rb +16 -0
- data/lib/neography/rest/schema_indexes.rb +26 -0
- data/lib/neography/rest/spatial.rb +137 -0
- data/lib/neography/rest/transactions.rb +101 -0
- data/lib/neography/tasks.rb +207 -0
- data/lib/neography/version.rb +3 -0
- data/neography.gemspec +39 -0
- data/spec/integration/authorization_spec.rb +40 -0
- data/spec/integration/broken_spatial_spec.rb +28 -0
- data/spec/integration/index_spec.rb +71 -0
- data/spec/integration/neography_spec.rb +10 -0
- data/spec/integration/node_encoding_spec.rb +71 -0
- data/spec/integration/node_path_spec.rb +222 -0
- data/spec/integration/node_relationship_spec.rb +381 -0
- data/spec/integration/node_spec.rb +260 -0
- data/spec/integration/parsing_spec.rb +13 -0
- data/spec/integration/performance_spec.rb +17 -0
- data/spec/integration/relationship_spec.rb +37 -0
- data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
- data/spec/integration/rest_batch_spec.rb +604 -0
- data/spec/integration/rest_batch_streaming_spec.rb +51 -0
- data/spec/integration/rest_bulk_spec.rb +106 -0
- data/spec/integration/rest_constraints_spec.rb +72 -0
- data/spec/integration/rest_experimental_spec.rb +22 -0
- data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
- data/spec/integration/rest_header_spec.rb +15 -0
- data/spec/integration/rest_index_spec.rb +481 -0
- data/spec/integration/rest_labels_spec.rb +128 -0
- data/spec/integration/rest_node_spec.rb +274 -0
- data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
- data/spec/integration/rest_path_spec.rb +231 -0
- data/spec/integration/rest_plugin_spec.rb +177 -0
- data/spec/integration/rest_relationship_spec.rb +354 -0
- data/spec/integration/rest_relationship_types_spec.rb +18 -0
- data/spec/integration/rest_schema_index_spec.rb +32 -0
- data/spec/integration/rest_spatial_spec.rb +166 -0
- data/spec/integration/rest_transaction_spec.rb +166 -0
- data/spec/integration/rest_traverse_spec.rb +149 -0
- data/spec/integration/unmanaged_spec.rb +27 -0
- data/spec/matchers.rb +33 -0
- data/spec/neography_spec.rb +23 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/unit/config_spec.rb +135 -0
- data/spec/unit/connection_spec.rb +284 -0
- data/spec/unit/node_spec.rb +100 -0
- data/spec/unit/properties_spec.rb +285 -0
- data/spec/unit/relationship_spec.rb +118 -0
- data/spec/unit/rest/batch_spec.rb +262 -0
- data/spec/unit/rest/clean_spec.rb +16 -0
- data/spec/unit/rest/constraints_spec.rb +45 -0
- data/spec/unit/rest/cypher_spec.rb +20 -0
- data/spec/unit/rest/extensions_spec.rb +28 -0
- data/spec/unit/rest/gremlin_spec.rb +25 -0
- data/spec/unit/rest/helpers_spec.rb +124 -0
- data/spec/unit/rest/labels_spec.rb +77 -0
- data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
- data/spec/unit/rest/node_indexes_spec.rb +140 -0
- data/spec/unit/rest/node_paths_spec.rb +77 -0
- data/spec/unit/rest/node_properties_spec.rb +79 -0
- data/spec/unit/rest/node_relationships_spec.rb +57 -0
- data/spec/unit/rest/node_traversal_spec.rb +35 -0
- data/spec/unit/rest/nodes_spec.rb +187 -0
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
- data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
- data/spec/unit/rest/relationship_properties_spec.rb +79 -0
- data/spec/unit/rest/relationship_types_spec.rb +15 -0
- data/spec/unit/rest/relationships_spec.rb +21 -0
- data/spec/unit/rest/schema_index_spec.rb +30 -0
- data/spec/unit/rest/transactions_spec.rb +43 -0
- metadata +372 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe Batch do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "gets nodes" do
|
|
10
|
+
expected_body = [
|
|
11
|
+
{ "id" => 0, "method" => "GET", "to" => "/node/foo" },
|
|
12
|
+
{ "id" => 1, "method" => "GET", "to" => "/node/bar" }
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
16
|
+
subject.batch [:get_node, "foo"], [:get_node, "bar"]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "gets nodes without symbol" do
|
|
20
|
+
expected_body = [
|
|
21
|
+
{ "id" => 0, "method" => "GET", "to" => "/node/foo" },
|
|
22
|
+
{ "id" => 1, "method" => "GET", "to" => "/node/bar" }
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
26
|
+
subject.batch ["get_node", "foo"], [:get_node, "bar"]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "creates nodes" do
|
|
30
|
+
expected_body = [
|
|
31
|
+
{ "id" => 0, "method" => "POST", "to" => "/node", "body" => { "foo" => "bar" } },
|
|
32
|
+
{ "id" => 1, "method" => "POST", "to" => "/node", "body" => { "baz" => "qux" } }
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
36
|
+
subject.batch [:create_node, { "foo" => "bar" }], [:create_node, { "baz" => "qux" }]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "deletes nodes" do
|
|
40
|
+
expected_body = [
|
|
41
|
+
{ "id" => 0, "method" => "DELETE", "to" => "/node/foo" },
|
|
42
|
+
{ "id" => 1, "method" => "DELETE", "to" => "/node/bar" }
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
46
|
+
subject.batch [:delete_node, "foo"], [:delete_node, "bar"]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "creates unique nodes" do
|
|
50
|
+
expected_body = [
|
|
51
|
+
{ "id" => 0, "method" => "POST", "to" => "/index/node/foo?unique", "body" => { "key" => "bar", "value" => "baz", "properties" => "qux" } },
|
|
52
|
+
{ "id" => 1, "method" => "POST", "to" => "/index/node/quux?unique", "body" => { "key" => "corge", "value" => "grault", "properties" => "garply" } }
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
56
|
+
subject.batch [:create_unique_node, "foo", "bar", "baz", "qux" ],
|
|
57
|
+
[:create_unique_node, "quux", "corge", "grault", "garply"]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "adds nodes to an index" do
|
|
61
|
+
expected_body = [
|
|
62
|
+
{ "id" => 0, "method" => "POST", "to" => "/index/node/foo", "body" => { "uri" => "/node/qux", "key" => "bar", "value" => "baz" } },
|
|
63
|
+
{ "id" => 1, "method" => "POST", "to" => "/index/node/quux", "body" => { "uri" => "{0}", "key" => "corge", "value" => "grault" } }
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
67
|
+
subject.batch [:add_node_to_index, "foo", "bar", "baz", "qux" ],
|
|
68
|
+
[:add_node_to_index, "quux", "corge", "grault", "{0}"]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "gets nodes from an index" do
|
|
72
|
+
expected_body = [
|
|
73
|
+
{ "id" => 0, "method" => "GET", "to" => "/index/node/foo/bar/baz" },
|
|
74
|
+
{ "id" => 1, "method" => "GET", "to" => "/index/node/qux/quux/corge" }
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
78
|
+
subject.batch [:get_node_index, "foo", "bar", "baz" ],
|
|
79
|
+
[:get_node_index, "qux", "quux", "corge" ]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "deletes nodes from an index" do
|
|
83
|
+
expected_body = [
|
|
84
|
+
{ "id" => 0, "method" => "DELETE", "to" => "/index/node/index1/id1" },
|
|
85
|
+
{ "id" => 1, "method" => "DELETE", "to" => "/index/node/index2/key2/id2" },
|
|
86
|
+
{ "id" => 2, "method" => "DELETE", "to" => "/index/node/index3/key3/value3/id3" }
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
90
|
+
subject.batch [:remove_node_from_index, "index1", "id1", ],
|
|
91
|
+
[:remove_node_from_index, "index2", "key2", "id2" ],
|
|
92
|
+
[:remove_node_from_index, "index3", "key3", "value3", "id3" ]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "sets node properties" do
|
|
96
|
+
expected_body = [
|
|
97
|
+
{ "id" => 0, "method" => "PUT", "to" => "/node/index1/properties/key1", "body" => "value1" },
|
|
98
|
+
{ "id" => 1, "method" => "PUT", "to" => "/node/index2/properties/key2", "body" => "value2" }
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
102
|
+
subject.batch [:set_node_property, "index1", { "key1" => "value1" } ],
|
|
103
|
+
[:set_node_property, "index2", { "key2" => "value2" } ]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "resets node properties" do
|
|
107
|
+
expected_body = [
|
|
108
|
+
{ "id" => 0, "method" => "PUT", "to" => "/node/index1/properties", "body" => { "key1" => "value1" } },
|
|
109
|
+
{ "id" => 1, "method" => "PUT", "to" => "/node/index2/properties", "body" => { "key2" => "value2" } }
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
113
|
+
subject.batch [:reset_node_properties, "index1", { "key1" => "value1" } ],
|
|
114
|
+
[:reset_node_properties, "index2", { "key2" => "value2" } ]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "adds a node label" do
|
|
118
|
+
expected_body = [
|
|
119
|
+
{ "id" => 0, "method" => "POST", "to" => "{0}/labels", "body" => "foo" },
|
|
120
|
+
{ "id" => 1, "method" => "POST", "to" => "{0}/labels", "body" => "bar" },
|
|
121
|
+
]
|
|
122
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
123
|
+
subject.batch [:add_label, "{0}", "foo"],
|
|
124
|
+
[:add_label, "{0}", "bar"]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "gets node relationships" do
|
|
128
|
+
expected_body = [
|
|
129
|
+
{ "id" => 0, "method" => "GET", "to" => "/node/id1/relationships/direction1" },
|
|
130
|
+
{ "id" => 1, "method" => "GET", "to" => "/node/id2/relationships/all" }
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
134
|
+
subject.batch [:get_node_relationships, "id1", "direction1" ],
|
|
135
|
+
[:get_node_relationships, "id2" ]
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it "gets relationships" do
|
|
139
|
+
expected_body = [
|
|
140
|
+
{ "id" => 0, "method" => "GET", "to" => "/relationship/foo" },
|
|
141
|
+
{ "id" => 1, "method" => "GET", "to" => "/relationship/bar" }
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
145
|
+
subject.batch [:get_relationship, "foo"], [:get_relationship, "bar"]
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it "creates relationships" do
|
|
149
|
+
expected_body = [
|
|
150
|
+
{ "id" => 0, "method" => "POST", "to" => "/node/from1/relationships", "body" => { "to" => "/node/to1", "type" => "type1", "data" => "data1" } },
|
|
151
|
+
{ "id" => 1, "method" => "POST", "to" => "{0}/relationships", "body" => { "to" => "{1}", "type" => "type2", "data" => "data2" } }
|
|
152
|
+
]
|
|
153
|
+
|
|
154
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
155
|
+
subject.batch [:create_relationship, "type1", "from1", "to1", "data1" ],
|
|
156
|
+
[:create_relationship, "type2", "{0}", "{1}", "data2" ]
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it "deletes relationships" do
|
|
160
|
+
expected_body = [
|
|
161
|
+
{ "id" => 0, "method" => "DELETE", "to" => "/relationship/foo" },
|
|
162
|
+
{ "id" => 1, "method" => "DELETE", "to" => "/relationship/bar" }
|
|
163
|
+
]
|
|
164
|
+
|
|
165
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
166
|
+
subject.batch [:delete_relationship, "foo"], [:delete_relationship, "bar"]
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it "creates unique nodes" do
|
|
170
|
+
expected_body = [
|
|
171
|
+
{ "id" => 0, "method" => "POST", "to" => "/index/relationship/index1?unique", "body" => { "key" => "key1", "value" => "value1", "type" => "type1", "start" => "/node/node1", "end" => "/node/node2", "properties" => "properties" } },
|
|
172
|
+
{ "id" => 1, "method" => "POST", "to" => "/index/relationship/index2?unique", "body" => { "key" => "key2", "value" => "value2", "type" => "type2", "start" => "{0}", "end" => "{1}", "properties" => "properties" } }
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
176
|
+
subject.batch [:create_unique_relationship, "index1", "key1", "value1", "type1", "node1", "node2","properties" ],
|
|
177
|
+
[:create_unique_relationship, "index2", "key2", "value2", "type2", "{0}", "{1}", "properties" ]
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it "adds relationships to an index" do
|
|
181
|
+
expected_body = [
|
|
182
|
+
{ "id" => 0, "method" => "POST", "to" => "/index/relationship/index1", "body" => { "uri" => "/relationship/rel1", "key" => "key1", "value" => "value1" } },
|
|
183
|
+
{ "id" => 1, "method" => "POST", "to" => "/index/relationship/index2", "body" => { "uri" => "{0}", "key" => "key2", "value" => "value2" } }
|
|
184
|
+
]
|
|
185
|
+
|
|
186
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
187
|
+
subject.batch [:add_relationship_to_index, "index1", "key1", "value1", "rel1" ],
|
|
188
|
+
[:add_relationship_to_index, "index2", "key2", "value2", "{0}"]
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
it "gets relationships from an index" do
|
|
192
|
+
expected_body = [
|
|
193
|
+
{ "id" => 0, "method" => "GET", "to" => "/index/relationship/foo/bar/baz" },
|
|
194
|
+
{ "id" => 1, "method" => "GET", "to" => "/index/relationship/qux/quux/corge" }
|
|
195
|
+
]
|
|
196
|
+
|
|
197
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
198
|
+
subject.batch [:get_relationship_index, "foo", "bar", "baz" ],
|
|
199
|
+
[:get_relationship_index, "qux", "quux", "corge" ]
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
it "deletes relationships from an index" do
|
|
203
|
+
expected_body = [
|
|
204
|
+
{ "id" => 0, "method" => "DELETE", "to" => "/index/relationship/index1/id1" },
|
|
205
|
+
{ "id" => 1, "method" => "DELETE", "to" => "/index/relationship/index2/key2/id2" },
|
|
206
|
+
{ "id" => 2, "method" => "DELETE", "to" => "/index/relationship/index3/key3/value3/id3" }
|
|
207
|
+
]
|
|
208
|
+
|
|
209
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
210
|
+
subject.batch [:remove_relationship_from_index, "index1", "id1", ],
|
|
211
|
+
[:remove_relationship_from_index, "index2", "key2", "id2" ],
|
|
212
|
+
[:remove_relationship_from_index, "index3", "key3", "value3", "id3" ]
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
it "sets relationship properties" do
|
|
216
|
+
expected_body = [
|
|
217
|
+
{ "id" => 0, "method" => "PUT", "to" => "/relationship/index1/properties/key1", "body" => "value1" },
|
|
218
|
+
{ "id" => 1, "method" => "PUT", "to" => "/relationship/index2/properties/key2", "body" => "value2" }
|
|
219
|
+
]
|
|
220
|
+
|
|
221
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
222
|
+
subject.batch [:set_relationship_property, "index1", { "key1" => "value1" } ],
|
|
223
|
+
[:set_relationship_property, "index2", { "key2" => "value2" } ]
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
it "resets relationship properties" do
|
|
227
|
+
expected_body = [
|
|
228
|
+
{ "id" => 0, "method" => "PUT", "to" => "/relationship/index1/properties", "body" => { "key1" => "value1" } },
|
|
229
|
+
{ "id" => 1, "method" => "PUT", "to" => "{0}/properties", "body" => { "key2" => "value2" } }
|
|
230
|
+
]
|
|
231
|
+
|
|
232
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
233
|
+
subject.batch [:reset_relationship_properties, "index1", { "key1" => "value1" } ],
|
|
234
|
+
[:reset_relationship_properties, "{0}", { "key2" => "value2" } ]
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
it "batchs scripts" do
|
|
238
|
+
expected_body = [
|
|
239
|
+
{ "id" => 0, "method" => "POST", "to" => "/ext/GremlinPlugin/graphdb/execute_script", "body" => { "script" => "script1", "params" => "params1" } },
|
|
240
|
+
{ "id" => 1, "method" => "POST", "to" => "/ext/GremlinPlugin/graphdb/execute_script", "body" => { "script" => "script2", "params" => "params2" } }
|
|
241
|
+
]
|
|
242
|
+
|
|
243
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
244
|
+
subject.batch [:execute_script, "script1", "params1"],
|
|
245
|
+
[:execute_script, "script2", "params2"]
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
it "batchs queries" do
|
|
249
|
+
expected_body = [
|
|
250
|
+
{ "id" => 0, "method" => "POST", "to" => "/cypher", "body" => { "query" => "query1", "params" => "params1" } },
|
|
251
|
+
{ "id" => 1, "method" => "POST", "to" => "/cypher", "body" => { "query" => "query2" } }
|
|
252
|
+
]
|
|
253
|
+
|
|
254
|
+
expect(subject.connection).to receive(:post).with("/batch", json_match(:body, expected_body))
|
|
255
|
+
subject.batch [:execute_query, "query1", "params1"],
|
|
256
|
+
[:execute_query, "query2" ]
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe Clean do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "cleans the database" do
|
|
10
|
+
expect(subject.connection).to receive(:delete).with("/cleandb/secret-key")
|
|
11
|
+
subject.clean_database("yes_i_really_want_to_clean_the_database")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe Constraints do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "list constraints" do
|
|
10
|
+
expect(subject.connection).to receive(:get).with("/schema/constraint/")
|
|
11
|
+
subject.get_constraints
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "get constraints for a label" do
|
|
15
|
+
expect(subject.connection).to receive(:get).with("/schema/constraint/label")
|
|
16
|
+
subject.get_constraints("label")
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "create a unique constraint for a label" do
|
|
20
|
+
options = {
|
|
21
|
+
:body => '{"property_keys":["property"]}',
|
|
22
|
+
:headers => json_content_type
|
|
23
|
+
}
|
|
24
|
+
expect(subject.connection).to receive(:post).with("/schema/constraint/label/uniqueness/", options)
|
|
25
|
+
subject.create_unique_constraint("label", "property")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "get unique constraints for a label" do
|
|
29
|
+
expect(subject.connection).to receive(:get).with("/schema/constraint/label/uniqueness/")
|
|
30
|
+
subject.get_uniqueness("label")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "get a specific unique constraint for a label" do
|
|
34
|
+
expect(subject.connection).to receive(:get).with("/schema/constraint/label/uniqueness/property")
|
|
35
|
+
subject.get_unique_constraint("label", "property")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "can delete a constraint for a label" do
|
|
39
|
+
expect(subject.connection).to receive(:delete).with("/schema/constraint/label/uniqueness/property")
|
|
40
|
+
subject.drop_constraint("label","property")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe Cypher do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "executes a cypher query" do
|
|
10
|
+
options = {
|
|
11
|
+
:body=>"{\"query\":\"SOME QUERY\",\"params\":{\"foo\":\"bar\",\"baz\":\"qux\"}}",
|
|
12
|
+
:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json;stream=true;charset=UTF-8"}
|
|
13
|
+
}
|
|
14
|
+
expect(subject.connection).to receive(:post).with("/cypher", options)
|
|
15
|
+
subject.execute_query("SOME QUERY", { :foo => "bar", :baz => "qux" })
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe Extensions do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "executes an extensions get query" do
|
|
10
|
+
path = "/unmanaged_extension/test"
|
|
11
|
+
|
|
12
|
+
expect(subject.connection).to receive(:get).with(path)
|
|
13
|
+
subject.get_extension("/unmanaged_extension/test")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "executes an extensions post query" do
|
|
17
|
+
path = "/unmanaged_extension/test"
|
|
18
|
+
options = {
|
|
19
|
+
:body=>"{\"foo\":\"bar\",\"baz\":\"qux\"}",
|
|
20
|
+
:headers=>{"Content-Type"=>"application/json", "Accept"=>"application/json;stream=true"}
|
|
21
|
+
}
|
|
22
|
+
expect(subject.connection).to receive(:post).with(path, options)
|
|
23
|
+
subject.post_extension("/unmanaged_extension/test", { :foo => "bar", :baz => "qux" })
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe Gremlin do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
it "executes a gremlin script" do
|
|
10
|
+
options = {
|
|
11
|
+
:body=>"{\"script\":\"SOME SCRIPT\",\"params\":{\"foo\":\"bar\",\"baz\":\"qux\"}}",
|
|
12
|
+
:headers=>{"Content-Type"=>"application/json"}
|
|
13
|
+
}
|
|
14
|
+
expect(subject.connection).to receive(:post).with("/ext/GremlinPlugin/graphdb/execute_script", options)
|
|
15
|
+
subject.execute_script("SOME SCRIPT", { :foo => "bar", :baz => "qux" })
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "returns nil if script result is null" do
|
|
19
|
+
allow(subject.connection).to receive(:post).and_return("null")
|
|
20
|
+
expect(subject.execute_script("", {})).to be_nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Neography
|
|
4
|
+
class Rest
|
|
5
|
+
describe Helpers do
|
|
6
|
+
|
|
7
|
+
subject { Neography::Rest.new }
|
|
8
|
+
|
|
9
|
+
context "directions" do
|
|
10
|
+
|
|
11
|
+
[ :incoming, "incoming", :in, "in" ].each do |direction|
|
|
12
|
+
it "parses 'in' direction" do
|
|
13
|
+
expect(subject.parse_direction(direction)).to eq("in")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
[ :outgoing, "outgoing", :out, "out" ].each do |direction|
|
|
18
|
+
it "parses 'out' direction" do
|
|
19
|
+
expect(subject.parse_direction(direction)).to eq("out")
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "parses 'all' direction by default" do
|
|
24
|
+
expect(subject.parse_direction("foo")).to eq("all")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "options" do
|
|
30
|
+
let(:traversal) { NodeTraversal.new(nil) }
|
|
31
|
+
|
|
32
|
+
context "order" do
|
|
33
|
+
[ :breadth, "breadth", "breadth first", "breadthFirst", :wide, "wide" ].each do |order|
|
|
34
|
+
it "parses breadth first" do
|
|
35
|
+
expect(subject.send(:parse_order, order)).to eq("breadth first")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "parses depth first by default" do
|
|
40
|
+
expect(subject.send(:parse_order, "foo")).to eq("depth first")
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
context "uniqueness" do
|
|
45
|
+
[ :nodeglobal, "node global", "nodeglobal", "node_global" ].each do |order|
|
|
46
|
+
it "parses node global" do
|
|
47
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("node global")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
[ :nodepath, "node path", "nodepath", "node_path" ].each do |order|
|
|
52
|
+
it "parses node path" do
|
|
53
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("node path")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
[ :noderecent, "node recent", "noderecent", "node_recent" ].each do |order|
|
|
58
|
+
it "parses node recent" do
|
|
59
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("node recent")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
[ :relationshipglobal, "relationship global", "relationshipglobal", "relationship_global" ].each do |order|
|
|
64
|
+
it "parses relationship global" do
|
|
65
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("relationship global")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
[ :relationshippath, "relationship path", "relationshippath", "relationship_path" ].each do |order|
|
|
70
|
+
it "parses relationship path" do
|
|
71
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("relationship path")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
[ :relationshiprecent, "relationship recent", "relationshiprecent", "relationship_recent" ].each do |order|
|
|
76
|
+
it "parses relationship recent" do
|
|
77
|
+
expect(subject.send(:parse_uniqueness, order)).to eq("relationship recent")
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "parses none by default" do
|
|
82
|
+
expect(subject.send(:parse_uniqueness, "foo")).to eq("none")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context "depth" do
|
|
87
|
+
it "parses nil as nil" do
|
|
88
|
+
expect(subject.send(:parse_depth, nil)).to be_nil
|
|
89
|
+
end
|
|
90
|
+
it "parses 0 as 1" do
|
|
91
|
+
expect(subject.send(:parse_depth, "0")).to eq(1)
|
|
92
|
+
end
|
|
93
|
+
it "parses integers" do
|
|
94
|
+
expect(subject.send(:parse_depth, "42")).to eq(42)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
context "type" do
|
|
99
|
+
[ :relationship, "relationship", :relationships, "relationships" ].each do |type|
|
|
100
|
+
it "parses relationship" do
|
|
101
|
+
expect(subject.send(:parse_type, type)).to eq("relationship")
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
[ :path, "path", :paths, "paths" ].each do |type|
|
|
105
|
+
it "parses path" do
|
|
106
|
+
expect(subject.send(:parse_type, type)).to eq("path")
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
[ :fullpath, "fullpath", :fullpaths, "fullpaths" ].each do |type|
|
|
110
|
+
it "parses fullpath" do
|
|
111
|
+
expect(subject.send(:parse_type, type)).to eq("fullpath")
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "parses node by default" do
|
|
116
|
+
expect(subject.send(:parse_type, "foo")).to eq("node")
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|