hammer_cli_katello 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b724181082827487def5bd163bd3ede79f92d898
4
- data.tar.gz: c479307f8e19564413bb8e0b29da2582e98b4625
3
+ metadata.gz: 34a1348383dad332efc75464f45b02aaef671e79
4
+ data.tar.gz: 7f0d409d51d8f89a6dd715aac1f5ac26f808ca46
5
5
  SHA512:
6
- metadata.gz: 6ff728a57e711d064752fc75f721fc283634f4cb0cc50df4b80813e9d01b11099c6654ab3b9c440610511023c49892c6fb1dbfff04e9dbf41bb318ece1978efa
7
- data.tar.gz: 99dc2f0ba6c14a6e1cf1388d6b4c9f7712b2db6089f3295e24bc196efa7d60657e276a62ace84d15b5f2630d6a3205d30a94dacf83d2d2e75d5cce45336086b8
6
+ metadata.gz: 73aa44488ec1e56a04395f9daf2eef057b330eced91641b39f1ede196953fb46bcc2d96a9d35670c3eb9aefdeae076098049631cc924bf1f7a82c39378fd46e0
7
+ data.tar.gz: 48517150eb035d7c60752bc93f48bd8d4c62778a463ae73c11b4706b0b6ff6f2e144a6ffa9c9fe872a09a444eefe074e5ea618d0971115086c5ba7e4040bdb79
@@ -53,22 +53,7 @@ module HammerCLIKatello
53
53
  success_message _("Puppet module removed from content view")
54
54
  failure_message _("Couldn't remove puppet module from the content view")
55
55
 
56
- def resolve_puppet_module_id_from_uuid(options)
57
- uuid = options.delete HammerCLI.option_accessor_name("id")
58
- options[HammerCLI.option_accessor_name("uuid")] = uuid
59
- resolver.content_view_puppet_module_id(options)
60
- end
61
-
62
- def all_options
63
- if super['option_id']
64
- super.merge(HammerCLI.option_accessor_name("id") =>
65
- resolve_puppet_module_id_from_uuid(super))
66
- else
67
- super
68
- end
69
- end
70
-
71
- build_options :without => :uuid
56
+ build_options
72
57
  end
73
58
 
74
59
  autoload_subcommands
@@ -44,7 +44,12 @@ module HammerCLIKatello
44
44
  def execute
45
45
  d = send_request
46
46
  print_data d
47
- d['status'] != _("FAIL") ? HammerCLI::EX_OK : 1
47
+ service_statuses = d['services'].values.map { |v| v['status'] }
48
+ if d['status'] == _("FAIL") || service_statuses.include?(_("FAIL"))
49
+ 1
50
+ else
51
+ HammerCLI::EX_OK
52
+ end
48
53
  end
49
54
 
50
55
  def send_request
@@ -1,5 +1,5 @@
1
1
  module HammerCLIKatello
2
2
  def self.version
3
- @version ||= Gem::Version.new('0.10.0')
3
+ @version ||= Gem::Version.new('0.10.1')
4
4
  end
5
5
  end
@@ -0,0 +1,13 @@
1
+ require_relative '../search_helpers'
2
+
3
+ module CapsuleHelpers
4
+ include SearchHelpers
5
+
6
+ def expect_generic_capsule_search(opts = {params: {}, returns: {}})
7
+ expect_generic_search(:smart_proxies, opts)
8
+ end
9
+
10
+ def expect_capsule_info(params = {})
11
+ api_expects(:smart_proxies, :show).with_params(params)
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../../test_helper'
2
+ require_relative 'capsule_content_helpers'
3
+ require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
4
+ require_relative '../../organization/organization_helpers'
5
+ require 'hammer_cli_katello/capsule'
6
+
7
+ module HammerCLIKatello
8
+ module Capsule
9
+ class Content
10
+ describe Content::AddLifecycleEnvironmentCommand do
11
+ include CapsuleContentHelpers
12
+ include LifecycleEnvironmentHelpers
13
+ include OrganizationHelpers
14
+
15
+ it 'allows minimal options' do
16
+ expect_lifecycle_environment_add('id' => '1', 'environment_id' => 2)
17
+
18
+ run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment-id 2))
19
+ end
20
+
21
+ it 'resolves environment ID from name' do
22
+ expect_lifecycle_environment_search('3', 'env2', 2)
23
+ expect_lifecycle_environment_add('id' => '1', 'environment_id' => 2)
24
+
25
+ run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment env2
26
+ --organization-id 3))
27
+ end
28
+
29
+ it 'resolves organization ID from name' do
30
+ expect_organization_search('org3', 3)
31
+ expect_lifecycle_environment_search(3, 'env2', 2)
32
+ expect_lifecycle_environment_add('id' => '1', 'environment_id' => 2)
33
+
34
+ run_cmd(%w(capsule content add-lifecycle-environment --id 1 --environment env2
35
+ --organization org3))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,8 +1,24 @@
1
+ require_relative '../capsule_helpers'
2
+
1
3
  module CapsuleContentHelpers
4
+ include CapsuleHelpers
5
+
2
6
  def expect_capsule_search(name, id)
3
- ex = api_expects(:smart_proxies, :index, 'Find the proxy') do |par|
4
- par[:search] == "name = \"#{name}\""
5
- end
6
- ex.returns(index_response([{'id' => id}]))
7
+ expect_generic_capsule_search(params: {search: "name = \"#{name}\""}, returns: {'id' => id})
8
+ end
9
+
10
+ def expect_lifecycle_environments_list(args = {params: {}, returns: []})
11
+ api_expects(:capsule_content, :lifecycle_environments)
12
+ .with_params(args[:params]).returns(index_response(args[:returns]))
13
+ end
14
+
15
+ def expect_lifecycle_environment_add(params = {})
16
+ api_expects(:capsule_content, :add_lifecycle_environment)
17
+ .with_params(params)
18
+ end
19
+
20
+ def expect_lifecycle_environment_remove(params = {})
21
+ api_expects(:capsule_content, :remove_lifecycle_environment)
22
+ .with_params(params)
7
23
  end
8
24
  end
@@ -0,0 +1,19 @@
1
+ require_relative '../../test_helper'
2
+ require_relative 'capsule_content_helpers'
3
+ require 'hammer_cli_katello/capsule'
4
+
5
+ module HammerCLIKatello
6
+ module Capsule
7
+ class Content
8
+ describe Content::ListLifecycleEnvironmentsCommand do
9
+ include CapsuleContentHelpers
10
+
11
+ it 'allows minimal options' do
12
+ expect_lifecycle_environments_list(params: {'id' => '1'}, returns: {})
13
+
14
+ run_cmd(%w(capsule content lifecycle-environments --id 1))
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../../test_helper'
2
+ require_relative 'capsule_content_helpers'
3
+ require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
4
+ require_relative '../../organization/organization_helpers'
5
+ require 'hammer_cli_katello/capsule'
6
+
7
+ module HammerCLIKatello
8
+ module Capsule
9
+ class Content
10
+ describe Content::RemoveLifecycleEnvironmentCommand do
11
+ include CapsuleContentHelpers
12
+ include LifecycleEnvironmentHelpers
13
+ include OrganizationHelpers
14
+
15
+ it 'allows minimal options' do
16
+ expect_lifecycle_environment_remove('id' => '1', 'environment_id' => 2)
17
+
18
+ run_cmd(%w(capsule content remove-lifecycle-environment --id 1 --environment-id 2))
19
+ end
20
+
21
+ it 'resolves environment ID from name' do
22
+ expect_lifecycle_environment_search('3', 'env2', 2)
23
+ expect_lifecycle_environment_remove('id' => '1', 'environment_id' => 2)
24
+
25
+ run_cmd(%w(capsule content remove-lifecycle-environment --id 1 --environment env2
26
+ --organization-id 3))
27
+ end
28
+
29
+ it 'resolves organization ID from name' do
30
+ expect_organization_search('org3', 3)
31
+ expect_lifecycle_environment_search(3, 'env2', 2)
32
+ expect_lifecycle_environment_remove('id' => '1', 'environment_id' => 2)
33
+
34
+ run_cmd(%w(capsule content remove-lifecycle-environment --id 1 --environment env2
35
+ --organization org3))
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,25 @@
1
+ require_relative '../test_helper'
2
+ require_relative 'capsule_helpers'
3
+ require 'hammer_cli_katello/capsule'
4
+
5
+ module HammerCLIKatello
6
+ describe Capsule do
7
+ describe InfoCommand do
8
+ include CapsuleHelpers
9
+
10
+ it 'allows minimal options' do
11
+ expect_capsule_info('id' => '1')
12
+
13
+ run_cmd(%w(capsule info --id 1))
14
+ end
15
+
16
+ it 'resolves capsule ID from name' do
17
+ expect_generic_capsule_search(
18
+ params: { search: "name = \"capsule1\"" }, returns: {'id' => 1})
19
+ expect_capsule_info('id' => 1)
20
+
21
+ run_cmd(%w(capsule info --name capsule1))
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ require_relative '../test_helper'
2
+ require_relative 'capsule_helpers'
3
+ require 'hammer_cli_katello/capsule'
4
+
5
+ module HammerCLIKatello
6
+ describe Capsule do
7
+ describe ListCommand do
8
+ include CapsuleHelpers
9
+
10
+ it 'allows minimal options' do
11
+ expect_generic_capsule_search
12
+
13
+ run_cmd(%w(capsule list))
14
+ end
15
+
16
+ it 'allows search' do
17
+ expect_generic_capsule_search(
18
+ params: { 'search' => 'search' }, returns: {})
19
+
20
+ run_cmd(%w(capsule list --search search))
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,8 +1,14 @@
1
+ require_relative '../search_helpers'
2
+
1
3
  module ContentViewHelpers
4
+ include SearchHelpers
5
+
2
6
  def expect_content_view_search(org_id, name, id)
3
- ex = api_expects(:content_views, :index, 'Find the content view') do |par|
4
- par['name'] == name && par['organization_id'] == org_id
5
- end
6
- ex.returns(index_response([{'id' => id}]))
7
+ expect_generic_content_view_search(params: {'name' => name, 'organization_id' => org_id},
8
+ returns: {'id' => id})
9
+ end
10
+
11
+ def expect_generic_content_view_search(args)
12
+ expect_generic_search(:content_views, args)
7
13
  end
8
14
  end
@@ -0,0 +1,54 @@
1
+ require_relative '../../test_helper'
2
+ require_relative '../../content_view/content_view_helpers'
3
+ require_relative '../../organization/organization_helpers'
4
+ require 'hammer_cli_katello/content_view_puppet_module'
5
+
6
+ module HammerCLIKatello
7
+ describe ContentViewPuppetModule::DeleteCommand do
8
+ include ContentViewHelpers
9
+ include OrganizationHelpers
10
+
11
+ def expect_module_destroy(opts)
12
+ api_expects(:content_view_puppet_modules, :destroy).with_params(opts[:params])
13
+ end
14
+
15
+ it 'allows minimal options' do
16
+ expect_module_destroy(params: {'content_view_id' => 1, 'id' => '2'})
17
+
18
+ run_cmd(%w(content-view puppet-module remove --content-view-id 1 --id 2))
19
+ end
20
+
21
+ it 'resolves puppet module ID from UUID' do
22
+ expect_generic_search(:content_view_puppet_modules,
23
+ params: {'uuid' => 'abcd1234', 'content_view_id' => 1},
24
+ returns: {'id' => 2})
25
+ expect_module_destroy(params: {'content_view_id' => 1, 'id' => 2})
26
+
27
+ run_cmd(%w(content-view puppet-module remove --content-view-id 1 --uuid abcd1234))
28
+ end
29
+
30
+ it 'resolves content view ID from name' do
31
+ expect_content_view_search('3', 'cv1', 1)
32
+ expect_module_destroy(params: {'content_view_id' => 1, 'id' => '2'})
33
+
34
+ run_cmd(%w(content-view puppet-module remove --content-view cv1 --organization-id 3 --id 2))
35
+ end
36
+
37
+ it 'resolves organization ID from name' do
38
+ expect_organization_search('org3', 3)
39
+ expect_content_view_search(3, 'cv1', 1)
40
+ expect_module_destroy(params: {'content_view_id' => 1, 'id' => '2'})
41
+
42
+ run_cmd(%w(content-view puppet-module remove --content-view cv1 --organization org3 --id 2))
43
+ end
44
+
45
+ it 'resolves organization ID from label' do
46
+ expect_organization_search('org3', 3, field: 'label')
47
+ expect_content_view_search(3, 'cv1', 1)
48
+ expect_module_destroy(params: {'content_view_id' => 1, 'id' => '2'})
49
+
50
+ run_cmd(%w(content-view puppet-module remove --content-view cv1 --organization-label
51
+ org3 --id 2))
52
+ end
53
+ end
54
+ end
@@ -1,9 +1,12 @@
1
+ require_relative '../search_helpers'
2
+
1
3
  module LifecycleEnvironmentHelpers
4
+ include SearchHelpers
5
+
2
6
  def expect_lifecycle_environment_search(org_id, name, id)
3
- ex = api_expects(:lifecycle_environments, :index, 'Find the lifecycle environment') do |par|
4
- par['name'] == name && par['organization_id'] == org_id
5
- end
6
- ex.returns(index_response([{'id' => id}]))
7
+ expect_generic_search(:lifecycle_environments,
8
+ params: {'name' => name, 'organization_id' => org_id},
9
+ returns: {'id' => id})
7
10
  end
8
11
 
9
12
  def expect_lifecycle_environments_request(org_id, results)
@@ -1,8 +1,10 @@
1
+ require_relative '../search_helpers'
2
+
1
3
  module OrganizationHelpers
4
+ include SearchHelpers
5
+
2
6
  def expect_organization_search(name_or_label, id, field: 'name')
3
- ex = api_expects(:organizations, :index, 'Find the organization') do |par|
4
- par[:search] == "#{field} = \"#{name_or_label}\""
5
- end
6
- ex.at_least_once.returns(index_response([{'id' => id}]))
7
+ expect_generic_search(:organizations, params: {search: "#{field} = \"#{name_or_label}\""},
8
+ returns: {'id' => id}).at_least_once
7
9
  end
8
10
  end
@@ -0,0 +1,6 @@
1
+ module SearchHelpers
2
+ def expect_generic_search(resource, args)
3
+ ex = api_expects(resource, :index, "Find the #{resource}").with_params(args[:params])
4
+ ex.returns(index_response([args[:returns]]))
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_katello
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Price
@@ -34,7 +34,7 @@ authors:
34
34
  autorequire:
35
35
  bindir: bin
36
36
  cert_chain: []
37
- date: 2017-03-30 00:00:00.000000000 Z
37
+ date: 2017-05-05 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: hammer_cli_foreman
@@ -311,13 +311,19 @@ files:
311
311
  - test/functional/activation_key/remove_host_collection_test.rb
312
312
  - test/functional/activation_key/subscriptions_test.rb
313
313
  - test/functional/activation_key/update_test.rb
314
+ - test/functional/capsule/capsule_helpers.rb
315
+ - test/functional/capsule/content/add_lifecycle_environment_test.rb
314
316
  - test/functional/capsule/content/cancel_synchronization_test.rb
315
317
  - test/functional/capsule/content/capsule_content_helpers.rb
316
318
  - test/functional/capsule/content/data/library_env.json
317
319
  - test/functional/capsule/content/data/sync_status.json
318
320
  - test/functional/capsule/content/data/sync_tasks.json
319
321
  - test/functional/capsule/content/info_test.rb
322
+ - test/functional/capsule/content/lifecycle_environments_test.rb
323
+ - test/functional/capsule/content/remove_lifecycle_environment_test.rb
320
324
  - test/functional/capsule/content/synchronization_status_test.rb
325
+ - test/functional/capsule/info_test.rb
326
+ - test/functional/capsule/list_test.rb
321
327
  - test/functional/content_view/add_content_view_version_test.rb
322
328
  - test/functional/content_view/add_repository_test.rb
323
329
  - test/functional/content_view/component/add_test.rb
@@ -336,6 +342,7 @@ files:
336
342
  - test/functional/content_view/list_test.rb
337
343
  - test/functional/content_view/publish_test.rb
338
344
  - test/functional/content_view/puppet_module/add_test.rb
345
+ - test/functional/content_view/puppet_module/remove_test.rb
339
346
  - test/functional/content_view/purge_test.rb
340
347
  - test/functional/content_view/remove_content_view_version_test.rb
341
348
  - test/functional/content_view/remove_test.rb
@@ -405,6 +412,7 @@ files:
405
412
  - test/functional/repository/synchronize_test.rb
406
413
  - test/functional/repository/update_test.rb
407
414
  - test/functional/repository/upload_test.rb
415
+ - test/functional/search_helpers.rb
408
416
  - test/functional/subscription/list_test.rb
409
417
  - test/functional/sync_plan/sync_plan_helpers.rb
410
418
  - test/functional/test_helper.rb
@@ -451,13 +459,19 @@ test_files:
451
459
  - test/functional/activation_key/remove_host_collection_test.rb
452
460
  - test/functional/activation_key/subscriptions_test.rb
453
461
  - test/functional/activation_key/update_test.rb
462
+ - test/functional/capsule/capsule_helpers.rb
463
+ - test/functional/capsule/content/add_lifecycle_environment_test.rb
454
464
  - test/functional/capsule/content/cancel_synchronization_test.rb
455
465
  - test/functional/capsule/content/capsule_content_helpers.rb
456
466
  - test/functional/capsule/content/data/library_env.json
457
467
  - test/functional/capsule/content/data/sync_status.json
458
468
  - test/functional/capsule/content/data/sync_tasks.json
459
469
  - test/functional/capsule/content/info_test.rb
470
+ - test/functional/capsule/content/lifecycle_environments_test.rb
471
+ - test/functional/capsule/content/remove_lifecycle_environment_test.rb
460
472
  - test/functional/capsule/content/synchronization_status_test.rb
473
+ - test/functional/capsule/info_test.rb
474
+ - test/functional/capsule/list_test.rb
461
475
  - test/functional/content_view/add_content_view_version_test.rb
462
476
  - test/functional/content_view/add_repository_test.rb
463
477
  - test/functional/content_view/component/add_test.rb
@@ -476,6 +490,7 @@ test_files:
476
490
  - test/functional/content_view/list_test.rb
477
491
  - test/functional/content_view/publish_test.rb
478
492
  - test/functional/content_view/puppet_module/add_test.rb
493
+ - test/functional/content_view/puppet_module/remove_test.rb
479
494
  - test/functional/content_view/purge_test.rb
480
495
  - test/functional/content_view/remove_content_view_version_test.rb
481
496
  - test/functional/content_view/remove_test.rb
@@ -545,6 +560,7 @@ test_files:
545
560
  - test/functional/repository/synchronize_test.rb
546
561
  - test/functional/repository/update_test.rb
547
562
  - test/functional/repository/upload_test.rb
563
+ - test/functional/search_helpers.rb
548
564
  - test/functional/subscription/list_test.rb
549
565
  - test/functional/sync_plan/sync_plan_helpers.rb
550
566
  - test/functional/test_helper.rb