mcollective-test 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,34 +1,101 @@
|
|
1
1
|
module MCollective
|
2
2
|
module Test
|
3
3
|
module Matchers
|
4
|
-
def have_data_items(*items); RPCResultItems.new(items);
|
4
|
+
def have_data_items(*items); RPCResultItems.new(items);end
|
5
5
|
|
6
6
|
class RPCResultItems
|
7
7
|
def initialize(expected)
|
8
|
-
@expected = expected
|
8
|
+
@expected = expected
|
9
|
+
@actual = []
|
9
10
|
end
|
10
11
|
|
11
12
|
def matches?(actual)
|
13
|
+
if actual == []
|
14
|
+
return false
|
15
|
+
end
|
16
|
+
|
12
17
|
[actual].flatten.each do |result|
|
13
18
|
result = result.results if result.is_a?(MCollective::RPC::Result)
|
14
|
-
|
15
|
-
@actual
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
@nodeid = result[:data][:test_sender]
|
20
|
+
@actual << result
|
21
|
+
@expected.each do |e|
|
22
|
+
if e.is_a? Hash
|
23
|
+
e.keys.each do |k|
|
24
|
+
unless result[:data].keys.include?(k)
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
e.keys.each do |k|
|
29
|
+
if e[k].is_a?(String) || e[k].is_a?(Regexp)
|
30
|
+
unless result[:data][k].match e[k]
|
31
|
+
return false
|
32
|
+
end
|
33
|
+
else
|
34
|
+
unless result[:data][k] == e[k]
|
35
|
+
return false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
else
|
40
|
+
unless result[:data].keys.include? e
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
end
|
19
44
|
end
|
20
45
|
end
|
21
|
-
|
22
46
|
true
|
23
47
|
end
|
24
48
|
|
25
49
|
def failure_message
|
26
|
-
|
50
|
+
return_string = "Failure from #{@nodeid}\n"
|
51
|
+
return_string << "Expected : \n"
|
52
|
+
@expected.each do |e|
|
53
|
+
if e.is_a? Hash
|
54
|
+
e.keys.each do |k|
|
55
|
+
return_string << " '#{k}' with value '#{e[k]}'\n"
|
56
|
+
end
|
57
|
+
else
|
58
|
+
return_string << " '#{e}' to be present\n"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
return_string << "Got : \n"
|
63
|
+
@actual.each do |a|
|
64
|
+
if a[:sender] == @nodeid
|
65
|
+
a[:data].each do |data|
|
66
|
+
return_string << " '#{data[0]}' with value '#{data[1]}'\n"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
return_string
|
27
72
|
end
|
28
73
|
|
29
74
|
def negative_failure_message
|
30
|
-
|
75
|
+
return_string = "Failure from #{@nodeid}\n"
|
76
|
+
return_string << "Did not expect : \n"
|
77
|
+
@expected.each do |e|
|
78
|
+
if e.is_a? Hash
|
79
|
+
e.keys.each do |k|
|
80
|
+
return_string << " '#{k}' with value '#{e[k]}'\n"
|
81
|
+
end
|
82
|
+
else
|
83
|
+
return_string << " '#{e}' to not be present\n"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
return_string << "But got : \n"
|
88
|
+
@actual.each do |a|
|
89
|
+
if a[:sender] == @nodeid
|
90
|
+
a[:data].each do |data|
|
91
|
+
return_string << " '#{data[0]}' with value '#{data[1]}'\n"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
return_string
|
31
97
|
end
|
98
|
+
|
32
99
|
end
|
33
100
|
end
|
34
101
|
end
|
@@ -73,7 +73,6 @@ module MCollective
|
|
73
73
|
MCollective::PluginManager.loadclass(classname)
|
74
74
|
end
|
75
75
|
|
76
|
-
MCollective::PluginManager.loadclass(classname)
|
77
76
|
|
78
77
|
MCollective::PluginManager << {:type => "#{application}_application", :class => classname, :single_instance => false}
|
79
78
|
MCollective::PluginManager["#{application}_application"]
|
@@ -101,8 +100,12 @@ module MCollective
|
|
101
100
|
MCollective::PluginManager["#{agent}_agent"]
|
102
101
|
end
|
103
102
|
|
104
|
-
def create_response(senderid, data = {}, statuscode = 0, statusmsg = "OK")
|
105
|
-
|
103
|
+
def create_response(senderid, data = {}, stats = nil , statuscode = 0, statusmsg = "OK")
|
104
|
+
unless stats == nil
|
105
|
+
{:senderid => senderid, :body =>{:data => data, :stats => stats}}
|
106
|
+
else
|
107
|
+
{:senderid => senderid, :body =>{:data => data}}
|
108
|
+
end
|
106
109
|
end
|
107
110
|
end
|
108
111
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcollective-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- R.I.Pienaar
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-08-03 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -27,16 +28,16 @@ extensions: []
|
|
27
28
|
extra_rdoc_files: []
|
28
29
|
|
29
30
|
files:
|
31
|
+
- lib/mcollective/test.rb
|
32
|
+
- lib/mcollective/test/util.rb
|
30
33
|
- lib/mcollective/test/matchers/rpc_result_items.rb
|
31
34
|
- lib/mcollective/test/matchers/rpc_metadata.rb
|
32
|
-
- lib/mcollective/test/matchers/application_description.rb
|
33
35
|
- lib/mcollective/test/matchers/rpc_status.rb
|
34
|
-
- lib/mcollective/test/
|
36
|
+
- lib/mcollective/test/matchers/application_description.rb
|
37
|
+
- lib/mcollective/test/remote_agent_test.rb
|
35
38
|
- lib/mcollective/test/matchers.rb
|
36
39
|
- lib/mcollective/test/application_test.rb
|
37
|
-
- lib/mcollective/test/
|
38
|
-
- lib/mcollective/test/util.rb
|
39
|
-
- lib/mcollective/test.rb
|
40
|
+
- lib/mcollective/test/local_agent_test.rb
|
40
41
|
has_rdoc: true
|
41
42
|
homepage: https://github.com/ripienaar/mcollective-test/
|
42
43
|
licenses: []
|
@@ -47,23 +48,27 @@ rdoc_options: []
|
|
47
48
|
require_paths:
|
48
49
|
- lib
|
49
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
50
52
|
requirements:
|
51
53
|
- - ">="
|
52
54
|
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
53
56
|
segments:
|
54
57
|
- 0
|
55
58
|
version: "0"
|
56
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
57
61
|
requirements:
|
58
62
|
- - ">="
|
59
63
|
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
60
65
|
segments:
|
61
66
|
- 0
|
62
67
|
version: "0"
|
63
68
|
requirements: []
|
64
69
|
|
65
70
|
rubyforge_project:
|
66
|
-
rubygems_version: 1.3.
|
71
|
+
rubygems_version: 1.3.7
|
67
72
|
signing_key:
|
68
73
|
specification_version: 3
|
69
74
|
summary: Test helper for MCollective
|