mcollective-test 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,43 +1,43 @@
1
1
  module MCollective
2
- module Test
3
- class ApplicationTest
4
- attr_reader :config, :logger, :application, :plugin
2
+ module Test
3
+ class ApplicationTest
4
+ attr_reader :config, :logger, :application, :plugin
5
5
 
6
- include Test::Util
6
+ include Test::Util
7
7
 
8
- def initialize(application, options={})
9
- config = options[:config] || {}
10
- facts = options[:facts] || {"fact" => "value"}
8
+ def initialize(application, options={})
9
+ config = options[:config] || {}
10
+ facts = options[:facts] || {"fact" => "value"}
11
11
 
12
- ARGV.clear
12
+ ARGV.clear
13
13
 
14
- @config = create_config_mock(config)
15
- @application = application.to_s
16
- @logger = create_logger_mock
17
- @plugin = load_application(@application, options[:application_file])
14
+ @config = create_config_mock(config)
15
+ @application = application.to_s
16
+ @logger = create_logger_mock
17
+ @plugin = load_application(@application, options[:application_file])
18
18
 
19
- @plugin.stubs(:printrpcstats)
20
- @plugin.stubs(:puts)
21
- @plugin.stubs(:printf)
19
+ @plugin.stubs(:printrpcstats)
20
+ @plugin.stubs(:puts)
21
+ @plugin.stubs(:printf)
22
22
 
23
- make_create_client
24
- end
23
+ make_create_client
24
+ end
25
25
 
26
- def make_create_client
27
- @plugin.instance_eval "
28
- def create_client(client)
29
- mock_client = Mocha::Mock.new
30
- mock_client.stubs(:progress=)
31
- mock_client.stubs(:progress)
26
+ def make_create_client
27
+ @plugin.instance_eval "
28
+ def create_client(client)
29
+ mock_client = Mocha::Mock.new
30
+ mock_client.stubs(:progress=)
31
+ mock_client.stubs(:progress)
32
32
 
33
- yield(mock_client) if block_given?
33
+ yield(mock_client) if block_given?
34
34
 
35
- MCollective::Application::Facts.any_instance.expects(:rpcclient).with(client).returns(mock_client)
35
+ MCollective::Application::Facts.any_instance.expects(:rpcclient).with(client).returns(mock_client)
36
36
 
37
- mock_client
38
- end
39
- "
40
- end
41
- end
37
+ mock_client
38
+ end
39
+ "
40
+ end
42
41
  end
42
+ end
43
43
  end
@@ -1,44 +1,45 @@
1
1
  module MCollective
2
- module Test
3
- class LocalAgentTest
4
- attr_reader :config, :logger, :agent, :connector, :plugin, :facts
5
-
6
- include Test::Util
7
-
8
- def initialize(agent, options={})
9
- config = options[:config]
10
- facts = options[:facts] || {"fact" => "value"}
11
-
12
- @config = create_config_mock(config)
13
- @agent = agent.to_s
14
- @logger = create_logger_mock
15
- @connector = create_connector_mock
16
- @plugin = load_agent(agent, options[:agent_file])
17
-
18
- create_facts_mock(facts)
19
-
20
- make_call_helper
21
- end
22
-
23
-
24
- # Place the mocked connector into the plugin instance and
25
- # create a call helper method that passes the connector in
26
- # and call the action via handlemsg.
27
- #
28
- # This will let you test auditing etc
29
- def make_call_helper
30
- @plugin.instance_variable_set("@mocked_connector", @connector)
31
-
32
- @plugin.instance_eval "
33
- def call(action, args={})
34
- request = {:action => action.to_s,
35
- :agent => '#{@agent}',
36
- :data => args}
37
-
38
- handlemsg({:body => request}, @mocked_connector)
39
- end
40
- "
41
- end
42
- end
2
+ module Test
3
+ class LocalAgentTest
4
+ attr_reader :config, :logger, :agent, :connector, :plugin, :facts
5
+
6
+ include Test::Util
7
+
8
+ def initialize(agent, options={})
9
+ config = options[:config]
10
+ facts = options[:facts] || {"fact" => "value"}
11
+
12
+ @config = create_config_mock(config)
13
+ @agent = agent.to_s
14
+ @logger = create_logger_mock
15
+ @connector = create_connector_mock
16
+ @plugin = load_agent(agent, options[:agent_file])
17
+
18
+ create_facts_mock(facts)
19
+ mock_validators
20
+
21
+ make_call_helper
22
+ end
23
+
24
+
25
+ # Place the mocked connector into the plugin instance and
26
+ # create a call helper method that passes the connector in
27
+ # and call the action via handlemsg.
28
+ #
29
+ # This will let you test auditing etc
30
+ def make_call_helper
31
+ @plugin.instance_variable_set("@mocked_connector", @connector)
32
+
33
+ @plugin.instance_eval "
34
+ def call(action, args={})
35
+ request = {:action => action.to_s,
36
+ :agent => '#{@agent}',
37
+ :data => args}
38
+
39
+ handlemsg({:body => request}, @mocked_connector)
40
+ end
41
+ "
42
+ end
43
43
  end
44
+ end
44
45
  end
@@ -1,39 +1,39 @@
1
1
  module MCollective
2
- module Test
3
- module Matchers
4
- def have_a_description(description=nil); ApplicationDescription.new(description); end
2
+ module Test
3
+ module Matchers
4
+ def have_a_description(description=nil); ApplicationDescription.new(description); end
5
5
 
6
- class ApplicationDescription
7
- def initialize(match=nil)
8
- @match = match
9
- end
6
+ class ApplicationDescription
7
+ def initialize(match=nil)
8
+ @match = match
9
+ end
10
10
 
11
- def matches?(actual)
12
- @actual = actual.application_description
11
+ def matches?(actual)
12
+ @actual = actual.application_description
13
13
 
14
- if @match
15
- return @actual == @match
16
- else
17
- return !@actual.nil?
18
- end
19
- end
14
+ if @match
15
+ return @actual == @match
16
+ else
17
+ return !@actual.nil?
18
+ end
19
+ end
20
20
 
21
- def failure_message
22
- if @match
23
- "application should have a description '#{@match}' but got '#{@actual}'"
24
- else
25
- "application should have a description, got #{@match}"
26
- end
27
- end
21
+ def failure_message
22
+ if @match
23
+ "application should have a description '#{@match}' but got '#{@actual}'"
24
+ else
25
+ "application should have a description, got #{@match}"
26
+ end
27
+ end
28
28
 
29
- def negative_failure_message
30
- if @match
31
- "application should not have a description matching '#{@match}' but got '#{@actual}'"
32
- else
33
- "application should not have a description"
34
- end
35
- end
36
- end
29
+ def negative_failure_message
30
+ if @match
31
+ "application should not have a description matching '#{@match}' but got '#{@actual}'"
32
+ else
33
+ "application should not have a description"
34
+ end
37
35
  end
36
+ end
38
37
  end
38
+ end
39
39
  end
@@ -1,40 +1,40 @@
1
1
  module MCollective
2
- module Test
3
- module Matchers
4
- def have_valid_metadata; RPCMetadata.new; end
2
+ module Test
3
+ module Matchers
4
+ def have_valid_metadata; RPCMetadata.new; end
5
5
 
6
- class RPCMetadata
7
- def matches?(actual)
8
- actual = actual.meta
6
+ class RPCMetadata
7
+ def matches?(actual)
8
+ actual = actual.meta
9
9
 
10
- @msg = "Unknown error"
10
+ @msg = "Unknown error"
11
11
 
12
- [:name, :description, :author, :license, :version, :url, :timeout].each do |item|
13
- unless actual.include?(item)
14
- @msg = "needs a '#{item}' item"
15
- return false
16
- end
17
- end
12
+ [:name, :description, :author, :license, :version, :url, :timeout].each do |item|
13
+ unless actual.include?(item)
14
+ @msg = "needs a '#{item}' item"
15
+ return false
16
+ end
17
+ end
18
18
 
19
- [:name, :description, :author, :license, :version, :url].each do |item|
20
- unless actual[item].is_a?(String)
21
- @msg = "#{item} should be a string"
22
- return false
23
- end
24
- end
19
+ [:name, :description, :author, :license, :version, :url].each do |item|
20
+ unless actual[item].is_a?(String)
21
+ @msg = "#{item} should be a string"
22
+ return false
23
+ end
24
+ end
25
25
 
26
- unless actual[:timeout].is_a?(Numeric)
27
- @msg = "timeout should be numeric"
28
- return false
29
- end
26
+ unless actual[:timeout].is_a?(Numeric)
27
+ @msg = "timeout should be numeric"
28
+ return false
29
+ end
30
30
 
31
- return true
32
- end
31
+ return true
32
+ end
33
33
 
34
- def failure_message
35
- "Invalid meta data: #{@msg}"
36
- end
37
- end
34
+ def failure_message
35
+ "Invalid meta data: #{@msg}"
38
36
  end
37
+ end
39
38
  end
39
+ end
40
40
  end
@@ -1,102 +1,102 @@
1
1
  module MCollective
2
- module Test
3
- module Matchers
4
- def have_data_items(*items); RPCResultItems.new(items);end
2
+ module Test
3
+ module Matchers
4
+ def have_data_items(*items); RPCResultItems.new(items);end
5
5
 
6
- class RPCResultItems
7
- def initialize(expected)
8
- @expected = expected
9
- @actual = []
10
- end
6
+ class RPCResultItems
7
+ def initialize(expected)
8
+ @expected = expected
9
+ @actual = []
10
+ end
11
11
 
12
- def matches?(actual)
13
- if actual == []
14
- return false
15
- end
12
+ def matches?(actual)
13
+ if actual == []
14
+ return false
15
+ end
16
16
 
17
- [actual].flatten.each do |result|
18
- result = result.results if result.is_a?(MCollective::RPC::Result)
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
44
- end
45
- end
46
- true
17
+ [actual].flatten.each do |result|
18
+ result = result.results if result.is_a?(MCollective::RPC::Result)
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
47
27
  end
48
-
49
- def failure_message
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
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
60
32
  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
33
+ else
34
+ unless result[:data][k] == e[k]
35
+ return false
69
36
  end
70
-
71
- return_string
37
+ end
38
+ end
39
+ else
40
+ unless result[:data].keys.include? e
41
+ return false
72
42
  end
43
+ end
44
+ end
45
+ end
46
+ true
47
+ end
73
48
 
74
- def negative_failure_message
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
49
+ def failure_message
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
86
61
 
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
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
95
70
 
96
- return_string
97
- end
71
+ return_string
72
+ end
73
+
74
+ def negative_failure_message
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
98
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
99
93
  end
94
+ end
95
+
96
+ return_string
100
97
  end
98
+
99
+ end
101
100
  end
101
+ end
102
102
  end
@@ -1,48 +1,48 @@
1
1
  module MCollective
2
- module Test
3
- module Matchers
4
- def rpc_success; RPCStatus.new(0); end
5
- def rpc_aborted; RPCStatus.new(1); end
6
- def rpc_unknown_action; RPCStatus.new(2); end
7
- def rpc_missing_data; RPCStatus.new(3); end
8
- def rpc_invalid_data; RPCStatus.new(4); end
9
- def rpc_unknown; RPCStatus.new(5); end
2
+ module Test
3
+ module Matchers
4
+ def rpc_success; RPCStatus.new(0); end
5
+ def rpc_aborted; RPCStatus.new(1); end
6
+ def rpc_unknown_action; RPCStatus.new(2); end
7
+ def rpc_missing_data; RPCStatus.new(3); end
8
+ def rpc_invalid_data; RPCStatus.new(4); end
9
+ def rpc_unknown; RPCStatus.new(5); end
10
10
 
11
- alias be_successful rpc_success
12
- alias be_aborted_error rpc_aborted
13
- alias be_unknown_action_error rpc_unknown_action
14
- alias be_missing_data_error rpc_missing_data
15
- alias be_invalid_data_error rpc_invalid_data
16
- alias be_unknown_error rpc_unknown
11
+ alias be_successful rpc_success
12
+ alias be_aborted_error rpc_aborted
13
+ alias be_unknown_action_error rpc_unknown_action
14
+ alias be_missing_data_error rpc_missing_data
15
+ alias be_invalid_data_error rpc_invalid_data
16
+ alias be_unknown_error rpc_unknown
17
17
 
18
- class RPCStatus
19
- def initialize(code)
20
- @code = code
21
- end
18
+ class RPCStatus
19
+ def initialize(code)
20
+ @code = code
21
+ end
22
22
 
23
- def matches?(actual)
24
- if actual == []
25
- return false
26
- end
27
- [actual].flatten.each do |result|
28
- result = result.results if result.is_a?(MCollective::RPC::Result)
23
+ def matches?(actual)
24
+ if actual == []
25
+ return false
26
+ end
27
+ [actual].flatten.each do |result|
28
+ result = result.results if result.is_a?(MCollective::RPC::Result)
29
29
 
30
- @actual = result[:statuscode]
30
+ @actual = result[:statuscode]
31
31
 
32
- unless @actual == @code
33
- return false
34
- end
35
- end
36
- end
32
+ unless @actual == @code
33
+ return false
34
+ end
35
+ end
36
+ end
37
37
 
38
- def failure_message
39
- "expected :statuscode == #{@code} but got '#{@actual}'"
40
- end
38
+ def failure_message
39
+ "expected :statuscode == #{@code} but got '#{@actual}'"
40
+ end
41
41
 
42
- def negative_failure_message
43
- "expected :statucode != #{@code} but got '#{@actual}'"
44
- end
45
- end
42
+ def negative_failure_message
43
+ "expected :statucode != #{@code} but got '#{@actual}'"
46
44
  end
45
+ end
47
46
  end
47
+ end
48
48
  end
@@ -1,10 +1,10 @@
1
1
  module MCollective
2
- module Test
3
- module Matchers
4
- require 'mcollective/test/matchers/rpc_result_items.rb'
5
- require 'mcollective/test/matchers/rpc_metadata.rb'
6
- require 'mcollective/test/matchers/rpc_status.rb'
7
- require 'mcollective/test/matchers/application_description.rb'
8
- end
2
+ module Test
3
+ module Matchers
4
+ require 'mcollective/test/matchers/rpc_result_items.rb'
5
+ require 'mcollective/test/matchers/rpc_metadata.rb'
6
+ require 'mcollective/test/matchers/rpc_status.rb'
7
+ require 'mcollective/test/matchers/application_description.rb'
9
8
  end
9
+ end
10
10
  end
@@ -1,15 +1,15 @@
1
1
  module MCollective
2
- module Test
3
- class RemoteAgentTest
4
- attr_reader :agent, :plugin
2
+ module Test
3
+ class RemoteAgentTest
4
+ attr_reader :agent, :plugin
5
5
 
6
- include MCollective::RPC
6
+ include MCollective::RPC
7
7
 
8
- def initialize(agent)
9
- @agent = agent.to_s
10
- @plugin = rpcclient(agent)
11
- @plugin.progress = false
12
- end
13
- end
8
+ def initialize(agent)
9
+ @agent = agent.to_s
10
+ @plugin = rpcclient(agent)
11
+ @plugin.progress = false
12
+ end
14
13
  end
14
+ end
15
15
  end
@@ -1,112 +1,123 @@
1
1
  module MCollective
2
- module Test
3
- module Util
4
- def create_facts_mock(factsource)
5
- facts = Mocha::Mock.new('facts')
6
- facts.stubs(:get_facts).returns(factsource)
7
-
8
- factsource.each_pair do |k, v|
9
- facts.stubs(:get_fact).with(k).returns(v)
10
- end
2
+ module Test
3
+ module Util
4
+ def create_facts_mock(factsource)
5
+ facts = Mocha::Mock.new('facts')
6
+ facts.stubs(:get_facts).returns(factsource)
7
+
8
+ factsource.each_pair do |k, v|
9
+ facts.stubs(:get_fact).with(k).returns(v)
10
+ end
11
11
 
12
- MCollective::PluginManager << {:type => "facts_plugin", :class => facts, :single_instance => false}
12
+ MCollective::PluginManager << {:type => "facts_plugin", :class => facts, :single_instance => false}
13
+ end
14
+
15
+ def create_config_mock(config)
16
+ cfg = Mocha::Mock.new('config')
17
+ cfg.stubs(:configured).returns(true)
18
+ cfg.stubs(:rpcauthorization).returns(false)
19
+ cfg.stubs(:main_collective).returns("mcollective")
20
+ cfg.stubs(:collectives).returns(["production", "staging"])
21
+ cfg.stubs(:classesfile).returns("classes.txt")
22
+ cfg.stubs(:identity).returns("rspec_tests")
23
+ cfg.stubs(:logger_type).returns("console")
24
+ cfg.stubs(:loglevel).returns("error")
25
+
26
+ if config
27
+ config.each_pair do |k, v|
28
+ cfg.send(:stubs, k).returns(v)
29
+ end
30
+
31
+ if config.include?(:libdir)
32
+ [config[:libdir]].flatten.each do |dir|
33
+ $: << dir if File.exist?(dir)
13
34
  end
14
35
 
15
- def create_config_mock(config)
16
- cfg = Mocha::Mock.new('config')
17
- cfg.stubs(:configured).returns(true)
18
- cfg.stubs(:rpcauthorization).returns(false)
19
- cfg.stubs(:main_collective).returns("mcollective")
20
- cfg.stubs(:collectives).returns(["production", "staging"])
21
- cfg.stubs(:classesfile).returns("classes.txt")
22
- cfg.stubs(:identity).returns("rspec_tests")
23
-
24
- if config
25
- config.each_pair do |k, v|
26
- cfg.send(:stubs, k).returns(v)
27
- end
28
-
29
- if config.include?(:libdir)
30
- [config[:libdir]].flatten.each do |dir|
31
- $: << dir if File.exist?(dir)
32
- end
33
- end
34
- end
35
-
36
- MCollective::Config.stubs(:instance).returns(cfg)
37
-
38
- cfg
39
- end
36
+ cfg.stubs(:libdir).returns(config[:libdir])
37
+ end
38
+ end
40
39
 
41
- def create_logger_mock
42
- logger = Mocha::Mock.new(:logger)
40
+ MCollective::Config.stubs(:instance).returns(cfg)
43
41
 
44
- [:log, :start, :debug, :info, :warn].each do |meth|
45
- logger.stubs(meth)
46
- end
42
+ cfg
43
+ end
47
44
 
48
- MCollective::Log.configure(logger)
45
+ def mock_validators
46
+ MCollective::Validator.stubs(:load_validators)
47
+ MCollective::Validator.stubs(:validate).returns(true)
48
+ end
49
49
 
50
- logger
51
- end
50
+ def create_logger_mock
51
+ logger = Mocha::Mock.new(:logger)
52
+
53
+ [:log, :start, :debug, :info, :warn].each do |meth|
54
+ logger.stubs(meth)
55
+ end
52
56
 
53
- def create_connector_mock
54
- connector = Mocha::Mock.new(:connector)
57
+ MCollective::Log.configure(logger)
55
58
 
56
- [:connect, :receive, :publish, :subscribe, :unsubscribe, :disconnect].each do |meth|
57
- connector.stubs(meth)
58
- end
59
+ logger
60
+ end
59
61
 
60
- MCollective::PluginManager << {:type => "connector_plugin", :class => connector}
62
+ def create_connector_mock
63
+ connector = Mocha::Mock.new(:connector)
61
64
 
62
- connector
63
- end
65
+ [:connect, :receive, :publish, :subscribe, :unsubscribe, :disconnect].each do |meth|
66
+ connector.stubs(meth)
67
+ end
64
68
 
65
- def load_application(application, application_file=nil)
66
- classname = "MCollective::Application::#{application.capitalize}"
67
- MCollective::PluginManager.delete("#{application}_application")
69
+ MCollective::PluginManager << {:type => "connector_plugin", :class => connector}
68
70
 
69
- if application_file
70
- raise "Cannot find application file #{application_file} for application #{application}" unless File.exist?(application_file)
71
- load application_file
72
- else
73
- MCollective::PluginManager.loadclass(classname)
74
- end
71
+ connector
72
+ end
75
73
 
74
+ def load_application(application, application_file=nil)
75
+ classname = "MCollective::Application::#{application.capitalize}"
76
+ MCollective::PluginManager.delete("#{application}_application")
76
77
 
77
- MCollective::PluginManager << {:type => "#{application}_application", :class => classname, :single_instance => false}
78
- MCollective::PluginManager["#{application}_application"]
79
- end
78
+ if application_file
79
+ raise "Cannot find application file #{application_file} for application #{application}" unless File.exist?(application_file)
80
+ load application_file
81
+ else
82
+ MCollective::PluginManager.loadclass(classname)
83
+ end
84
+
85
+ MCollective::PluginManager << {:type => "#{application}_application", :class => classname, :single_instance => false}
86
+ MCollective::PluginManager["#{application}_application"]
87
+ end
80
88
 
81
- def load_agent(agent, agent_file=nil)
82
- classname = "MCollective::Agent::#{agent.capitalize}"
89
+ def load_agent(agent, agent_file=nil)
90
+ classname = "MCollective::Agent::#{agent.capitalize}"
83
91
 
84
- MCollective::PluginManager.delete("#{agent}_agent")
92
+ MCollective::PluginManager.delete("#{agent}_agent")
85
93
 
86
- if agent_file
87
- raise "Cannot find agent file #{agent_file} for agent #{agent}" unless File.exist?(agent_file)
88
- load agent_file
89
- else
90
- MCollective::PluginManager.loadclass(classname)
91
- end
94
+ if agent_file
95
+ raise "Cannot find agent file #{agent_file} for agent #{agent}" unless File.exist?(agent_file)
96
+ load agent_file
97
+ else
98
+ MCollective::PluginManager.loadclass(classname)
99
+ end
92
100
 
93
- # Stub out startup_hook as this feature should probably
94
- # be deprecated and it's really hard to test
101
+ # Stub out startup_hook as this feature should probably
102
+ # be deprecated and it's really hard to test
95
103
 
96
- klass = MCollective::Agent.const_get(agent.capitalize)
97
- klass.any_instance.stubs(:startup_hook).returns(true)
104
+ klass = MCollective::Agent.const_get(agent.capitalize)
98
105
 
99
- MCollective::PluginManager << {:type => "#{agent}_agent", :class => classname, :single_instance => false}
100
- MCollective::PluginManager["#{agent}_agent"]
101
- end
106
+ klass.any_instance.stubs("load_ddl").returns(true)
107
+ klass.any_instance.stubs(:startup_hook).returns(true)
108
+ MCollective::RPC::Request.any_instance.stubs(:validate!).returns(true)
102
109
 
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
109
- end
110
+ MCollective::PluginManager << {:type => "#{agent}_agent", :class => classname, :single_instance => false}
111
+ MCollective::PluginManager["#{agent}_agent"]
112
+ end
113
+
114
+ def create_response(senderid, data = {}, stats = nil , statuscode = 0, statusmsg = "OK")
115
+ unless stats == nil
116
+ {:senderid => senderid, :body =>{:data => data, :stats => stats}}
117
+ else
118
+ {:senderid => senderid, :body =>{:data => data}}
110
119
  end
120
+ end
111
121
  end
122
+ end
112
123
  end
@@ -1,9 +1,9 @@
1
1
  module MCollective
2
- module Test
3
- autoload :Util, "mcollective/test/util"
4
- autoload :Matchers, "mcollective/test/matchers"
5
- autoload :LocalAgentTest, "mcollective/test/local_agent_test.rb"
6
- autoload :RemoteAgentTest, "mcollective/test/remote_agent_test.rb"
7
- autoload :ApplicationTest, "mcollective/test/application_test.rb"
8
- end
2
+ module Test
3
+ autoload :Util, "mcollective/test/util"
4
+ autoload :Matchers, "mcollective/test/matchers"
5
+ autoload :LocalAgentTest, "mcollective/test/local_agent_test.rb"
6
+ autoload :RemoteAgentTest, "mcollective/test/remote_agent_test.rb"
7
+ autoload :ApplicationTest, "mcollective/test/application_test.rb"
8
+ end
9
9
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcollective-test
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 4
10
- version: 0.1.4
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-21 00:00:00 +00:00
18
+ date: 2012-09-14 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21