zabbixapi 0.5.0b3 → 0.5.0b4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/spec/run.rb CHANGED
@@ -33,12 +33,11 @@ describe ZabbixApi, "test_api" do
33
33
  end
34
34
 
35
35
  it "HOSTGROUP: Create" do
36
- $hostgroup_id_real = zbx.hostgroups.create(:name => hostgroup)
37
- $hostgroup_id_real.should be_kind_of(Integer)
36
+ zbx.hostgroups.create(:name => hostgroup).should be_kind_of(Integer)
38
37
  end
39
38
 
40
39
  it "HOSTGROUP: Find" do
41
- zbx.hostgroups.get_id(:name => hostgroup).should equal $hostgroup_id_real
40
+ zbx.hostgroups.get_id(:name => hostgroup).should be_kind_of(Integer)
42
41
  end
43
42
 
44
43
  it "HOSTGROUP: Find unknown" do
@@ -46,61 +45,59 @@ describe ZabbixApi, "test_api" do
46
45
  end
47
46
 
48
47
  it "HOSTGROUP: Create or get" do
49
- zbx.hostgroups.get_or_create(:name => hostgroup).should equal $hostgroup_id_real
48
+ zbx.hostgroups.get_or_create(:name => hostgroup).should be_kind_of(Integer)
50
49
  end
51
50
 
52
51
  it "HOSTGROUP: Get all" do
53
- zbx.hostgroups.all.should include(hostgroup => $hostgroup_id_real.to_s)
52
+ zbx.hostgroups.all.should be_kind_of(Hash)
54
53
  end
55
54
 
56
55
  it "TEMPLATE: Create" do
57
- $template_id_real = zbx.templates.create(
56
+ zbx.templates.create(
58
57
  :host => template,
59
58
  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
60
- )
61
- $template_id_real.should be_kind_of(Integer)
59
+ ).should be_kind_of(Integer)
62
60
  end
63
61
 
64
62
  it "TEMPLATE: Get get or create" do
65
63
  zbx.templates.get_or_create(
66
64
  :host => template,
67
65
  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
68
- ).should equal $template_id_real
66
+ ).should be_kind_of(Integer)
67
+ end
68
+
69
+ it "TEMPLATE: Check full data" do
70
+ zbx.templates.get_full_data(:host => template)[0]['host'].should be_kind_of(String)
69
71
  end
70
72
 
71
73
  it "TEMPLATE: Find" do
72
- zbx.templates.get_id(:host => template).should equal $template_id_real
74
+ zbx.templates.get_id(:host => template).should be_kind_of(Integer)
73
75
  end
74
76
 
75
77
  it "TEMPLATE: Find unknown" do
76
78
  zbx.templates.get_id(:host => "#{template}_____").should be_kind_of(NilClass)
77
79
  end
78
80
 
79
- it "TEMPLATE: Get all" do
80
- zbx.templates.all.should include(template => $template_id_real.to_s)
81
- end
82
-
83
81
  it "APPLICATION: Create" do
84
- $application_id_real = zbx.applications.create(
82
+ zbx.applications.create(
85
83
  :name => application,
86
84
  :hostid => zbx.templates.get_id(:host => template)
87
85
  )
88
- $application_id_real.should be_kind_of(Integer)
89
- end
90
-
91
- it "APPLICATION: Get all" do
92
- zbx.applications.all.should include(application => $application_id_real.to_s)
93
86
  end
94
87
 
95
88
  it "APPLICATION: Get or create" do
96
89
  zbx.applications.get_or_create(
97
90
  :name => application,
98
91
  :hostid => zbx.templates.get_id(:host => template)
99
- ).should equal $application_id_real
92
+ )
93
+ end
94
+
95
+ it "APPLICATION: Full info check" do
96
+ zbx.applications.get_full_data(:name => application)[0]['applicationid'].should be_kind_of(String)
100
97
  end
101
98
 
102
99
  it "APPLICATION: Find" do
103
- zbx.applications.get_id(:name => application).should equal $application_id_real
100
+ zbx.applications.get_id(:name => application).should be_kind_of(Integer)
104
101
  end
105
102
 
106
103
  it "APPLICATION: Find unknown" do
@@ -108,28 +105,27 @@ describe ZabbixApi, "test_api" do
108
105
  end
109
106
 
110
107
  it "ITEM: Create" do
111
- $item_id_real = zbx.items.create(
108
+ zbx.items.create(
112
109
  :description => item,
113
110
  :key_ => "proc.num[aaa]",
114
111
  :hostid => zbx.templates.get_id(:host => template),
115
112
  :applications => [zbx.applications.get_id(:name => application)]
116
- )
117
- $item_id_real.should be_kind_of(Integer)
113
+ ).should be_kind_of(Integer)
118
114
  end
119
115
 
120
- it "ITEM: Find" do
121
- zbx.items.get_id(:description => item).should equal $item_id_real
116
+ it "ITEM: Full info check" do
117
+ zbx.items.get_full_data(:description => item)[0]['itemid'].should be_kind_of(String)
122
118
  end
123
119
 
124
- it "ITEM: Get all" do
125
- zbx.items.all.should include(item => $item_id_real.to_s)
120
+ it "ITEM: Find" do
121
+ zbx.items.get_id(:description => item).should be_kind_of(Integer)
126
122
  end
127
123
 
128
124
  it "ITEM: Update" do
129
125
  zbx.items.update(
130
126
  :itemid => zbx.items.get_id(:description => item),
131
127
  :status => 0
132
- ).should equal $item_id_real
128
+ ).should be_kind_of(Integer)
133
129
  end
134
130
 
135
131
  it "ITEM: Create or update" do
@@ -139,20 +135,19 @@ describe ZabbixApi, "test_api" do
139
135
  :type => 6,
140
136
  :hostid => zbx.templates.get_id(:host => template),
141
137
  :applications => [zbx.applications.get_id(:name => application)]
142
- ).should equal $item_id_real
138
+ ).should be_kind_of(Integer)
143
139
  end
144
140
 
145
141
  it "ITEM: Get unknown" do
146
- zbx.items.get_id(:description => "#{item}_____").should be_kind_of(NilClass)
142
+ zbx.items.get_id(:description => "#{item}_____")
147
143
  end
148
144
 
149
145
  it "HOST: Create" do
150
- $host_id_real = zbx.hosts.create(
146
+ zbx.hosts.create(
151
147
  :host => host,
152
148
  :ip => "10.20.48.88",
153
149
  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
154
- )
155
- $host_id_real.should be_kind_of(Integer)
150
+ ).should be_kind_of(Integer)
156
151
  end
157
152
 
158
153
  it "HOST: Update or create" do
@@ -160,7 +155,7 @@ describe ZabbixApi, "test_api" do
160
155
  :host => host,
161
156
  :ip => "10.20.48.89",
162
157
  :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
163
- ).should equal $host_id_real
158
+ ).should be_kind_of(Integer)
164
159
  end
165
160
 
166
161
  it "HOST: Find unknown" do
@@ -168,18 +163,20 @@ describe ZabbixApi, "test_api" do
168
163
  end
169
164
 
170
165
  it "HOST: Find" do
171
- zbx.hosts.get_id(:host => host).should equal $host_id_real
166
+ zbx.hosts.get_id(:host => host).should be_kind_of(Integer)
172
167
  end
173
168
 
174
169
  it "HOST: Update" do
175
170
  zbx.hosts.update(
176
171
  :hostid => zbx.hosts.get_id(:host => host),
177
172
  :status => 0
178
- ).should equal $host_id_real
173
+ )
179
174
  end
180
175
 
181
- it "HOST: Get all" do
182
- zbx.hosts.all.should include(host => $host_id_real.to_s)
176
+ it "TEMPLATE: Get all templates linked with host" do
177
+ zbx.templates.get_ids_by_host(
178
+ :hostids => [zbx.hosts.get_id(:host => host)]
179
+ ).should be_kind_of(Array)
183
180
  end
184
181
 
185
182
  it "TEMPLATE: Linked hosts with templates" do
@@ -196,18 +193,12 @@ describe ZabbixApi, "test_api" do
196
193
  ).should be_kind_of(TrueClass)
197
194
  end
198
195
 
199
- it "TEMPLATE: Get all templates linked with host" do
200
- zbx.templates.get_ids_by_host(
201
- :hostids => [zbx.hosts.get_id(:host => host)]
202
- ).should include($template_id_real.to_s)
203
- end
204
-
205
196
  it "TEMPLATE: Get all" do
206
- zbx.templates.all.should include(template => $template_id_real.to_s)
197
+ zbx.templates.all.should be_kind_of(Hash)
207
198
  end
208
199
 
209
200
  it "TRIGGER: Create" do
210
- $trigger_id_real = zbx.triggers.create(
201
+ zbx.triggers.create(
211
202
  :description => trigger,
212
203
  :expression => "{#{template}:proc.num[aaa].last(0)}<1",
213
204
  :comments => "Bla-bla is faulty (disaster)",
@@ -215,22 +206,13 @@ describe ZabbixApi, "test_api" do
215
206
  :status => 0,
216
207
  :templateid => 0,
217
208
  :type => 0
218
- )
219
- $trigger_id_real.should be_kind_of(Integer)
209
+ ).should be_kind_of(Integer)
220
210
  end
221
211
 
222
212
  it "TRIGGER: Find" do
223
213
  zbx.triggers.get_id(:description => trigger).should be_kind_of(Integer)
224
214
  end
225
215
 
226
- it "TRIGGER: Find unknown" do
227
- zbx.triggers.get_id(:description => "#{trigger}____").should be_kind_of(NilClass)
228
- end
229
-
230
- it "TRIGGER: Get all" do
231
- zbx.triggers.all.should be_kind_of(Hash)
232
- end
233
-
234
216
  it "GRAPH: Create" do
235
217
  gitems = {
236
218
  :itemid => zbx.items.get_id(:description => item),
@@ -238,14 +220,13 @@ describe ZabbixApi, "test_api" do
238
220
  :type => "0",
239
221
  :periods_cnt => "5"
240
222
  }
241
- $graph_id_real = zbx.graphs.create(
223
+ zbx.graphs.create(
242
224
  :gitems => [gitems],
243
225
  :show_triggers => "0",
244
226
  :name => graph,
245
227
  :width => "900",
246
228
  :height => "200"
247
- )
248
- $graph_id_real.should be_kind_of(Integer)
229
+ ).should be_kind_of(Integer)
249
230
  end
250
231
 
251
232
  it "GRAPH: Create or get" do
@@ -261,25 +242,21 @@ describe ZabbixApi, "test_api" do
261
242
  :name => graph,
262
243
  :width => "900",
263
244
  :height => "200"
264
- ).should equal $graph_id_real
245
+ ).should be_kind_of(Integer)
265
246
  end
266
247
 
267
248
  it "GRAPH: Find gititems" do
268
- zbx.graphs.get_items( zbx.graphs.get_id(:name => graph) ).should be_kind_of(Array)
249
+ zbx.graphs.get_items( zbx.graphs.get_id(:name => graph) )
269
250
  end
270
251
 
271
252
  it "GRAPH: Find" do
272
- zbx.graphs.get_id( :name => graph ).should equal $graph_id_real
253
+ zbx.graphs.get_id( :name => graph ).should be_kind_of(Integer)
273
254
  end
274
255
 
275
256
  it "GRAPH: get_ids_by_host" do
276
257
  zbx.graphs.get_ids_by_host( :host => host ).should be_kind_of(Array)
277
258
  end
278
259
 
279
- it "GRAPH: Get all" do
280
- zbx.graphs.all.should include(graph => $graph_id_real.to_s)
281
- end
282
-
283
260
  it "GRAPH: Update" do
284
261
  zbx.graphs.update(
285
262
  :graphid => zbx.graphs.get_id(
@@ -287,7 +264,7 @@ describe ZabbixApi, "test_api" do
287
264
  :hostid => zbx.hosts.get_id(:host => host)
288
265
  ),
289
266
  :ymax_type => 1
290
- ).should equal $graph_id_real
267
+ ).should be_kind_of(Integer)
291
268
  end
292
269
 
293
270
  it "GRAPH: Create or Update" do
@@ -303,15 +280,14 @@ describe ZabbixApi, "test_api" do
303
280
  :name => graph,
304
281
  :width => "900",
305
282
  :height => "200"
306
- ).should equal $graph_id_real
283
+ ).should be_kind_of(Integer)
307
284
  end
308
285
 
309
286
  it "SCREEN: Get or create for host" do
310
- $screen_id_real = zbx.screens.get_or_create_for_host(
287
+ zbx.screens.get_or_create_for_host(
311
288
  :host => host,
312
289
  :graphids => zbx.graphs.get_ids_by_host(:host => host)
313
- )
314
- $screen_id_real.should be_kind_of(Integer)
290
+ ).should be_kind_of(Integer)
315
291
  end
316
292
 
317
293
  it "TEMPLATE: Unlink hosts from templates" do
@@ -321,14 +297,10 @@ describe ZabbixApi, "test_api" do
321
297
  ).should be_kind_of(TrueClass)
322
298
  end
323
299
 
324
- it "SCREEN: Get all" do
325
- zbx.screens.all.should be_kind_of(Hash)
326
- end
327
-
328
300
  it "SCREEN: Delete" do
329
301
  zbx.screens.delete(
330
302
  [zbx.screens.get_id(:name => "#{host}_graphs")]
331
- ).should equal $screen_id_real
303
+ ).should be_kind_of(Integer)
332
304
  end
333
305
 
334
306
  it "GRAPH: Delete" do
@@ -340,37 +312,36 @@ describe ZabbixApi, "test_api" do
340
312
  end
341
313
 
342
314
  it "HOST: Delete" do
343
- zbx.hosts.delete( zbx.hosts.get_id(:host => host) ).should equal $host_id_real
315
+ zbx.hosts.delete( zbx.hosts.get_id(:host => host) ).should be_kind_of(Integer)
344
316
  end
345
317
 
346
318
  it "ITEM: Delete" do
347
319
  zbx.items.delete(
348
320
  zbx.items.get_id(:description => item)
349
- ).should equal $item_id_real
321
+ ).should be_kind_of(Integer)
350
322
  end
351
323
 
352
324
  it "APPLICATION: Delete" do
353
- zbx.applications.delete( zbx.applications.get_id(:name => application) ).should equal $application_id_real
325
+ zbx.applications.delete( zbx.applications.get_id(:name => application) )
354
326
  end
355
327
 
356
328
  it "TEMPLATE: Delete" do
357
- zbx.templates.delete(zbx.templates.get_id(:host => template)).should equal $template_id_real
329
+ zbx.templates.delete(zbx.templates.get_id(:host => template))
358
330
  end
359
331
 
360
332
  it "HOSTGROUP: Delete" do
361
333
  zbx.hostgroups.delete(
362
334
  zbx.hostgroups.get_id(:name => hostgroup)
363
- ).should equal $hostgroup_id_real
335
+ ).should be_kind_of(Integer)
364
336
  end
365
337
 
366
338
  it "USER: Create" do
367
- $user_id_real = zbx.users.create(
339
+ zbx.users.create(
368
340
  :alias => "Test #{user}",
369
341
  :name => user,
370
342
  :surname => user,
371
343
  :passwd => user
372
- )
373
- $user_id_real.should be_kind_of(Integer)
344
+ ).should be_kind_of(Integer)
374
345
  end
375
346
 
376
347
  it "USER: Create or update" do
@@ -379,31 +350,34 @@ describe ZabbixApi, "test_api" do
379
350
  :name => user,
380
351
  :surname => user,
381
352
  :passwd => user
382
- ).should equal $user_id_real
353
+ ).should be_kind_of(Integer)
354
+ end
355
+
356
+ it "USER: Find" do
357
+ zbx.users.get_full_data(:name => user)[0]['name'].should be_kind_of(String)
383
358
  end
384
359
 
385
360
  it "USER: Update" do
386
- zbx.users.update(:userid => zbx.users.get_id(:name => user), :name => user2).should equal $user_id_real
361
+ zbx.users.update(:userid => zbx.users.get_id(:name => user), :name => user2).should be_kind_of(Integer)
387
362
  end
388
363
 
389
364
  it "USER: Find unknown" do
390
- zbx.users.get_id(:name => "#{user}_____").should be_kind_of(NilClass)
365
+ zbx.users.get_id(:name => "#{user}_____")
391
366
  end
392
367
 
393
368
  it "USERGROUPS: Create" do
394
- $usergrp_id_real = zbx.usergroups.create(:name => usergroup)
395
- $usergrp_id_real.should be_kind_of(Integer)
369
+ zbx.usergroups.create(:name => usergroup).should be_kind_of(Integer)
396
370
  end
397
371
 
398
372
  it "USERGROUPS: Create or update" do
399
- zbx.usergroups.get_or_create(:name => usergroup).should equal $usergrp_id_real
373
+ zbx.usergroups.get_or_create(:name => usergroup).should be_kind_of(Integer)
400
374
  end
401
375
 
402
376
  it "USERGROUPS: Add user" do
403
377
  zbx.usergroups.add_user(
404
378
  :usrgrpids => [zbx.usergroups.get_id(:name => usergroup)],
405
379
  :userids => [zbx.users.get_id(:name => user2)]
406
- ).should equal $usergrp_id_real
380
+ ).should be_kind_of(Integer)
407
381
  end
408
382
 
409
383
  it "USERGROUPS: Set UserGroup read & write perm" do
@@ -411,24 +385,23 @@ describe ZabbixApi, "test_api" do
411
385
  :usrgrpid => zbx.usergroups.get_or_create(:name => usergroup).to_s,
412
386
  :hostgroupids => zbx.hostgroups.all.values,
413
387
  :permission => 3
414
- ).should equal $usergrp_id_real
388
+ ).should be_kind_of(Integer)
415
389
  end
416
390
 
417
391
  it "MEDIATYPE: Create" do
418
- $meditype_id_real = zbx.mediatypes.create(
392
+ zbx.mediatypes.create(
419
393
  :description => mediatype,
420
394
  :type => 0,
421
395
  :smtp_server => "127.0.0.1",
422
396
  :smtp_email => "zabbix@test.com"
423
- )
424
- $meditype_id_real.should be_kind_of(Integer)
397
+ ).should be_kind_of(Integer)
425
398
  end
426
399
 
427
400
  it "MEDIATYPE: Update or create" do
428
401
  zbx.mediatypes.create_or_update(
429
402
  :description => mediatype,
430
403
  :smtp_email => "zabbix2@test.com"
431
- ).should equal $meditype_id_real
404
+ ).should be_kind_of(Integer)
432
405
  end
433
406
 
434
407
  it "USER: Add mediatype" do
@@ -443,21 +416,21 @@ describe ZabbixApi, "test_api" do
443
416
  :severity => "56"
444
417
  }
445
418
  ]
446
- ).should equal $user_id_real
419
+ ).should be_kind_of(Integer)
447
420
  end
448
421
 
449
422
  it "MEDIATYPE: Delete" do
450
423
  zbx.mediatypes.delete(
451
424
  zbx.mediatypes.get_id(:description => mediatype)
452
- ).should equal $meditype_id_real
425
+ ).should be_kind_of(Integer)
453
426
  end
454
427
 
455
428
  it "USER: Delete" do
456
- zbx.users.delete(zbx.users.get_id(:name => user2)).should equal $user_id_real
429
+ zbx.users.delete(zbx.users.get_id(:name => user2)).should be_kind_of(Integer)
457
430
  end
458
431
 
459
432
  it "USERGROUPS: Delete" do
460
- zbx.usergroups.delete([zbx.usergroups.get_id(:name => usergroup)]).should equal $usergrp_id_real
433
+ zbx.usergroups.delete([zbx.usergroups.get_id(:name => usergroup)]).should be_kind_of(Integer)
461
434
  end
462
435
 
463
436
  it "QUERY" do