MrMurano 1.11.3 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/README.markdown +12 -14
- data/Rakefile +2 -2
- data/TODO.taskpaper +8 -6
- data/docs/demo.md +109 -0
- data/lib/MrMurano/Account.rb +6 -3
- data/lib/MrMurano/Config.rb +13 -37
- data/lib/MrMurano/Product-1P-Device.rb +2 -0
- data/lib/MrMurano/Product-Resources.rb +5 -4
- data/lib/MrMurano/Product.rb +3 -3
- data/lib/MrMurano/Solution-File.rb +1 -2
- data/lib/MrMurano/Solution-ServiceConfig.rb +11 -1
- data/lib/MrMurano/Solution-Services.rb +24 -7
- data/lib/MrMurano/Solution-Users.rb +6 -4
- data/lib/MrMurano/SyncUpDown.rb +67 -28
- data/lib/MrMurano/commands/config.rb +4 -1
- data/lib/MrMurano/commands/exportImport.rb +3 -0
- data/lib/MrMurano/hash.rb +2 -0
- data/lib/MrMurano/http.rb +3 -3
- data/lib/MrMurano/verbosing.rb +9 -3
- data/lib/MrMurano/version.rb +1 -1
- data/spec/Account_spec.rb +104 -0
- data/spec/Config_spec.rb +202 -57
- data/spec/Http_spec.rb +204 -0
- data/spec/MakePretties_spec.rb +35 -0
- data/spec/Mock_spec.rb +13 -20
- data/spec/ProductBase_spec.rb +2 -0
- data/spec/ProductContent_spec.rb +77 -12
- data/spec/ProductResources_spec.rb +235 -0
- data/spec/Product_1P_Device_spec.rb +62 -0
- data/spec/Product_1P_RPC_spec.rb +2 -0
- data/spec/Product_spec.rb +18 -8
- data/spec/Solution-Cors_spec.rb +28 -1
- data/spec/Solution-Endpoint_spec.rb +250 -33
- data/spec/Solution-File_spec.rb +210 -0
- data/spec/Solution-ServiceConfig_spec.rb +2 -0
- data/spec/Solution-ServiceDevice_spec.rb +174 -0
- data/spec/Solution-ServiceEventHandler_spec.rb +134 -1
- data/spec/Solution-ServiceModules_spec.rb +317 -64
- data/spec/Solution-UsersRoles_spec.rb +207 -0
- data/spec/Solution_spec.rb +90 -0
- data/spec/SyncRoot_spec.rb +52 -46
- data/spec/SyncUpDown_spec.rb +364 -0
- data/spec/Verbosing_spec.rb +279 -0
- data/spec/_workspace.rb +27 -0
- data/spec/fixtures/dumped_config +47 -0
- data/spec/fixtures/product_spec_files/lightbulb-no-state.yaml +11 -0
- data/spec/fixtures/product_spec_files/lightbulb.yaml +2 -0
- data/spec/fixtures/roles-three.yaml +11 -0
- data/spec/spec_helper.rb +9 -0
- metadata +26 -2
data/spec/ProductContent_spec.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'MrMurano/version'
|
2
|
+
require 'MrMurano/Config'
|
2
3
|
require 'MrMurano/Product'
|
4
|
+
require '_workspace'
|
3
5
|
|
4
6
|
RSpec.describe MrMurano::ProductContent, "#product_content" do
|
7
|
+
include_context "WORKSPACE"
|
5
8
|
before(:example) do
|
6
9
|
$cfg = MrMurano::Config.new
|
7
10
|
$cfg.load
|
@@ -24,6 +27,26 @@ RSpec.describe MrMurano::ProductContent, "#product_content" do
|
|
24
27
|
expect(ret).to eq([])
|
25
28
|
end
|
26
29
|
|
30
|
+
it "lists something" do
|
31
|
+
stub_request(:get, @urlroot + "/").
|
32
|
+
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
33
|
+
'Content-Type'=>'application/json'}).
|
34
|
+
to_return(body: "one\ntwo\nthree\n")
|
35
|
+
|
36
|
+
ret = @prd.list
|
37
|
+
expect(ret).to eq(['one','two','three'])
|
38
|
+
end
|
39
|
+
|
40
|
+
it "lists something for identifier" do
|
41
|
+
stub_request(:get, @urlroot + "/?sn=12").
|
42
|
+
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
43
|
+
'Content-Type'=>'application/json'}).
|
44
|
+
to_return(body: "one\ntwo\nthree\n")
|
45
|
+
|
46
|
+
ret = @prd.list_for('12')
|
47
|
+
expect(ret).to eq(['one','two','three'])
|
48
|
+
end
|
49
|
+
|
27
50
|
it "creates an item" do
|
28
51
|
stub_request(:post, @urlroot + "/").
|
29
52
|
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
@@ -56,6 +79,16 @@ RSpec.describe MrMurano::ProductContent, "#product_content" do
|
|
56
79
|
expect(ret).to eq([['text/plain','42','123456789','test meta','false']])
|
57
80
|
end
|
58
81
|
|
82
|
+
it "gets info for missing content" do
|
83
|
+
stub_request(:get, @urlroot + "/testFor").
|
84
|
+
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
85
|
+
'Content-Type'=>'application/json'}).
|
86
|
+
to_return(status: 404, body: "")
|
87
|
+
|
88
|
+
ret = @prd.info("testFor")
|
89
|
+
expect(ret).to be_nil
|
90
|
+
end
|
91
|
+
|
59
92
|
it "removes content" do
|
60
93
|
stub_request(:delete, @urlroot + "/testFor").
|
61
94
|
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
@@ -67,27 +100,59 @@ RSpec.describe MrMurano::ProductContent, "#product_content" do
|
|
67
100
|
end
|
68
101
|
|
69
102
|
it "uploads content data" do
|
70
|
-
|
103
|
+
pth = (@testdir + 'spec/fixtures/product_spec_files/lightbulb.yaml').realpath
|
104
|
+
size = FileTest.size(pth.to_path)
|
71
105
|
stub_request(:post, @urlroot + "/testFor").
|
72
106
|
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
73
107
|
'Content-Type'=>/text\/(x-)?yaml/,
|
74
108
|
'Content-Length' => size
|
75
|
-
|
109
|
+
}).
|
76
110
|
to_return(status: 205)
|
77
111
|
|
78
|
-
ret = @prd.upload('testFor',
|
112
|
+
ret = @prd.upload('testFor', pth.to_path)
|
79
113
|
expect(ret).to eq({})
|
80
114
|
end
|
81
115
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
116
|
+
context "downloads content" do
|
117
|
+
it "to block" do
|
118
|
+
stub_request(:get, @urlroot + "/testFor?download=true").
|
119
|
+
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
120
|
+
'Content-Type'=>'application/json'}).
|
121
|
+
to_return(body: "short and sweet")
|
122
|
+
|
123
|
+
data = ""
|
124
|
+
@prd.download('testFor') {|chunk| data << chunk}
|
125
|
+
expect(data).to eq("short and sweet")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "to stdout" do
|
129
|
+
stub_request(:get, @urlroot + "/testFor?download=true").
|
130
|
+
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
131
|
+
'Content-Type'=>'application/json'}).
|
132
|
+
to_return(body: "short and sweet")
|
133
|
+
|
134
|
+
begin
|
135
|
+
old_stdout = $stdout
|
136
|
+
$stdout = StringIO.new('','w')
|
137
|
+
@prd.download('testFor')
|
138
|
+
expect($stdout.string).to eq("short and sweet")
|
139
|
+
ensure
|
140
|
+
$stdout = old_stdout
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
it "but error" do
|
145
|
+
stub_request(:get, @urlroot + "/testFor?download=true").
|
146
|
+
with(headers: {'Authorization'=>'token TTTTTTTTTT',
|
147
|
+
'Content-Type'=>'application/json'}).
|
148
|
+
to_return(status:404, body: "{}")
|
149
|
+
|
150
|
+
data = ""
|
151
|
+
expect(@prd).to receive(:error).once
|
152
|
+
@prd.download('testFor') {|chunk| data << chunk}
|
153
|
+
expect(data).to eq("")
|
154
|
+
|
155
|
+
end
|
91
156
|
end
|
92
157
|
|
93
158
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'MrMurano/version'
|
2
2
|
require 'MrMurano/Config'
|
3
3
|
require 'MrMurano/Product-Resources'
|
4
|
+
require '_workspace'
|
4
5
|
|
5
6
|
RSpec.describe MrMurano::ProductResources do
|
7
|
+
include_context "WORKSPACE"
|
6
8
|
before(:example) do
|
7
9
|
$cfg = MrMurano::Config.new
|
8
10
|
$cfg.load
|
@@ -76,6 +78,18 @@ RSpec.describe MrMurano::ProductResources do
|
|
76
78
|
ret = @prd.list
|
77
79
|
expect(ret).to eq([{:alias=>"bob", :rid=>:abcdefg}])
|
78
80
|
end
|
81
|
+
|
82
|
+
it "gets item" do
|
83
|
+
stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/product/XYZ/proxy/onep:v1/rpc/process").
|
84
|
+
with(body: {:auth=>{:client_id=>"LLLLLLLLLL"},
|
85
|
+
:calls=>[{:id=>1,
|
86
|
+
:procedure=>"info",
|
87
|
+
:arguments=>["FFFFFFFFFF", {}]} ]}).
|
88
|
+
to_return(body: [{:id=>1, :status=>"ok", :result=>{:comments=>[]}}])
|
89
|
+
|
90
|
+
ret = @prd.fetch("FFFFFFFFFF")
|
91
|
+
expect(ret).to eq({:comments=>[]})
|
92
|
+
end
|
79
93
|
end
|
80
94
|
|
81
95
|
context "Modifying" do
|
@@ -119,6 +133,227 @@ RSpec.describe MrMurano::ProductResources do
|
|
119
133
|
end
|
120
134
|
end
|
121
135
|
|
136
|
+
context "uploads" do
|
137
|
+
it "replacing" do
|
138
|
+
frid = "ffffffffffffffffffffffffffffffffffffffff"
|
139
|
+
stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/product/XYZ/proxy/onep:v1/rpc/process").
|
140
|
+
with(body: {:auth=>{:client_id=>"LLLLLLLLLL"},
|
141
|
+
:calls=>[{:id=>1,
|
142
|
+
:procedure=>"drop",
|
143
|
+
:arguments=>[frid]} ]}).
|
144
|
+
to_return(body: [{:id=>1, :status=>"ok", :result=>{}}])
|
145
|
+
|
146
|
+
stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/product/XYZ/proxy/onep:v1/rpc/process").
|
147
|
+
with(body: {:auth=>{:client_id=>"LLLLLLLLLL"},
|
148
|
+
:calls=>[{:id=>1,
|
149
|
+
:procedure=>"create",
|
150
|
+
:arguments=>["dataport",{
|
151
|
+
:format=>"string",
|
152
|
+
:name=>"bob",
|
153
|
+
:retention=>{
|
154
|
+
:count=>1,
|
155
|
+
:duration=>"infinity"
|
156
|
+
}
|
157
|
+
}]} ]}).
|
158
|
+
to_return(body: [{:id=>1, :status=>"ok", :result=>frid}])
|
159
|
+
|
160
|
+
stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/product/XYZ/proxy/onep:v1/rpc/process").
|
161
|
+
with(body: {:auth=>{:client_id=>"LLLLLLLLLL"},
|
162
|
+
:calls=>[{:id=>1,
|
163
|
+
:procedure=>"map",
|
164
|
+
:arguments=>["alias", frid, "bob"]} ]}).
|
165
|
+
to_return(body: [{:id=>1, :status=>"ok", :result=>{}}])
|
166
|
+
|
167
|
+
@prd.upload(nil, {:alias=>"bob", :format=>"string", :rid=>frid}, true)
|
168
|
+
end
|
169
|
+
|
170
|
+
it "creating" do
|
171
|
+
frid = "ffffffffffffffffffffffffffffffffffffffff"
|
172
|
+
stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/product/XYZ/proxy/onep:v1/rpc/process").
|
173
|
+
with(body: {:auth=>{:client_id=>"LLLLLLLLLL"},
|
174
|
+
:calls=>[{:id=>1,
|
175
|
+
:procedure=>"create",
|
176
|
+
:arguments=>["dataport",{
|
177
|
+
:format=>"string",
|
178
|
+
:name=>"bob",
|
179
|
+
:retention=>{
|
180
|
+
:count=>1,
|
181
|
+
:duration=>"infinity"
|
182
|
+
}
|
183
|
+
}]} ]}).
|
184
|
+
to_return(body: [{:id=>1, :status=>"ok", :result=>frid}])
|
185
|
+
|
186
|
+
stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/product/XYZ/proxy/onep:v1/rpc/process").
|
187
|
+
with(body: {:auth=>{:client_id=>"LLLLLLLLLL"},
|
188
|
+
:calls=>[{:id=>1,
|
189
|
+
:procedure=>"map",
|
190
|
+
:arguments=>["alias", frid, "bob"]} ]}).
|
191
|
+
to_return(body: [{:id=>1, :status=>"ok", :result=>{}}])
|
192
|
+
|
193
|
+
@prd.upload(nil, {:alias=>"bob", :format=>"string"}, false)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
context "compares" do
|
198
|
+
before(:example) do
|
199
|
+
@iA = {:alias=>"data",
|
200
|
+
:format=>"string",
|
201
|
+
}
|
202
|
+
@iB = {:alias=>"data",
|
203
|
+
:format=>"string",
|
204
|
+
}
|
205
|
+
end
|
206
|
+
it "same" do
|
207
|
+
ret = @prd.docmp(@iA, @iB)
|
208
|
+
expect(ret).to eq(false)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "different alias" do
|
212
|
+
iA = @iA.merge({:alias=>"bob"})
|
213
|
+
ret = @prd.docmp(iA, @iB)
|
214
|
+
expect(ret).to eq(true)
|
215
|
+
end
|
216
|
+
|
217
|
+
it "different format" do
|
218
|
+
iA = @iA.merge({:format=>"integer"})
|
219
|
+
ret = @prd.docmp(iA, @iB)
|
220
|
+
expect(ret).to eq(true)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
context "Lookup functions" do
|
226
|
+
it "gets local name" do
|
227
|
+
ret = @prd.tolocalname({ :method=>'get', :path=>'one/two/three' }, nil)
|
228
|
+
expect(ret).to eq('')
|
229
|
+
end
|
230
|
+
|
231
|
+
it "gets synckey" do
|
232
|
+
ret = @prd.synckey({ :alias=>'get' })
|
233
|
+
expect(ret).to eq("get")
|
234
|
+
end
|
235
|
+
|
236
|
+
it "tolocalpath is into" do
|
237
|
+
ret = @prd.tolocalpath('a/path/', {:id=>'cors'})
|
238
|
+
expect(ret).to eq('a/path/')
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
context "local resoruces" do
|
243
|
+
before(:example) do
|
244
|
+
# pull over test file.
|
245
|
+
FileUtils.mkpath($cfg['location.specs'])
|
246
|
+
lb = (@testdir + 'spec/fixtures/product_spec_files/lightbulb.yaml').realpath
|
247
|
+
@spec_path = File.join($cfg['location.specs'], $cfg['product.spec'])
|
248
|
+
FileUtils.copy(lb.to_path, @spec_path)
|
249
|
+
end
|
250
|
+
|
251
|
+
context "gets local items" do
|
252
|
+
it "is there" do
|
253
|
+
ret = @prd.localitems(@spec_path)
|
254
|
+
expect(ret).to eq([
|
255
|
+
{:alias=>"state", :format=>"integer", :initial=>0},
|
256
|
+
{:alias=>"temperature", :format=>"float", :initial=>0},
|
257
|
+
{:alias=>"uptime", :format=>"integer", :initial=>0},
|
258
|
+
{:alias=>"humidity", :format=>"float", :initial=>0}
|
259
|
+
])
|
260
|
+
end
|
261
|
+
|
262
|
+
it "is missing" do
|
263
|
+
expect(@prd).to receive(:warning).once.with("Skipping missing specs/XYZ.yaml-h")
|
264
|
+
ret = @prd.localitems(@spec_path + '-h')
|
265
|
+
expect(ret).to eq([])
|
266
|
+
end
|
267
|
+
|
268
|
+
it "isn't a file" do
|
269
|
+
expect(@prd).to receive(:warning).once.with("Cannot read from specs/XYZ.yaml-h")
|
270
|
+
FileUtils.mkpath(@spec_path + '-h')
|
271
|
+
ret = @prd.localitems(@spec_path + '-h')
|
272
|
+
expect(ret).to eq([])
|
273
|
+
end
|
274
|
+
|
275
|
+
it "has wrong format" do
|
276
|
+
File.open(@spec_path + '-h', 'w') do |io|
|
277
|
+
io << ['a','b','c'].to_yaml
|
278
|
+
end
|
279
|
+
expect(@prd).to receive(:warning).once.with("Unexpected data in specs/XYZ.yaml-h")
|
280
|
+
ret = @prd.localitems(@spec_path + '-h')
|
281
|
+
expect(ret).to eq([])
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
context "downloads" do
|
287
|
+
before(:example) do
|
288
|
+
FileUtils.mkpath($cfg['location.specs'])
|
289
|
+
@lb = (@testdir + 'spec/fixtures/product_spec_files/lightbulb.yaml').realpath
|
290
|
+
@spec_path = Pathname.new(File.join($cfg['location.specs'], $cfg['product.spec']))
|
291
|
+
end
|
292
|
+
|
293
|
+
it "when nothing is there" do
|
294
|
+
frid = "FFFFFFFFFF"
|
295
|
+
stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/product/XYZ/proxy/onep:v1/rpc/process").
|
296
|
+
with(body: {:auth=>{:client_id=>"LLLLLLLLLL"},
|
297
|
+
:calls=>[{:id=>1,
|
298
|
+
:procedure=>"info",
|
299
|
+
:arguments=>[frid, {}]} ]}).
|
300
|
+
to_return(body: [{:id=>1, :status=>"ok", :result=>{:description=>{:format=>'integer'}}}])
|
301
|
+
|
302
|
+
@prd.download(@spec_path, {:rid=>frid, :alias=>'state'})
|
303
|
+
|
304
|
+
data = nil
|
305
|
+
@spec_path.open{|io| data = YAML.load(io)}
|
306
|
+
expect(data).to eq({"resources"=>[{"alias"=>"state", "format"=>"integer"}]})
|
307
|
+
end
|
308
|
+
|
309
|
+
it "merging into existing file" do
|
310
|
+
FileUtils.copy(@lb.to_path, @spec_path)
|
311
|
+
frid = "FFFFFFFFFF"
|
312
|
+
stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/product/XYZ/proxy/onep:v1/rpc/process").
|
313
|
+
with(body: {:auth=>{:client_id=>"LLLLLLLLLL"},
|
314
|
+
:calls=>[{:id=>1,
|
315
|
+
:procedure=>"info",
|
316
|
+
:arguments=>[frid, {}]} ]}).
|
317
|
+
to_return(body: [{:id=>1, :status=>"ok", :result=>{:description=>{:format=>'integer'}}}])
|
318
|
+
|
319
|
+
@prd.download(@spec_path, {:rid=>frid, :alias=>'state'})
|
320
|
+
#FileUtils.copy_stream(@spec_path, $stdout)
|
321
|
+
#expect(FileUtils.cmp(@spec_path.to_path, @lb.to_path)).to be true
|
322
|
+
|
323
|
+
data = nil
|
324
|
+
@spec_path.open{|io| data = YAML.load(io)}
|
325
|
+
expect(data).to eq({"resources"=>[
|
326
|
+
{"alias"=>"temperature", "format"=>"float", "initial"=>0},
|
327
|
+
{"alias"=>"uptime", "format"=>"integer", "initial"=>0},
|
328
|
+
{"alias"=>"humidity", "format"=>"float", "initial"=>0},
|
329
|
+
{"alias"=>"state", "format"=>"integer"}
|
330
|
+
]})
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|
334
|
+
|
335
|
+
context "removes local items" do
|
336
|
+
before(:example) do
|
337
|
+
# pull over test file.
|
338
|
+
FileUtils.mkpath($cfg['location.specs'])
|
339
|
+
@lb = (@testdir + 'spec/fixtures/product_spec_files/lightbulb.yaml').realpath
|
340
|
+
@spec_path = File.join($cfg['location.specs'], $cfg['product.spec'])
|
341
|
+
FileUtils.copy(@lb.to_path, @spec_path)
|
342
|
+
@spec_path = Pathname.new(@spec_path)
|
343
|
+
end
|
344
|
+
|
345
|
+
it "it exists and has item" do
|
346
|
+
@prd.removelocal(@spec_path, {:alias=>"state"})
|
347
|
+
lbns = (@testdir + 'spec/fixtures/product_spec_files/lightbulb-no-state.yaml').realpath
|
348
|
+
expect(FileUtils.cmp(@spec_path.to_path, lbns.to_path)).to be true
|
349
|
+
end
|
350
|
+
|
351
|
+
it "it exists and does not have item" do
|
352
|
+
@prd.removelocal(@spec_path, {:alias=>"ThisAliasDoesNotExistInHere"})
|
353
|
+
# nothing changed
|
354
|
+
expect(FileUtils.cmp(@spec_path.to_path, @lb.to_path)).to be true
|
355
|
+
end
|
356
|
+
end
|
122
357
|
end
|
123
358
|
|
124
359
|
# vim: set ai et sw=2 ts=2 :
|
@@ -1,8 +1,70 @@
|
|
1
1
|
require 'MrMurano/version'
|
2
2
|
require 'MrMurano/Config'
|
3
3
|
require 'MrMurano/Product-1P-Device'
|
4
|
+
require '_workspace'
|
5
|
+
|
6
|
+
RSpec.describe MrMurano::Product1PDevice, '#sn_rid tests' do
|
7
|
+
include_context "WORKSPACE"
|
8
|
+
before(:example) do
|
9
|
+
$cfg = MrMurano::Config.new
|
10
|
+
$cfg.load
|
11
|
+
$cfg['net.host'] = 'bizapi.hosted.exosite.io'
|
12
|
+
$cfg['product.id'] = 'XYZ'
|
13
|
+
$cfg['product.spec'] = 'XYZ.yaml'
|
14
|
+
|
15
|
+
@prd = MrMurano::Product1PDevice.new
|
16
|
+
allow(@prd).to receive(:token).and_return("TTTTTTTTTT")
|
17
|
+
@mrp = instance_double("MrMurano::Product")
|
18
|
+
allow(MrMurano::Product).to receive(:new).and_return(@mrp)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "gets rid from sn" do
|
22
|
+
expect(@mrp).to receive(:list).once.and_return([
|
23
|
+
{:sn=>"12",
|
24
|
+
:status=>"activated",
|
25
|
+
:rid=>"77cbf643ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"}])
|
26
|
+
ret = @prd.sn_rid("12")
|
27
|
+
expect(ret).to eq("77cbf643ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "gets rid from sn on page two" do
|
31
|
+
expect(@mrp).to receive(:list).twice.and_return(
|
32
|
+
[{:sn=>"14",
|
33
|
+
:status=>"notactivated"}],
|
34
|
+
[{:sn=>"12",
|
35
|
+
:status=>"activated",
|
36
|
+
:rid=>"77cbf643ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"}])
|
37
|
+
|
38
|
+
ret = @prd.sn_rid("12")
|
39
|
+
expect(ret).to eq("77cbf643ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "doesn't find the sn" do
|
43
|
+
expect(@mrp).to receive(:list).twice.and_return(
|
44
|
+
[{:sn=>"14",
|
45
|
+
:status=>"notactivated"}],
|
46
|
+
[])
|
47
|
+
|
48
|
+
expect {
|
49
|
+
@prd.sn_rid("12")
|
50
|
+
}.to raise_error "Identifier Not Found: 12"
|
51
|
+
end
|
52
|
+
|
53
|
+
it "gets model_rid" do
|
54
|
+
expect(@mrp).to receive(:info).once.and_return({:modelrid=>"1234567890"})
|
55
|
+
ret = @prd.model_rid
|
56
|
+
expect(ret).to eq("1234567890")
|
57
|
+
end
|
58
|
+
it "raises with bad model_rid" do
|
59
|
+
expect(@mrp).to receive(:info).once.and_return({:mid=>"1234567890"})
|
60
|
+
expect {
|
61
|
+
@prd.model_rid
|
62
|
+
}.to raise_error(/^Bad info; .*/)
|
63
|
+
end
|
64
|
+
end
|
4
65
|
|
5
66
|
RSpec.describe MrMurano::Product1PDevice do
|
67
|
+
include_context "WORKSPACE"
|
6
68
|
before(:example) do
|
7
69
|
$cfg = MrMurano::Config.new
|
8
70
|
$cfg.load
|
data/spec/Product_1P_RPC_spec.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'MrMurano/version'
|
2
2
|
require 'MrMurano/Config'
|
3
3
|
require 'MrMurano/Product-Resources'
|
4
|
+
require '_workspace'
|
4
5
|
|
5
6
|
RSpec.describe MrMurano::ProductResources, "#1PshimTests" do
|
7
|
+
include_context "WORKSPACE"
|
6
8
|
before(:example) do
|
7
9
|
$cfg = MrMurano::Config.new
|
8
10
|
$cfg.load
|
data/spec/Product_spec.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'MrMurano/version'
|
2
2
|
require 'MrMurano/Config'
|
3
3
|
require 'MrMurano/Product'
|
4
|
+
require '_workspace'
|
4
5
|
|
5
6
|
RSpec.describe MrMurano::Product, "#product" do
|
7
|
+
include_context "WORKSPACE"
|
6
8
|
before(:example) do
|
7
9
|
$cfg = MrMurano::Config.new
|
8
10
|
$cfg.load
|
@@ -88,7 +90,8 @@ RSpec.describe MrMurano::Product, "#product" do
|
|
88
90
|
to_return(body: rbody.to_json)
|
89
91
|
|
90
92
|
# Open test file sepc.yaml
|
91
|
-
|
93
|
+
pth = (@testdir + 'spec/fixtures/product_spec_files/lightbulb.yaml').realpath
|
94
|
+
ret = @prd.update(pth)
|
92
95
|
expect(ret).to eq(rbody)
|
93
96
|
end
|
94
97
|
|
@@ -104,18 +107,22 @@ RSpec.describe MrMurano::Product, "#product" do
|
|
104
107
|
|
105
108
|
context "converting a specFile" do
|
106
109
|
it "can convert a file" do
|
107
|
-
|
108
|
-
|
110
|
+
epth = (@testdir + 'spec/fixtures/product_spec_files/gwe.exoline.spec.yaml').realpath
|
111
|
+
mpth = (@testdir + 'spec/fixtures/product_spec_files/gwe.murano.spec.yaml').realpath
|
112
|
+
out = @prd.convert(epth)
|
113
|
+
want = mpth.read
|
109
114
|
|
110
115
|
expect(out).to eq(want)
|
111
116
|
end
|
112
117
|
|
113
118
|
it "can convert stdin" do
|
114
|
-
|
119
|
+
epth = (@testdir + 'spec/fixtures/product_spec_files/gwe.exoline.spec.yaml').realpath
|
120
|
+
mpth = (@testdir + 'spec/fixtures/product_spec_files/gwe.murano.spec.yaml').realpath
|
121
|
+
epth.open do |fin|
|
115
122
|
begin
|
116
123
|
$stdin = fin
|
117
124
|
out = @prd.convert('-')
|
118
|
-
want =
|
125
|
+
want = mpth.read
|
119
126
|
|
120
127
|
expect(out).to eq(want)
|
121
128
|
ensure
|
@@ -125,15 +132,18 @@ RSpec.describe MrMurano::Product, "#product" do
|
|
125
132
|
end
|
126
133
|
|
127
134
|
it "converts a fully featured exoline spec file" do
|
128
|
-
|
129
|
-
|
135
|
+
epth = (@testdir + 'spec/fixtures/product_spec_files/example.exoline.spec.yaml').realpath
|
136
|
+
mpth = (@testdir + 'spec/fixtures/product_spec_files/example.murano.spec.yaml').realpath
|
137
|
+
out = @prd.convert(epth)
|
138
|
+
want = mpth.read
|
130
139
|
|
131
140
|
expect(out).to eq(want)
|
132
141
|
end
|
133
142
|
|
134
143
|
it "raises when not an exoline spec" do
|
135
144
|
expect {
|
136
|
-
@
|
145
|
+
pth = @testdir + 'spec/fixtures/product_spec_files/example.murano.spec.yaml'
|
146
|
+
@prd.convert(pth.realpath)
|
137
147
|
}.to raise_exception('No dataports section found, or not an array')
|
138
148
|
end
|
139
149
|
end
|
data/spec/Solution-Cors_spec.rb
CHANGED
@@ -2,8 +2,10 @@ require 'MrMurano/version'
|
|
2
2
|
require 'MrMurano/Solution-Cors'
|
3
3
|
require 'tempfile'
|
4
4
|
require 'yaml'
|
5
|
+
require '_workspace'
|
5
6
|
|
6
7
|
RSpec.describe MrMurano::Cors do
|
8
|
+
include_context "WORKSPACE"
|
7
9
|
before(:example) do
|
8
10
|
$cfg = MrMurano::Config.new
|
9
11
|
$cfg.load
|
@@ -99,7 +101,7 @@ RSpec.describe MrMurano::Cors do
|
|
99
101
|
end
|
100
102
|
|
101
103
|
it "return empty if not a file" do
|
102
|
-
Dir.
|
104
|
+
Dir.mktmpdir do |td|
|
103
105
|
tp = File.join(td, 'cors.yaml')
|
104
106
|
Dir.mkdir( tp ) # not a file
|
105
107
|
allow(@srv).to receive(:warning)
|
@@ -130,5 +132,30 @@ RSpec.describe MrMurano::Cors do
|
|
130
132
|
expect(ret).to eq(nil)
|
131
133
|
end
|
132
134
|
|
135
|
+
it "tolocalpath is into" do
|
136
|
+
ret = @srv.tolocalpath('a/path/', {:id=>'cors'})
|
137
|
+
expect(ret).to eq('a/path/')
|
138
|
+
end
|
139
|
+
|
140
|
+
context "compares" do
|
141
|
+
before(:example) do
|
142
|
+
@iA = {:origin=>true,
|
143
|
+
:methods=>['HEAD','GET'],
|
144
|
+
:headers=>['Content-Type'],
|
145
|
+
}
|
146
|
+
@iB = {:origin=>true,
|
147
|
+
:methods=>['HEAD','GET'],
|
148
|
+
:headers=>['Content-Type'],
|
149
|
+
}
|
150
|
+
end
|
151
|
+
it "equal" do
|
152
|
+
ret = @srv.docmp(@iA,@iB)
|
153
|
+
expect(ret).to eq(false)
|
154
|
+
end
|
155
|
+
it "different" do
|
156
|
+
ret = @srv.docmp(@iA,@iB.merge({:foo=>:bar}))
|
157
|
+
expect(ret).to eq(true)
|
158
|
+
end
|
159
|
+
end
|
133
160
|
end
|
134
161
|
# vim: set ai et sw=2 ts=2 :
|