hammer_cli_foreman 0.0.18 → 0.1.0

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.

Potentially problematic release.


This version of hammer_cli_foreman might be problematic. Click here for more details.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_foreman.rb +39 -27
  3. data/lib/hammer_cli_foreman/architecture.rb +14 -14
  4. data/lib/hammer_cli_foreman/associating_commands.rb +46 -40
  5. data/lib/hammer_cli_foreman/auth.rb +49 -0
  6. data/lib/hammer_cli_foreman/commands.rb +82 -29
  7. data/lib/hammer_cli_foreman/common_parameter.rb +13 -17
  8. data/lib/hammer_cli_foreman/compute_resource.rb +23 -23
  9. data/lib/hammer_cli_foreman/credentials.rb +36 -0
  10. data/lib/hammer_cli_foreman/domain.rb +32 -35
  11. data/lib/hammer_cli_foreman/environment.rb +14 -19
  12. data/lib/hammer_cli_foreman/exception_handler.rb +30 -8
  13. data/lib/hammer_cli_foreman/fact.rb +5 -5
  14. data/lib/hammer_cli_foreman/host.rb +178 -105
  15. data/lib/hammer_cli_foreman/hostgroup.rb +59 -37
  16. data/lib/hammer_cli_foreman/i18n.rb +24 -0
  17. data/lib/hammer_cli_foreman/image.rb +24 -24
  18. data/lib/hammer_cli_foreman/location.rb +13 -13
  19. data/lib/hammer_cli_foreman/media.rb +21 -16
  20. data/lib/hammer_cli_foreman/model.rb +16 -16
  21. data/lib/hammer_cli_foreman/operating_system.rb +39 -39
  22. data/lib/hammer_cli_foreman/organization.rb +13 -13
  23. data/lib/hammer_cli_foreman/output/fields.rb +2 -2
  24. data/lib/hammer_cli_foreman/output/formatters.rb +15 -4
  25. data/lib/hammer_cli_foreman/parameter.rb +13 -11
  26. data/lib/hammer_cli_foreman/partition_table.rb +17 -18
  27. data/lib/hammer_cli_foreman/puppet_class.rb +9 -9
  28. data/lib/hammer_cli_foreman/report.rb +38 -38
  29. data/lib/hammer_cli_foreman/resource_supported_test.rb +1 -1
  30. data/lib/hammer_cli_foreman/smart_class_parameter.rb +36 -36
  31. data/lib/hammer_cli_foreman/smart_proxy.rb +22 -21
  32. data/lib/hammer_cli_foreman/subnet.rb +29 -31
  33. data/lib/hammer_cli_foreman/template.rb +45 -43
  34. data/lib/hammer_cli_foreman/user.rb +20 -23
  35. data/lib/hammer_cli_foreman/version.rb +1 -1
  36. data/locale/Makefile +64 -0
  37. data/locale/hammer-cli-foreman.pot +1573 -0
  38. data/locale/zanata.xml +29 -0
  39. data/test/unit/apipie_resource_mock.rb +44 -72
  40. data/test/unit/architecture_test.rb +1 -2
  41. data/test/unit/commands_test.rb +23 -21
  42. data/test/unit/common_parameter_test.rb +15 -10
  43. data/test/unit/compute_resource_test.rb +1 -2
  44. data/test/unit/credentials_test.rb +46 -0
  45. data/test/unit/data/1.4/foreman_api.json +10387 -0
  46. data/test/unit/domain_test.rb +2 -5
  47. data/test/unit/environment_test.rb +2 -3
  48. data/test/unit/exception_handler_test.rb +29 -4
  49. data/test/unit/fact_test.rb +0 -1
  50. data/test/unit/helpers/command.rb +20 -4
  51. data/test/unit/helpers/resource_disabled.rb +2 -2
  52. data/test/unit/host_test.rb +24 -12
  53. data/test/unit/hostgroup_test.rb +7 -8
  54. data/test/unit/image_test.rb +6 -7
  55. data/test/unit/location_test.rb +9 -5
  56. data/test/unit/media_test.rb +1 -9
  57. data/test/unit/model_test.rb +1 -3
  58. data/test/unit/operating_system_test.rb +7 -9
  59. data/test/unit/organization_test.rb +12 -6
  60. data/test/unit/output/formatters_test.rb +5 -0
  61. data/test/unit/partition_table_test.rb +1 -2
  62. data/test/unit/puppet_class_test.rb +2 -3
  63. data/test/unit/report_test.rb +1 -2
  64. data/test/unit/smart_class_parameter_test.rb +9 -4
  65. data/test/unit/smart_proxy_test.rb +1 -2
  66. data/test/unit/subnet_test.rb +2 -3
  67. data/test/unit/template_test.rb +23 -8
  68. data/test/unit/test_helper.rb +13 -0
  69. data/test/unit/test_output_adapter.rb +1 -1
  70. data/test/unit/user_test.rb +1 -2
  71. metadata +17 -7
@@ -7,7 +7,6 @@ describe HammerCLIForeman::Domain do
7
7
  extend CommandTestHelper
8
8
 
9
9
  before :each do
10
- cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
10
  cmd.stubs(:name_to_id).returns(1)
12
11
  end
13
12
 
@@ -21,7 +20,7 @@ describe HammerCLIForeman::Domain do
21
20
  end
22
21
 
23
22
  context "output" do
24
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
23
+ let(:expected_record_count) { cmd.resource.call(:index).length }
25
24
 
26
25
  it_should_print_n_records
27
26
  it_should_print_columns ["Id", "Name"]
@@ -97,9 +96,7 @@ describe HammerCLIForeman::Domain do
97
96
  context "SetParameterCommand" do
98
97
 
99
98
  before :each do
100
- resource_mock = ApipieResourceMock.new(cmd.class.resource.resource_class)
101
- resource_mock.stub_method(:index, [])
102
- cmd.class.resource resource_mock
99
+ ResourceMocks.parameters_index
103
100
  end
104
101
 
105
102
  let(:cmd) { HammerCLIForeman::Domain::SetParameterCommand.new("", ctx) }
@@ -7,7 +7,6 @@ describe HammerCLIForeman::Environment do
7
7
  extend CommandTestHelper
8
8
 
9
9
  before :each do
10
- cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
10
  cmd.stubs(:name_to_id).returns(1)
12
11
  end
13
12
 
@@ -21,7 +20,7 @@ describe HammerCLIForeman::Environment do
21
20
  end
22
21
 
23
22
  context "output" do
24
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
23
+ let(:expected_record_count) { cmd.resource.call(:index).length }
25
24
 
26
25
  it_should_print_n_records
27
26
  it_should_print_column "Name"
@@ -95,7 +94,7 @@ describe HammerCLIForeman::Environment do
95
94
  context "SCParamsCommand" do
96
95
 
97
96
  before :each do
98
- cmd.class.resource ResourceMocks.smart_class_parameter
97
+ ResourceMocks.smart_class_parameters_index
99
98
  end
100
99
 
101
100
  let(:cmd) { HammerCLIForeman::Environment::SCParamsCommand.new("", ctx) }
@@ -57,9 +57,9 @@ describe HammerCLIForeman::ExceptionHandler do
57
57
  end
58
58
 
59
59
  it "should print resource errors on resource not found exception" do
60
- response = <<-RESPONSE
61
- {"error":{"message":"Resource architecture not found by id '1'"}}
62
- RESPONSE
60
+ response = <<-RESPONSE
61
+ {"error":{"message":"Resource architecture not found by id '1'"}}
62
+ RESPONSE
63
63
  ex = RestClient::ResourceNotFound.new(response)
64
64
  ex.stubs(:message).returns("")
65
65
 
@@ -69,7 +69,7 @@ describe HammerCLIForeman::ExceptionHandler do
69
69
  end
70
70
 
71
71
  it "should print exception message on resource not found exception without explicit message" do
72
- response = '{"error": ""}'
72
+ response = '{"error": ""}'
73
73
  ex = RestClient::ResourceNotFound.new(response)
74
74
  ex.stubs(:message).returns("ResourceNotFound message")
75
75
 
@@ -78,5 +78,30 @@ describe HammerCLIForeman::ExceptionHandler do
78
78
  err_code.must_equal HammerCLI::EX_NOT_FOUND
79
79
  end
80
80
 
81
+ it "should print resource errors on internal error exception" do
82
+ response = <<-RESPONSE
83
+ {"error":{"message":"Some internal exception"}}
84
+ RESPONSE
85
+ ex = RestClient::InternalServerError.new(response)
86
+ ex.stubs(:message).returns("")
87
+
88
+ output.expects(:print_error).with(heading, "Some internal exception")
89
+ err_code = handler.handle_exception(ex, :heading => heading)
90
+ err_code.must_equal HammerCLI::EX_SOFTWARE
91
+ end
92
+
93
+ it "should print exception message on internal error exception without formatted message" do
94
+ response = <<-RESPONSE.gsub(/^\s+/, "")
95
+ Unformatted
96
+ lines
97
+ RESPONSE
98
+ ex = RestClient::InternalServerError.new(response)
99
+ ex.stubs(:message).returns(response)
100
+
101
+ output.expects(:print_error).with("Something went wrong", "Unformatted\nlines\n")
102
+ err_code = handler.handle_exception(ex, :heading => heading)
103
+ err_code.must_equal HammerCLI::EX_SOFTWARE
104
+ end
105
+
81
106
  end
82
107
 
@@ -7,7 +7,6 @@ describe HammerCLIForeman::Fact do
7
7
  extend CommandTestHelper
8
8
 
9
9
  before :each do
10
- cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
10
  cmd.stubs(:name_to_id).returns(1)
12
11
  end
13
12
 
@@ -13,7 +13,9 @@ module CommandTestHelper
13
13
  def it_should_call_action(action, params, headers={})
14
14
  it "should call action "+action.to_s do
15
15
  arguments ||= respond_to?(:with_params) ? with_params : []
16
- cmd.resource.resource_class.expects_with(action, params, headers)
16
+ ApipieBindings::API.any_instance.expects(:call).with() do |r,a,p,h,o|
17
+ (r == cmd.resource.name && a == action && p == params && h == headers)
18
+ end
17
19
  cmd.run(arguments)
18
20
  end
19
21
  end
@@ -21,7 +23,9 @@ module CommandTestHelper
21
23
  def it_should_call_action_and_test_params(action, &block)
22
24
  it "should call action "+action.to_s do
23
25
  arguments ||= respond_to?(:with_params) ? with_params : []
24
- cmd.resource.resource_class.expects_with_block(action, &block)
26
+ ApipieBindings::API.any_instance.expects(:call).with() do |r,a,p,h,o|
27
+ (r == cmd.resource.name && a == action && yield(p))
28
+ end
25
29
  cmd.run(arguments)
26
30
  end
27
31
  end
@@ -34,7 +38,20 @@ module CommandTestHelper
34
38
 
35
39
  def it_should_accept(message, arguments=[])
36
40
  it "should accept " + message.to_s do
37
- cmd.run(arguments).must_equal HammerCLI::EX_OK
41
+ out, err = capture_io do
42
+ cmd.run(arguments).must_equal HammerCLI::EX_OK
43
+ end
44
+ end
45
+ end
46
+
47
+ def it_should_output(message, adapter=:base)
48
+ it "should output '" + message.to_s + "'" do
49
+ arguments ||= respond_to?(:with_params) ? with_params : []
50
+ cmd.stubs(:context).returns(ctx.update(:adapter => adapter))
51
+ out, err = capture_io do
52
+ cmd.run(arguments)
53
+ end
54
+ out.must_include message
38
55
  end
39
56
  end
40
57
 
@@ -62,7 +79,6 @@ module CommandTestHelper
62
79
  out, err = capture_io do
63
80
  cmd.run(arguments)
64
81
  end
65
-
66
82
  out.split(/\n/).length.must_equal count+1 # plus 1 for line with column headers
67
83
  end
68
84
  end
@@ -7,13 +7,13 @@ module ResourceDisabled
7
7
  context "resource disabled" do
8
8
 
9
9
  it "should return error" do
10
- cmd.class.resource ApipieDisabledResourceMock.new(cmd.class.resource.resource_class)
10
+ cmd.class.resource.stubs(:call).raises(RestClient::ResourceNotFound)
11
11
  arguments = respond_to?(:with_params) ? with_params : []
12
12
  cmd.run(arguments).must_equal HammerCLI::EX_UNAVAILABLE
13
13
  end
14
14
 
15
15
  it "should print error message" do
16
- cmd.class.resource ApipieDisabledResourceMock.new(cmd.class.resource.resource_class)
16
+ cmd.class.resource.stubs(:call).raises(RestClient::ResourceNotFound)
17
17
  cmd.stubs(:context).returns(ctx.update(:adapter => :test))
18
18
 
19
19
  arguments = respond_to?(:with_params) ? with_params : []
@@ -7,7 +7,6 @@ describe HammerCLIForeman::Host do
7
7
  extend CommandTestHelper
8
8
 
9
9
  before :each do
10
- cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
10
  cmd.stubs(:name_to_id).returns(1)
12
11
  end
13
12
 
@@ -21,7 +20,7 @@ describe HammerCLIForeman::Host do
21
20
  end
22
21
 
23
22
  context "output" do
24
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
23
+ let(:expected_record_count) { cmd.resource.call(:index).length }
25
24
 
26
25
  it_should_print_n_records
27
26
  it_should_print_columns ["Id", "Name", "Operating System Id", "Host Group Id", "IP", "MAC"]
@@ -56,6 +55,7 @@ describe HammerCLIForeman::Host do
56
55
  it_should_print_columns ["Created at", "Updated at", "Installed at", "Last report"]
57
56
  it_should_print_columns ["Puppet CA Proxy Id", "Medium Id", "Model Id", "Owner Id", "Subnet Id", "Domain Id"]
58
57
  it_should_print_columns ["Puppet Proxy Id", "Owner Type", "Partition Table Id", "Architecture Id", "Image Id", "Compute Resource Id"]
58
+ it_should_print_columns ["BMC Network Interfaces", "Managed Network Interfaces"]
59
59
  it_should_print_columns ["Comment"]
60
60
  end
61
61
  end
@@ -67,9 +67,7 @@ describe HammerCLIForeman::Host do
67
67
  let(:cmd) { HammerCLIForeman::Host::StatusCommand.new("", ctx) }
68
68
 
69
69
  before :each do
70
- resource_mock = ApipieResourceMock.new(cmd.class.resource.resource_class)
71
- resource_mock.stub_method(:power, {'power' => 'running'})
72
- cmd.class.resource resource_mock
70
+ ResourceMocks.mock_action_call(:hosts, :power, {'power' => 'running'} )
73
71
  end
74
72
 
75
73
  context "parameters" do
@@ -196,11 +194,16 @@ describe HammerCLIForeman::Host do
196
194
 
197
195
  let(:cmd) { HammerCLIForeman::Host::CreateCommand.new("", ctx) }
198
196
 
197
+ before :each do
198
+ HammerCLIForeman::CommonHostUpdateOptions.stubs(:ask_password).returns("password")
199
+ end
200
+
199
201
  context "parameters" do
200
202
  it_should_accept "name, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
201
203
  ["--name=host", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
202
204
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
203
- "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppetclass-ids']
205
+ "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppetclass-ids',
206
+ "--root-password=pwd", "--ask-root-password=true", "--provision-method=build"]
204
207
  it_should_fail_with "name or id missing",
205
208
  ["--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1"]
206
209
  it_should_fail_with "environment_id missing",
@@ -216,10 +219,12 @@ describe HammerCLIForeman::Host do
216
219
 
217
220
  with_params ["--name=host", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
218
221
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
219
- "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppetclass-ids'] do
222
+ "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1', '--puppetclass-ids',
223
+ "--root-password=pwd", "--ask-root-password=true", "--provision-method=build"] do
220
224
  it_should_call_action_and_test_params(:create) { |par| par["host"]["managed"] == true }
221
225
  it_should_call_action_and_test_params(:create) { |par| par["host"]["build"] == true }
222
226
  it_should_call_action_and_test_params(:create) { |par| par["host"]["enabled"] == true }
227
+ it_should_call_action_and_test_params(:create) { |par| par["host"]["provision_method"] == "build" }
223
228
  end
224
229
  end
225
230
  end
@@ -228,12 +233,17 @@ describe HammerCLIForeman::Host do
228
233
 
229
234
  let(:cmd) { HammerCLIForeman::Host::UpdateCommand.new("", ctx) }
230
235
 
236
+ before :each do
237
+ HammerCLIForeman::CommonHostUpdateOptions.stubs(:ask_password).returns("password")
238
+ end
239
+
231
240
  context "parameters" do
232
241
  it_should_accept "name", ["--name=host", "--new-name=host2"]
233
242
  it_should_accept "id and more", ["--id=1", "--new-name=host2", "--environment-id=1", "--architecture-id=1",
234
243
  "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1",
235
244
  "--ip=1.2.3.4", "--mac=11:22:33:44:55:66", "--medium-id=1", "--partition-table-id=1", "--subnet-id=1",
236
- "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1']
245
+ "--sp-subnet-id=1", "--model-id=1", "--hostgroup-id=1", "--owner-id=1", '--puppet-ca-proxy-id=1',
246
+ "--root-password=pwd", "--ask-root-password=true", "--provision-method=build"]
237
247
  it_should_fail_with "no params", []
238
248
  it_should_fail_with "name or id missing", ["--new-name=host2"]
239
249
 
@@ -250,6 +260,10 @@ describe HammerCLIForeman::Host do
250
260
  with_params ["--id=1", "--enabled=false"] do
251
261
  it_should_call_action_and_test_params(:update) { |par| par["host"]["enabled"] == false }
252
262
  end
263
+
264
+ with_params ["--id=1","--provision-method=build"] do
265
+ it_should_call_action_and_test_params(:update) { |par| par["host"]["provision_method"] == "build" }
266
+ end
253
267
  end
254
268
 
255
269
  end
@@ -258,9 +272,7 @@ describe HammerCLIForeman::Host do
258
272
  context "SetParameterCommand" do
259
273
 
260
274
  before :each do
261
- resource_mock = ApipieResourceMock.new(cmd.class.resource.resource_class)
262
- resource_mock.stub_method(:index, [])
263
- cmd.class.resource resource_mock
275
+ ResourceMocks.parameters_index
264
276
  end
265
277
 
266
278
  let(:cmd) { HammerCLIForeman::Host::SetParameterCommand.new("", ctx) }
@@ -320,7 +332,7 @@ describe HammerCLIForeman::Host do
320
332
  context "SCParamsCommand" do
321
333
 
322
334
  before :each do
323
- cmd.class.resource ResourceMocks.smart_class_parameter
335
+ ResourceMocks.smart_class_parameters_index
324
336
  end
325
337
 
326
338
  let(:cmd) { HammerCLIForeman::Host::SCParamsCommand.new("", ctx) }
@@ -7,7 +7,6 @@ describe HammerCLIForeman::Hostgroup do
7
7
  extend CommandTestHelper
8
8
 
9
9
  before :each do
10
- cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
10
  cmd.stubs(:name_to_id).returns(1)
12
11
  end
13
12
 
@@ -21,11 +20,13 @@ describe HammerCLIForeman::Hostgroup do
21
20
  end
22
21
 
23
22
  context "output" do
24
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
23
+ let(:expected_record_count) { cmd.resource.call(:index).length }
25
24
 
26
25
  it_should_print_n_records
27
26
  it_should_print_columns ["Id", "Name", "Label", "Operating System Id", "Subnet Id"]
28
27
  it_should_print_columns ["Domain Id", "Environment Id", "Puppetclass Ids", "Ancestry"]
28
+ it_should_print_columns ["Architecture Id", "Partition Table Id", "Medium Id"]
29
+ it_should_print_columns ["Puppet CA Proxy Id", "Puppet Master Proxy Id"]
29
30
  end
30
31
 
31
32
  end
@@ -72,7 +73,7 @@ describe HammerCLIForeman::Hostgroup do
72
73
  context "parameters" do
73
74
  it_should_accept "name, parent_id, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
74
75
  ["--name=hostgroup", "--parent-id=1", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1",
75
- "--operatingsystem-id=1", "--medium-id=1", "--ptable-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1']
76
+ "--operatingsystem-id=1", "--medium-id=1", "--ptable-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1', '--puppetclass-ids=1,2']
76
77
  it_should_fail_with "name or id missing",
77
78
  ["--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1", "--operatingsystem-id=1"]
78
79
  end
@@ -85,7 +86,7 @@ describe HammerCLIForeman::Hostgroup do
85
86
  context "parameters" do
86
87
  it_should_accept "name, parent_id, environment_id, architecture_id, domain_id, puppet_proxy_id, operatingsystem_id and more",
87
88
  ["--id=1 --name=hostgroup2", "--parent-id=1", "--environment-id=1", "--architecture-id=1", "--domain-id=1", "--puppet-proxy-id=1",
88
- "--operatingsystem-id=1", "--medium-id=1", "--ptable-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1']
89
+ "--operatingsystem-id=1", "--medium-id=1", "--ptable-id=1", "--subnet-id=1", '--puppet-ca-proxy-id=1', '--puppetclass-ids=1,2']
89
90
  it_should_fail_with "no params", []
90
91
  it_should_fail_with "id missing", ["--name=host2"]
91
92
  end
@@ -96,9 +97,7 @@ describe HammerCLIForeman::Hostgroup do
96
97
  context "SetParameterCommand" do
97
98
 
98
99
  before :each do
99
- resource_mock = ApipieResourceMock.new(cmd.class.resource.resource_class)
100
- resource_mock.stub_method(:index, [])
101
- cmd.class.resource resource_mock
100
+ ResourceMocks.parameters_index
102
101
  end
103
102
 
104
103
  let(:cmd) { HammerCLIForeman::Hostgroup::SetParameterCommand.new("", ctx) }
@@ -129,7 +128,7 @@ describe HammerCLIForeman::Hostgroup do
129
128
  context "SCParamsCommand" do
130
129
 
131
130
  before :each do
132
- cmd.class.resource ResourceMocks.smart_class_parameter
131
+ ResourceMocks.smart_class_parameters_index
133
132
  end
134
133
 
135
134
  let(:cmd) { HammerCLIForeman::Hostgroup::SCParamsCommand.new("", ctx) }
@@ -10,7 +10,6 @@ describe HammerCLIForeman::Image do
10
10
  extend CommandTestHelper
11
11
 
12
12
  before :each do
13
- cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
14
13
  cmd.stubs(:name_to_id).returns(1)
15
14
  end
16
15
 
@@ -21,11 +20,11 @@ describe HammerCLIForeman::Image do
21
20
  context "parameters" do
22
21
  it_should_accept "compute resource name", ["--compute-resource=cr"]
23
22
  it_should_accept "compute resource id", ["--compute-resource-id=1"]
24
- # it_should_accept_search_params
23
+ #it_should_accept_search_params
25
24
  end
26
25
 
27
26
  context "output" do
28
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
27
+ let(:expected_record_count) { cmd.resource.call(:index, :compute_resource_id=>1).length }
29
28
 
30
29
  with_params ["--compute-resource-id=1"] do
31
30
  it_should_print_n_records
@@ -49,7 +48,7 @@ describe HammerCLIForeman::Image do
49
48
  end
50
49
 
51
50
  context "output" do
52
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
51
+ let(:expected_record_count) { cmd.resource.call(:index).length }
53
52
 
54
53
  with_params ["--compute-resource-id=1", "--id=1"] do
55
54
  it_should_print_n_records 1
@@ -69,11 +68,11 @@ describe HammerCLIForeman::Image do
69
68
  let(:cmd) { HammerCLIForeman::Image::AvailableImagesCommand.new("", ctx) }
70
69
 
71
70
  before :each do
72
- resource_mock = ApipieResourceMock.new(cmd.class.resource.resource_class)
73
- resource_mock.stub_method(:available_images, [])
74
- cmd.class.resource resource_mock
71
+
72
+ ResourceMocks.compute_resources_available_images
75
73
  end
76
74
 
75
+
77
76
  context "parameters" do
78
77
  it_should_accept "compute resource name", ["--compute-resource=cr"]
79
78
  it_should_accept "compute resource id", ["--compute-resource-id=1"]
@@ -7,10 +7,6 @@ describe HammerCLIForeman::Location do
7
7
  extend ResourceDisabled
8
8
 
9
9
  before :each do
10
- resource_mock = ApipieResourceMock.new(cmd.class.resource.resource_class)
11
- resource_mock.stub_method(:index, [])
12
- resource_mock.stub_method(:show, {})
13
- cmd.class.resource resource_mock
14
10
  cmd.stubs(:name_to_id).returns(1)
15
11
  end
16
12
 
@@ -18,13 +14,17 @@ describe HammerCLIForeman::Location do
18
14
 
19
15
  let(:cmd) { HammerCLIForeman::Location::ListCommand.new("", ctx) }
20
16
 
17
+ before :each do
18
+ ResourceMocks.locations_index
19
+ end
20
+
21
21
  context "parameters" do
22
22
  it_should_accept "no arguments"
23
23
  it_should_accept_search_params
24
24
  end
25
25
 
26
26
  context "output" do
27
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
27
+ let(:expected_record_count) { cmd.resource.call(:index).length }
28
28
 
29
29
  it_should_print_n_records
30
30
  it_should_print_column "Name"
@@ -39,6 +39,10 @@ describe HammerCLIForeman::Location do
39
39
 
40
40
  let(:cmd) { HammerCLIForeman::Location::InfoCommand.new("", ctx) }
41
41
 
42
+ before :each do
43
+ ResourceMocks.locations_show
44
+ end
45
+
42
46
  context "parameters" do
43
47
  it_should_accept "id", ["--id=1"]
44
48
  it_should_accept "name", ["--name=arch"]
@@ -1,13 +1,11 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper')
2
2
  require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
3
3
 
4
-
5
4
  describe HammerCLIForeman::Medium do
6
5
 
7
6
  extend CommandTestHelper
8
7
 
9
8
  before :each do
10
- cmd.class.resource ApipieResourceMock.new(cmd.class.resource.resource_class)
11
9
  cmd.stubs(:name_to_id).returns(1)
12
10
  end
13
11
 
@@ -21,7 +19,7 @@ describe HammerCLIForeman::Medium do
21
19
  end
22
20
 
23
21
  context "output" do
24
- let(:expected_record_count) { cmd.resource.call(:index)[0].length }
22
+ let(:expected_record_count) { cmd.resource.call(:index).length }
25
23
 
26
24
  it_should_print_n_records
27
25
  it_should_print_column "Name"
@@ -31,7 +29,6 @@ describe HammerCLIForeman::Medium do
31
29
 
32
30
  end
33
31
 
34
-
35
32
  context "InfoCommand" do
36
33
 
37
34
  let(:cmd) { HammerCLIForeman::Medium::InfoCommand.new("", ctx) }
@@ -54,10 +51,8 @@ describe HammerCLIForeman::Medium do
54
51
  it_should_print_column "Updated at"
55
52
  end
56
53
  end
57
-
58
54
  end
59
55
 
60
-
61
56
  context "CreateCommand" do
62
57
 
63
58
  let(:cmd) { HammerCLIForeman::Medium::CreateCommand.new("", ctx) }
@@ -73,7 +68,6 @@ describe HammerCLIForeman::Medium do
73
68
  end
74
69
  end
75
70
 
76
-
77
71
  context "DeleteCommand" do
78
72
 
79
73
  let(:cmd) { HammerCLIForeman::Medium::DeleteCommand.new("", ctx) }
@@ -83,10 +77,8 @@ describe HammerCLIForeman::Medium do
83
77
  it_should_accept "id", ["--id=1"]
84
78
  it_should_fail_with "name or id missing", []
85
79
  end
86
-
87
80
  end
88
81
 
89
-
90
82
  context "UpdateCommand" do
91
83
 
92
84
  let(:cmd) { HammerCLIForeman::Medium::UpdateCommand.new("", ctx) }