neography 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTORS +5 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +46 -41
- data/lib/neography/rest.rb +41 -30
- data/lib/neography/version.rb +1 -1
- data/spec/integration/rest_index_spec.rb +6 -9
- data/spec/integration/rest_node_spec.rb +52 -69
- data/spec/integration/rest_path_spec.rb +65 -112
- data/spec/integration/rest_relationship_spec.rb +85 -151
- data/spec/integration/rest_traverse_spec.rb +89 -170
- metadata +4 -3
@@ -8,11 +8,9 @@ describe Neography::Rest do
|
|
8
8
|
describe "get path" do
|
9
9
|
it "can get a path between two nodes" do
|
10
10
|
new_node1 = @neo.create_node
|
11
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
12
11
|
new_node2 = @neo.create_node
|
13
|
-
|
14
|
-
|
15
|
-
path = @neo.get_path(new_node1[:id], new_node2[:id], {"type"=> "friends", "direction" => "out"})
|
12
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2005', "met" => "college"})
|
13
|
+
path = @neo.get_path(new_node1, new_node2, {"type"=> "friends", "direction" => "out"})
|
16
14
|
path["start"].should == new_node1["self"]
|
17
15
|
path["end"].should == new_node2["self"]
|
18
16
|
path["nodes"].should == [new_node1["self"], new_node2["self"]]
|
@@ -20,21 +18,16 @@ describe Neography::Rest do
|
|
20
18
|
|
21
19
|
it "can get the shortest path between two nodes" do
|
22
20
|
new_node1 = @neo.create_node
|
23
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
24
21
|
new_node2 = @neo.create_node
|
25
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
26
22
|
new_node3 = @neo.create_node
|
27
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
28
23
|
new_node4 = @neo.create_node
|
29
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
30
24
|
new_node5 = @neo.create_node
|
31
|
-
|
32
|
-
@neo.create_relationship("friends",
|
33
|
-
@neo.create_relationship("friends",
|
34
|
-
@neo.create_relationship("friends",
|
35
|
-
@neo.create_relationship("friends",
|
36
|
-
@neo.
|
37
|
-
path = @neo.get_path(new_node1[:id], new_node5[:id], {"type"=> "friends", "direction" => "out"}, depth=3, algorithm="shortestPath")
|
25
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
26
|
+
@neo.create_relationship("friends", new_node2, new_node3)
|
27
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
28
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
29
|
+
@neo.create_relationship("friends", new_node3, new_node5)
|
30
|
+
path = @neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=3, algorithm="shortestPath")
|
38
31
|
path["start"].should == new_node1["self"]
|
39
32
|
path["end"].should == new_node5["self"]
|
40
33
|
path["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node5["self"]]
|
@@ -42,21 +35,16 @@ describe Neography::Rest do
|
|
42
35
|
|
43
36
|
it "can get a simple path between two nodes" do
|
44
37
|
new_node1 = @neo.create_node
|
45
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
46
38
|
new_node2 = @neo.create_node
|
47
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
48
39
|
new_node3 = @neo.create_node
|
49
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
50
40
|
new_node4 = @neo.create_node
|
51
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
52
41
|
new_node5 = @neo.create_node
|
53
|
-
|
54
|
-
@neo.create_relationship("friends",
|
55
|
-
@neo.create_relationship("friends",
|
56
|
-
@neo.create_relationship("friends",
|
57
|
-
@neo.create_relationship("friends",
|
58
|
-
@neo.
|
59
|
-
path = @neo.get_path(new_node1[:id], new_node5[:id], {"type"=> "friends", "direction" => "out"}, depth=3, algorithm="simplePaths")
|
42
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
43
|
+
@neo.create_relationship("friends", new_node2, new_node3)
|
44
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
45
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
46
|
+
@neo.create_relationship("friends", new_node3, new_node5)
|
47
|
+
path = @neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=3, algorithm="simplePaths")
|
60
48
|
path["start"].should == new_node1["self"]
|
61
49
|
path["end"].should == new_node5["self"]
|
62
50
|
path["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node5["self"]]
|
@@ -64,43 +52,33 @@ describe Neography::Rest do
|
|
64
52
|
|
65
53
|
it "fails to get a path between two nodes 3 nodes apart when using max depth of 2" do
|
66
54
|
new_node1 = @neo.create_node
|
67
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
68
55
|
new_node2 = @neo.create_node
|
69
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
70
56
|
new_node3 = @neo.create_node
|
71
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
72
57
|
new_node4 = @neo.create_node
|
73
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
74
58
|
new_node5 = @neo.create_node
|
75
|
-
|
76
|
-
@neo.create_relationship("friends",
|
77
|
-
@neo.create_relationship("friends",
|
78
|
-
@neo.create_relationship("friends",
|
79
|
-
@neo.create_relationship("friends",
|
80
|
-
@neo.
|
81
|
-
path = @neo.get_path(new_node1[:id], new_node5[:id], {"type"=> "friends", "direction" => "out"}, depth=2, algorithm="shortestPath")
|
59
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
60
|
+
@neo.create_relationship("friends", new_node2, new_node3)
|
61
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
62
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
63
|
+
@neo.create_relationship("friends", new_node3, new_node5)
|
64
|
+
path = @neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=2, algorithm="shortestPath")
|
82
65
|
path["start"].should be_nil
|
83
66
|
path["end"].should be_nil
|
84
67
|
end
|
85
68
|
|
86
69
|
it "can get a path between two nodes of a specific relationship" do
|
87
70
|
new_node1 = @neo.create_node
|
88
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
89
71
|
new_node2 = @neo.create_node
|
90
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
91
72
|
new_node3 = @neo.create_node
|
92
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
93
73
|
new_node4 = @neo.create_node
|
94
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
95
74
|
new_node5 = @neo.create_node
|
96
|
-
|
97
|
-
@neo.create_relationship("classmates",
|
98
|
-
@neo.create_relationship("
|
99
|
-
@neo.create_relationship("friends",
|
100
|
-
@neo.create_relationship("friends",
|
101
|
-
@neo.create_relationship("friends",
|
102
|
-
@neo.
|
103
|
-
path = @neo.get_path(new_node1[:id], new_node5[:id], {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="shortestPath")
|
75
|
+
@neo.create_relationship("classmates", new_node1, new_node2)
|
76
|
+
@neo.create_relationship("classmates", new_node2, new_node5)
|
77
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
78
|
+
@neo.create_relationship("friends", new_node2, new_node3)
|
79
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
80
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
81
|
+
path = @neo.get_path(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="shortestPath")
|
104
82
|
path["start"].should == new_node1["self"]
|
105
83
|
path["end"].should == new_node5["self"]
|
106
84
|
path["nodes"].should == [new_node1["self"], new_node2["self"], new_node3["self"], new_node4["self"], new_node5["self"]]
|
@@ -110,22 +88,17 @@ describe Neography::Rest do
|
|
110
88
|
describe "get paths" do
|
111
89
|
it "can get the shortest paths between two nodes" do
|
112
90
|
new_node1 = @neo.create_node
|
113
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
114
91
|
new_node2 = @neo.create_node
|
115
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
116
92
|
new_node3 = @neo.create_node
|
117
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
118
93
|
new_node4 = @neo.create_node
|
119
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
120
94
|
new_node5 = @neo.create_node
|
121
|
-
|
122
|
-
@neo.create_relationship("friends",
|
123
|
-
@neo.create_relationship("friends",
|
124
|
-
@neo.create_relationship("friends",
|
125
|
-
@neo.create_relationship("friends",
|
126
|
-
@neo.create_relationship("friends",
|
127
|
-
@neo.
|
128
|
-
paths = @neo.get_paths(new_node1[:id], new_node5[:id], {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="shortestPath")
|
95
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
96
|
+
@neo.create_relationship("friends", new_node2, new_node5)
|
97
|
+
@neo.create_relationship("friends", new_node1, new_node3)
|
98
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
99
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
100
|
+
@neo.create_relationship("friends", new_node3, new_node5)
|
101
|
+
paths = @neo.get_paths(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="shortestPath")
|
129
102
|
paths.length.should == 2
|
130
103
|
paths[0]["length"].should == 2
|
131
104
|
paths[0]["start"].should == new_node1["self"]
|
@@ -137,22 +110,17 @@ describe Neography::Rest do
|
|
137
110
|
|
138
111
|
it "can get all paths between two nodes" do
|
139
112
|
new_node1 = @neo.create_node
|
140
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
141
113
|
new_node2 = @neo.create_node
|
142
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
143
114
|
new_node3 = @neo.create_node
|
144
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
145
115
|
new_node4 = @neo.create_node
|
146
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
147
116
|
new_node5 = @neo.create_node
|
148
|
-
|
149
|
-
@neo.create_relationship("friends",
|
150
|
-
@neo.create_relationship("friends",
|
151
|
-
@neo.create_relationship("friends",
|
152
|
-
@neo.create_relationship("friends",
|
153
|
-
@neo.create_relationship("friends",
|
154
|
-
@neo.
|
155
|
-
paths = @neo.get_paths(new_node1[:id], new_node5[:id], {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="allPaths")
|
117
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
118
|
+
@neo.create_relationship("friends", new_node2, new_node5)
|
119
|
+
@neo.create_relationship("friends", new_node1, new_node3)
|
120
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
121
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
122
|
+
@neo.create_relationship("friends", new_node3, new_node5)
|
123
|
+
paths = @neo.get_paths(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="allPaths")
|
156
124
|
paths.length.should == 3
|
157
125
|
paths[0]["length"].should == 2
|
158
126
|
paths[0]["start"].should == new_node1["self"]
|
@@ -167,23 +135,18 @@ describe Neography::Rest do
|
|
167
135
|
|
168
136
|
it "can get all simple paths between two nodes" do
|
169
137
|
new_node1 = @neo.create_node
|
170
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
171
138
|
new_node2 = @neo.create_node
|
172
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
173
139
|
new_node3 = @neo.create_node
|
174
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
175
140
|
new_node4 = @neo.create_node
|
176
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
177
141
|
new_node5 = @neo.create_node
|
178
|
-
|
179
|
-
@neo.create_relationship("friends",
|
180
|
-
@neo.create_relationship("friends", new_node2
|
181
|
-
@neo.create_relationship("friends",
|
182
|
-
@neo.create_relationship("friends",
|
183
|
-
@neo.create_relationship("friends",
|
184
|
-
@neo.create_relationship("friends",
|
185
|
-
@neo.
|
186
|
-
paths = @neo.get_paths(new_node1[:id], new_node5[:id], {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="allSimplePaths")
|
142
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
143
|
+
@neo.create_relationship("friends", new_node2, new_node1)
|
144
|
+
@neo.create_relationship("friends", new_node2, new_node5)
|
145
|
+
@neo.create_relationship("friends", new_node1, new_node3)
|
146
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
147
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
148
|
+
@neo.create_relationship("friends", new_node3, new_node5)
|
149
|
+
paths = @neo.get_paths(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=4, algorithm="allSimplePaths")
|
187
150
|
paths.length.should == 3
|
188
151
|
paths[0]["length"].should == 2
|
189
152
|
paths[0]["start"].should == new_node1["self"]
|
@@ -198,22 +161,17 @@ describe Neography::Rest do
|
|
198
161
|
|
199
162
|
it "can get paths between two nodes of max depth 2" do
|
200
163
|
new_node1 = @neo.create_node
|
201
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
202
164
|
new_node2 = @neo.create_node
|
203
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
204
165
|
new_node3 = @neo.create_node
|
205
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
206
166
|
new_node4 = @neo.create_node
|
207
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
208
167
|
new_node5 = @neo.create_node
|
209
|
-
|
210
|
-
@neo.create_relationship("friends",
|
211
|
-
@neo.create_relationship("friends",
|
212
|
-
@neo.create_relationship("friends",
|
213
|
-
@neo.create_relationship("friends",
|
214
|
-
@neo.create_relationship("friends",
|
215
|
-
@neo.
|
216
|
-
paths = @neo.get_paths(new_node1[:id], new_node5[:id], {"type"=> "friends", "direction" => "out"}, depth=2, algorithm="allPaths")
|
168
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
169
|
+
@neo.create_relationship("friends", new_node2, new_node5)
|
170
|
+
@neo.create_relationship("friends", new_node1, new_node3)
|
171
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
172
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
173
|
+
@neo.create_relationship("friends", new_node3, new_node5)
|
174
|
+
paths = @neo.get_paths(new_node1, new_node5, {"type"=> "friends", "direction" => "out"}, depth=2, algorithm="allPaths")
|
217
175
|
paths.length.should == 2
|
218
176
|
paths[0]["length"].should == 2
|
219
177
|
paths[0]["start"].should == new_node1["self"]
|
@@ -224,24 +182,19 @@ describe Neography::Rest do
|
|
224
182
|
|
225
183
|
it "can get paths between two nodes of a specific relationship" do
|
226
184
|
new_node1 = @neo.create_node
|
227
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
228
185
|
new_node2 = @neo.create_node
|
229
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
230
186
|
new_node3 = @neo.create_node
|
231
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
232
187
|
new_node4 = @neo.create_node
|
233
|
-
new_node4[:id] = new_node4["self"].split('/').last
|
234
188
|
new_node5 = @neo.create_node
|
235
|
-
|
236
|
-
@neo.create_relationship("classmates",
|
237
|
-
@neo.create_relationship("
|
238
|
-
@neo.create_relationship("friends",
|
239
|
-
@neo.create_relationship("friends",
|
240
|
-
@neo.create_relationship("friends",
|
241
|
-
@neo.create_relationship("
|
242
|
-
@neo.create_relationship("classmates",
|
243
|
-
@neo.
|
244
|
-
paths = @neo.get_paths(new_node1[:id], new_node5[:id], {"type"=> "classmates", "direction" => "out"}, depth=4, algorithm="allPaths")
|
189
|
+
@neo.create_relationship("classmates", new_node1, new_node2)
|
190
|
+
@neo.create_relationship("classmates", new_node2, new_node5)
|
191
|
+
@neo.create_relationship("friends", new_node1, new_node2)
|
192
|
+
@neo.create_relationship("friends", new_node2, new_node3)
|
193
|
+
@neo.create_relationship("friends", new_node3, new_node4)
|
194
|
+
@neo.create_relationship("friends", new_node4, new_node5)
|
195
|
+
@neo.create_relationship("classmates", new_node1, new_node3)
|
196
|
+
@neo.create_relationship("classmates", new_node3, new_node5)
|
197
|
+
paths = @neo.get_paths(new_node1, new_node5, {"type"=> "classmates", "direction" => "out"}, depth=4, algorithm="allPaths")
|
245
198
|
paths[0]["length"].should == 2
|
246
199
|
paths[0]["start"].should == new_node1["self"]
|
247
200
|
paths[0]["end"].should == new_node5["self"]
|
@@ -8,10 +8,8 @@ describe Neography::Rest do
|
|
8
8
|
describe "create_relationship" do
|
9
9
|
it "can create an empty relationship" do
|
10
10
|
new_node1 = @neo.create_node
|
11
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
12
11
|
new_node2 = @neo.create_node
|
13
|
-
|
14
|
-
new_relationship = @neo.create_relationship("friends", new_node1[:id], new_node2[:id])
|
12
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
15
13
|
new_relationship["start"].should_not be_nil
|
16
14
|
new_relationship["end"].should_not be_nil
|
17
15
|
end
|
@@ -21,16 +19,14 @@ describe Neography::Rest do
|
|
21
19
|
new_node1[:id] = new_node1["self"].split('/').last
|
22
20
|
new_node2 = @neo.create_node
|
23
21
|
new_node2[:id] = new_node2["self"].split('/').last
|
24
|
-
new_relationship = @neo.create_relationship("friends", new_node1
|
22
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010'})
|
25
23
|
new_relationship["data"]["since"].should == '10-1-2010'
|
26
24
|
end
|
27
25
|
|
28
26
|
it "can create a relationship with more than one property" do
|
29
27
|
new_node1 = @neo.create_node
|
30
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
31
28
|
new_node2 = @neo.create_node
|
32
|
-
|
33
|
-
new_relationship = @neo.create_relationship("friends", new_node1[:id], new_node2[:id], {"since" => '10-1-2010', "met" => "college"})
|
29
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
34
30
|
new_relationship["data"]["since"].should == '10-1-2010'
|
35
31
|
new_relationship["data"]["met"].should == "college"
|
36
32
|
end
|
@@ -39,14 +35,11 @@ describe Neography::Rest do
|
|
39
35
|
describe "set_relationship_properties" do
|
40
36
|
it "can set a relationship's properties" do
|
41
37
|
new_node1 = @neo.create_node
|
42
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
43
38
|
new_node2 = @neo.create_node
|
44
|
-
|
45
|
-
|
46
|
-
new_relationship
|
47
|
-
@neo.
|
48
|
-
@neo.set_relationship_properties(new_relationship[:id], {"roommates" => "no"})
|
49
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id])
|
39
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
40
|
+
@neo.set_relationship_properties(new_relationship, {"since" => '10-1-2010', "met" => "college"})
|
41
|
+
@neo.set_relationship_properties(new_relationship, {"roommates" => "no"})
|
42
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship)
|
50
43
|
relationship_properties["since"].should == '10-1-2010'
|
51
44
|
relationship_properties["met"].should == "college"
|
52
45
|
relationship_properties["roommates"].should == "no"
|
@@ -54,13 +47,11 @@ describe Neography::Rest do
|
|
54
47
|
|
55
48
|
it "it fails to set properties on a relationship that does not exist" do
|
56
49
|
new_node1 = @neo.create_node
|
57
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
58
50
|
new_node2 = @neo.create_node
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
@neo.
|
63
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id].to_i + 10000)
|
51
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
52
|
+
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
53
|
+
@neo.set_relationship_properties(fake_relationship, {"since" => '10-1-2010', "met" => "college"})
|
54
|
+
relationship_properties = @neo.get_relationship_properties(fake_relationship)
|
64
55
|
relationship_properties.should be_nil
|
65
56
|
end
|
66
57
|
end
|
@@ -68,14 +59,11 @@ describe Neography::Rest do
|
|
68
59
|
describe "reset_relationship_properties" do
|
69
60
|
it "can reset a relationship's properties" do
|
70
61
|
new_node1 = @neo.create_node
|
71
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
72
62
|
new_node2 = @neo.create_node
|
73
|
-
|
74
|
-
|
75
|
-
new_relationship
|
76
|
-
@neo.
|
77
|
-
@neo.reset_relationship_properties(new_relationship[:id], {"roommates" => "no"})
|
78
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id])
|
63
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
64
|
+
@neo.set_relationship_properties(new_relationship, {"since" => '10-1-2010', "met" => "college"})
|
65
|
+
@neo.reset_relationship_properties(new_relationship, {"roommates" => "no"})
|
66
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship)
|
79
67
|
relationship_properties["since"].should be_nil
|
80
68
|
relationship_properties["met"].should be_nil
|
81
69
|
relationship_properties["roommates"].should == "no"
|
@@ -83,13 +71,11 @@ describe Neography::Rest do
|
|
83
71
|
|
84
72
|
it "it fails to reset properties on a relationship that does not exist" do
|
85
73
|
new_node1 = @neo.create_node
|
86
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
87
74
|
new_node2 = @neo.create_node
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
@neo.
|
92
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id].to_i + 10000)
|
75
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
76
|
+
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
77
|
+
@neo.reset_relationship_properties(fake_relationship, {"since" => '10-1-2010', "met" => "college"})
|
78
|
+
relationship_properties = @neo.get_relationship_properties(fake_relationship)
|
93
79
|
relationship_properties.should be_nil
|
94
80
|
end
|
95
81
|
end
|
@@ -97,24 +83,18 @@ describe Neography::Rest do
|
|
97
83
|
describe "get_relationship_properties" do
|
98
84
|
it "can get all of a relationship's properties" do
|
99
85
|
new_node1 = @neo.create_node
|
100
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
101
86
|
new_node2 = @neo.create_node
|
102
|
-
|
103
|
-
|
104
|
-
new_relationship[:id] = new_relationship["self"].split('/').last
|
105
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id])
|
87
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
88
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship)
|
106
89
|
relationship_properties["since"].should == '10-1-2010'
|
107
90
|
relationship_properties["met"].should == "college"
|
108
91
|
end
|
109
92
|
|
110
93
|
it "can get some of a relationship's properties" do
|
111
94
|
new_node1 = @neo.create_node
|
112
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
113
95
|
new_node2 = @neo.create_node
|
114
|
-
|
115
|
-
|
116
|
-
new_relationship[:id] = new_relationship["self"].split('/').last
|
117
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id], ["since", "roommates"])
|
96
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college", "roommates" => "no"})
|
97
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship, ["since", "roommates"])
|
118
98
|
relationship_properties["since"].should == '10-1-2010'
|
119
99
|
relationship_properties["met"].should be_nil
|
120
100
|
relationship_properties["roommates"].should == "no"
|
@@ -122,34 +102,26 @@ describe Neography::Rest do
|
|
122
102
|
|
123
103
|
it "returns nil if it gets the properties on a relationship that does not have any" do
|
124
104
|
new_node1 = @neo.create_node
|
125
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
126
105
|
new_node2 = @neo.create_node
|
127
|
-
|
128
|
-
|
129
|
-
new_relationship[:id] = new_relationship["self"].split('/').last
|
130
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id])
|
106
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
107
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship)
|
131
108
|
relationship_properties.should be_nil
|
132
109
|
end
|
133
110
|
|
134
111
|
it "returns nil if it tries to get some of the properties on a relationship that does not have any" do
|
135
112
|
new_node1 = @neo.create_node
|
136
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
137
113
|
new_node2 = @neo.create_node
|
138
|
-
|
139
|
-
|
140
|
-
new_relationship[:id] = new_relationship["self"].split('/').last
|
141
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id], ["since", "roommates"])
|
114
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
115
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship, ["since", "roommates"])
|
142
116
|
relationship_properties.should be_nil
|
143
117
|
end
|
144
118
|
|
145
119
|
it "returns nil if it fails to get properties on a relationship that does not exist" do
|
146
120
|
new_node1 = @neo.create_node
|
147
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
148
121
|
new_node2 = @neo.create_node
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id].to_i + 10000)
|
122
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
123
|
+
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
124
|
+
relationship_properties = @neo.get_relationship_properties(fake_relationship)
|
153
125
|
relationship_properties.should be_nil
|
154
126
|
end
|
155
127
|
end
|
@@ -157,48 +129,37 @@ describe Neography::Rest do
|
|
157
129
|
describe "remove_relationship_properties" do
|
158
130
|
it "can remove a relationship's properties" do
|
159
131
|
new_node1 = @neo.create_node
|
160
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
161
132
|
new_node2 = @neo.create_node
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
@neo.remove_relationship_properties(new_relationship[:id])
|
166
|
-
@neo.get_relationship_properties(new_relationship[:id]).should be_nil
|
133
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
134
|
+
@neo.remove_relationship_properties(new_relationship)
|
135
|
+
@neo.get_relationship_properties(new_relationship).should be_nil
|
167
136
|
end
|
168
137
|
|
169
138
|
it "returns nil if it fails to remove the properties of a relationship that does not exist" do
|
170
139
|
new_node1 = @neo.create_node
|
171
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
172
140
|
new_node2 = @neo.create_node
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
@neo.
|
177
|
-
@neo.get_relationship_properties(new_relationship[:id].to_i + 10000).should be_nil
|
141
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
142
|
+
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
143
|
+
@neo.remove_relationship_properties(fake_relationship).should be_nil
|
144
|
+
@neo.get_relationship_properties(fake_relationship).should be_nil
|
178
145
|
end
|
179
146
|
|
180
147
|
it "can remove a specific relationship property" do
|
181
148
|
new_node1 = @neo.create_node
|
182
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
183
149
|
new_node2 = @neo.create_node
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
@neo.remove_relationship_properties(new_relationship[:id], "met")
|
188
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id], ["met", "since"])
|
150
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
151
|
+
@neo.remove_relationship_properties(new_relationship, "met")
|
152
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship, ["met", "since"])
|
189
153
|
relationship_properties["met"].should be_nil
|
190
154
|
relationship_properties["since"].should == '10-1-2010'
|
191
155
|
end
|
192
156
|
|
193
157
|
it "can remove more than one relationship property" do
|
194
158
|
new_node1 = @neo.create_node
|
195
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
196
159
|
new_node2 = @neo.create_node
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
@neo.remove_relationship_properties(new_relationship[:id], ["met", "since"])
|
201
|
-
relationship_properties = @neo.get_relationship_properties(new_relationship[:id], ["since", "met", "roommates"])
|
160
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college", "roommates" => "no"})
|
161
|
+
@neo.remove_relationship_properties(new_relationship, ["met", "since"])
|
162
|
+
relationship_properties = @neo.get_relationship_properties(new_relationship, ["since", "met", "roommates"])
|
202
163
|
relationship_properties["met"].should be_nil
|
203
164
|
relationship_properties["since"].should be_nil
|
204
165
|
relationship_properties["roommates"].should == "no"
|
@@ -208,37 +169,29 @@ describe Neography::Rest do
|
|
208
169
|
describe "delete_relationship" do
|
209
170
|
it "can delete an existing relationship" do
|
210
171
|
new_node1 = @neo.create_node
|
211
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
212
172
|
new_node2 = @neo.create_node
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
@neo.delete_relationship(new_relationship[:id])
|
217
|
-
relationships = @neo.get_node_relationships(new_node1[:id])
|
173
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
174
|
+
@neo.delete_relationship(new_relationship)
|
175
|
+
relationships = @neo.get_node_relationships(new_node1)
|
218
176
|
relationships.should be_nil
|
219
177
|
end
|
220
178
|
|
221
179
|
it "returns nil if it tries to delete a relationship that does not exist" do
|
222
180
|
new_node1 = @neo.create_node
|
223
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
224
181
|
new_node2 = @neo.create_node
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
existing_relationship = @neo.delete_relationship(new_relationship[:id].to_i + 1000)
|
182
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
183
|
+
fake_relationship = new_relationship["self"].split('/').last.to_i + 1000
|
184
|
+
existing_relationship = @neo.delete_relationship(fake_relationship)
|
229
185
|
existing_relationship.should be_nil
|
230
186
|
end
|
231
187
|
|
232
188
|
it "returns nil if it tries to delete a relationship that has already been deleted" do
|
233
189
|
new_node1 = @neo.create_node
|
234
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
235
190
|
new_node2 = @neo.create_node
|
236
|
-
|
237
|
-
|
238
|
-
new_relationship[:id] = new_relationship["self"].split('/').last
|
239
|
-
existing_relationship = @neo.delete_relationship(new_relationship[:id])
|
191
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2010', "met" => "college"})
|
192
|
+
existing_relationship = @neo.delete_relationship(new_relationship)
|
240
193
|
existing_relationship.should be_nil
|
241
|
-
existing_relationship = @neo.delete_relationship(new_relationship
|
194
|
+
existing_relationship = @neo.delete_relationship(new_relationship)
|
242
195
|
existing_relationship.should be_nil
|
243
196
|
end
|
244
197
|
end
|
@@ -246,14 +199,12 @@ describe Neography::Rest do
|
|
246
199
|
describe "get_node_relationships" do
|
247
200
|
it "can get a node's relationship" do
|
248
201
|
new_node1 = @neo.create_node
|
249
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
250
202
|
new_node2 = @neo.create_node
|
251
|
-
|
252
|
-
|
253
|
-
relationships = @neo.get_node_relationships(new_node1[:id])
|
203
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2005', "met" => "college"})
|
204
|
+
relationships = @neo.get_node_relationships(new_node1)
|
254
205
|
relationships.should_not be_nil
|
255
|
-
relationships[0]["start"].
|
256
|
-
relationships[0]["end"].
|
206
|
+
relationships[0]["start"].should == new_node1["self"]
|
207
|
+
relationships[0]["end"].should == new_node2["self"]
|
257
208
|
relationships[0]["type"].should == "friends"
|
258
209
|
relationships[0]["data"]["met"].should == "college"
|
259
210
|
relationships[0]["data"]["since"].should == '10-1-2005'
|
@@ -261,22 +212,19 @@ describe Neography::Rest do
|
|
261
212
|
|
262
213
|
it "can get a node's multiple relationships" do
|
263
214
|
new_node1 = @neo.create_node
|
264
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
265
215
|
new_node2 = @neo.create_node
|
266
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
267
216
|
new_node3 = @neo.create_node
|
268
|
-
|
269
|
-
new_relationship = @neo.create_relationship("
|
270
|
-
|
271
|
-
relationships = @neo.get_node_relationships(new_node1[:id])
|
217
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2005', "met" => "college"})
|
218
|
+
new_relationship = @neo.create_relationship("enemies", new_node1, new_node3, {"since" => '10-2-2010', "met" => "work"})
|
219
|
+
relationships = @neo.get_node_relationships(new_node1)
|
272
220
|
relationships.should_not be_nil
|
273
|
-
relationships[0]["start"].
|
274
|
-
relationships[0]["end"].
|
221
|
+
relationships[0]["start"].should == new_node1["self"]
|
222
|
+
relationships[0]["end"].should == new_node2["self"]
|
275
223
|
relationships[0]["type"].should == "friends"
|
276
224
|
relationships[0]["data"]["met"].should == "college"
|
277
225
|
relationships[0]["data"]["since"].should == '10-1-2005'
|
278
|
-
relationships[1]["start"].
|
279
|
-
relationships[1]["end"].
|
226
|
+
relationships[1]["start"].should == new_node1["self"]
|
227
|
+
relationships[1]["end"].should == new_node3["self"]
|
280
228
|
relationships[1]["type"].should == "enemies"
|
281
229
|
relationships[1]["data"]["met"].should == "work"
|
282
230
|
relationships[1]["data"]["since"].should == '10-2-2010'
|
@@ -284,17 +232,14 @@ describe Neography::Rest do
|
|
284
232
|
|
285
233
|
it "can get a node's outgoing relationship" do
|
286
234
|
new_node1 = @neo.create_node
|
287
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
288
235
|
new_node2 = @neo.create_node
|
289
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
290
236
|
new_node3 = @neo.create_node
|
291
|
-
|
292
|
-
new_relationship = @neo.create_relationship("
|
293
|
-
|
294
|
-
relationships = @neo.get_node_relationships(new_node1[:id], "out")
|
237
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2005', "met" => "college"})
|
238
|
+
new_relationship = @neo.create_relationship("enemies", new_node3, new_node1, {"since" => '10-2-2010', "met" => "work"})
|
239
|
+
relationships = @neo.get_node_relationships(new_node1, "out")
|
295
240
|
relationships.should_not be_nil
|
296
|
-
relationships[0]["start"].
|
297
|
-
relationships[0]["end"].
|
241
|
+
relationships[0]["start"].should == new_node1["self"]
|
242
|
+
relationships[0]["end"].should == new_node2["self"]
|
298
243
|
relationships[0]["type"].should == "friends"
|
299
244
|
relationships[0]["data"]["met"].should == "college"
|
300
245
|
relationships[0]["data"]["since"].should == '10-1-2005'
|
@@ -303,17 +248,14 @@ describe Neography::Rest do
|
|
303
248
|
|
304
249
|
it "can get a node's incoming relationship" do
|
305
250
|
new_node1 = @neo.create_node
|
306
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
307
251
|
new_node2 = @neo.create_node
|
308
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
309
252
|
new_node3 = @neo.create_node
|
310
|
-
|
311
|
-
new_relationship = @neo.create_relationship("
|
312
|
-
|
313
|
-
relationships = @neo.get_node_relationships(new_node1[:id], "in")
|
253
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2005', "met" => "college"})
|
254
|
+
new_relationship = @neo.create_relationship("enemies", new_node3, new_node1, {"since" => '10-2-2010', "met" => "work"})
|
255
|
+
relationships = @neo.get_node_relationships(new_node1, "in")
|
314
256
|
relationships.should_not be_nil
|
315
|
-
relationships[0]["start"].
|
316
|
-
relationships[0]["end"].
|
257
|
+
relationships[0]["start"].should == new_node3["self"]
|
258
|
+
relationships[0]["end"].should == new_node1["self"]
|
317
259
|
relationships[0]["type"].should == "enemies"
|
318
260
|
relationships[0]["data"]["met"].should == "work"
|
319
261
|
relationships[0]["data"]["since"].should == '10-2-2010'
|
@@ -322,17 +264,14 @@ describe Neography::Rest do
|
|
322
264
|
|
323
265
|
it "can get a specific type of node relationships" do
|
324
266
|
new_node1 = @neo.create_node
|
325
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
326
267
|
new_node2 = @neo.create_node
|
327
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
328
268
|
new_node3 = @neo.create_node
|
329
|
-
|
330
|
-
new_relationship = @neo.create_relationship("
|
331
|
-
|
332
|
-
relationships = @neo.get_node_relationships(new_node1[:id], "all", "friends")
|
269
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2005', "met" => "college"})
|
270
|
+
new_relationship = @neo.create_relationship("enemies", new_node1, new_node3, {"since" => '10-2-2010', "met" => "work"})
|
271
|
+
relationships = @neo.get_node_relationships(new_node1, "all", "friends")
|
333
272
|
relationships.should_not be_nil
|
334
|
-
relationships[0]["start"].
|
335
|
-
relationships[0]["end"].
|
273
|
+
relationships[0]["start"].should == new_node1["self"]
|
274
|
+
relationships[0]["end"].should == new_node2["self"]
|
336
275
|
relationships[0]["type"].should == "friends"
|
337
276
|
relationships[0]["data"]["met"].should == "college"
|
338
277
|
relationships[0]["data"]["since"].should == '10-1-2005'
|
@@ -341,20 +280,16 @@ describe Neography::Rest do
|
|
341
280
|
|
342
281
|
it "can get a specific type and direction of a node relationships" do
|
343
282
|
new_node1 = @neo.create_node
|
344
|
-
new_node1[:id] = new_node1["self"].split('/').last
|
345
283
|
new_node2 = @neo.create_node
|
346
|
-
new_node2[:id] = new_node2["self"].split('/').last
|
347
284
|
new_node3 = @neo.create_node
|
348
|
-
new_node3[:id] = new_node3["self"].split('/').last
|
349
285
|
new_node4 = @neo.create_node
|
350
|
-
|
351
|
-
new_relationship = @neo.create_relationship("
|
352
|
-
new_relationship = @neo.create_relationship("enemies",
|
353
|
-
|
354
|
-
relationships = @neo.get_node_relationships(new_node1[:id], "in", "enemies")
|
286
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"since" => '10-1-2005', "met" => "college"})
|
287
|
+
new_relationship = @neo.create_relationship("enemies", new_node1, new_node3, {"since" => '10-2-2010', "met" => "work"})
|
288
|
+
new_relationship = @neo.create_relationship("enemies", new_node4, new_node1, {"since" => '10-3-2010', "met" => "gym"})
|
289
|
+
relationships = @neo.get_node_relationships(new_node1, "in", "enemies")
|
355
290
|
relationships.should_not be_nil
|
356
|
-
relationships[0]["start"].
|
357
|
-
relationships[0]["end"].
|
291
|
+
relationships[0]["start"].should == new_node4["self"]
|
292
|
+
relationships[0]["end"].should == new_node1["self"]
|
358
293
|
relationships[0]["type"].should == "enemies"
|
359
294
|
relationships[0]["data"]["met"].should == "gym"
|
360
295
|
relationships[0]["data"]["since"].should == '10-3-2010'
|
@@ -363,8 +298,7 @@ describe Neography::Rest do
|
|
363
298
|
|
364
299
|
it "returns nil if there are no relationships" do
|
365
300
|
new_node1 = @neo.create_node
|
366
|
-
|
367
|
-
relationships = @neo.get_node_relationships(new_node1[:id])
|
301
|
+
relationships = @neo.get_node_relationships(new_node1)
|
368
302
|
relationships.should be_nil
|
369
303
|
end
|
370
304
|
end
|