hammer_cli_katello 1.0.1 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/content_import.rb +16 -1
  3. data/lib/hammer_cli_katello/content_view_version.rb +0 -273
  4. data/lib/hammer_cli_katello/docker.rb +13 -0
  5. data/lib/hammer_cli_katello/docker_manifest.rb +53 -0
  6. data/lib/hammer_cli_katello/docker_tag.rb +40 -0
  7. data/lib/hammer_cli_katello/foreman_search_options_creators.rb +12 -0
  8. data/lib/hammer_cli_katello/host_collection_erratum.rb +10 -0
  9. data/lib/hammer_cli_katello/host_collection_package.rb +30 -0
  10. data/lib/hammer_cli_katello/host_collection_package_group.rb +30 -0
  11. data/lib/hammer_cli_katello/host_errata.rb +8 -0
  12. data/lib/hammer_cli_katello/host_package.rb +32 -0
  13. data/lib/hammer_cli_katello/host_package_group.rb +16 -0
  14. data/lib/hammer_cli_katello/id_resolver.rb +3 -1
  15. data/lib/hammer_cli_katello/organization.rb +10 -0
  16. data/lib/hammer_cli_katello/ping.rb +13 -5
  17. data/lib/hammer_cli_katello/repository.rb +21 -0
  18. data/lib/hammer_cli_katello/simple_content_access.rb +2 -0
  19. data/lib/hammer_cli_katello/version.rb +1 -1
  20. data/lib/hammer_cli_katello.rb +5 -1
  21. data/locale/hammer-cli-katello.pot +0 -25
  22. metadata +7 -419
  23. data/lib/hammer_cli_katello/cv_import_export_helper.rb +0 -187
  24. data/test/data/2.5/foreman_api.json +0 -1
  25. data/test/data/3.0/foreman_api.json +0 -1
  26. data/test/data/3.10/foreman_api.json +0 -1
  27. data/test/data/3.11/foreman_api.json +0 -1
  28. data/test/data/3.12/foreman_api.json +0 -1
  29. data/test/data/3.13/foreman_api.json +0 -1
  30. data/test/data/3.14/foreman_api.json +0 -1
  31. data/test/data/3.15/foreman_api.json +0 -1
  32. data/test/data/3.16/foreman_api.json +0 -1
  33. data/test/data/3.17/foreman_api.json +0 -1
  34. data/test/data/3.18/foreman_api.json +0 -1
  35. data/test/data/3.19/foreman_api.json +0 -1
  36. data/test/data/3.2/foreman_api.json +0 -1
  37. data/test/data/3.4/foreman_api.json +0 -1
  38. data/test/data/3.5/foreman_api.json +0 -1
  39. data/test/data/3.6/foreman_api.json +0 -1
  40. data/test/data/3.7/foreman_api.json +0 -1
  41. data/test/data/3.8/foreman_api.json +0 -1
  42. data/test/data/3.9/foreman_api.json +0 -1
  43. data/test/data/4.0/foreman_api.json +0 -1
  44. data/test/data/Readme.md +0 -5
  45. data/test/functional/activation_key/add_host_collection_test.rb +0 -62
  46. data/test/functional/activation_key/content_override_test.rb +0 -92
  47. data/test/functional/activation_key/create_test.rb +0 -33
  48. data/test/functional/activation_key/data/activation_key.json +0 -17
  49. data/test/functional/activation_key/info_test.rb +0 -29
  50. data/test/functional/activation_key/list_test.rb +0 -68
  51. data/test/functional/activation_key/product_content_test.rb +0 -23
  52. data/test/functional/activation_key/remove_host_collection_test.rb +0 -62
  53. data/test/functional/activation_key/subscriptions_test.rb +0 -71
  54. data/test/functional/activation_key/update_test.rb +0 -26
  55. data/test/functional/apipie_helper_test.rb +0 -31
  56. data/test/functional/capsule/capsule_helpers.rb +0 -13
  57. data/test/functional/capsule/content/add_lifecycle_environment_test.rb +0 -40
  58. data/test/functional/capsule/content/cancel_synchronization_test.rb +0 -42
  59. data/test/functional/capsule/content/capsule_content_helpers.rb +0 -24
  60. data/test/functional/capsule/content/data/library_env.json +0 -47
  61. data/test/functional/capsule/content/data/sync_status.json +0 -6
  62. data/test/functional/capsule/content/data/sync_tasks.json +0 -62
  63. data/test/functional/capsule/content/info_test.rb +0 -61
  64. data/test/functional/capsule/content/lifecycle_environments_test.rb +0 -19
  65. data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +0 -40
  66. data/test/functional/capsule/content/synchronization_status_test.rb +0 -107
  67. data/test/functional/capsule/info_test.rb +0 -25
  68. data/test/functional/capsule/list_test.rb +0 -24
  69. data/test/functional/content_credentials/create_test.rb +0 -32
  70. data/test/functional/content_credentials/data/test_cert.json +0 -43
  71. data/test/functional/content_credentials/info_test.rb +0 -50
  72. data/test/functional/content_credentials/list_test.rb +0 -66
  73. data/test/functional/content_export/complete/library_test.rb +0 -155
  74. data/test/functional/content_export/complete/version_test.rb +0 -217
  75. data/test/functional/content_export/content_export_helpers.rb +0 -26
  76. data/test/functional/content_export/generate_metadata_test.rb +0 -64
  77. data/test/functional/content_export/incremental/library_test.rb +0 -172
  78. data/test/functional/content_export/incremental/version_test.rb +0 -268
  79. data/test/functional/content_export/list_test.rb +0 -64
  80. data/test/functional/content_import/library_test.rb +0 -85
  81. data/test/functional/content_import/metadata.json +0 -1
  82. data/test/functional/content_import/version_test.rb +0 -85
  83. data/test/functional/content_view/add_content_view_version_test.rb +0 -88
  84. data/test/functional/content_view/add_repository_test.rb +0 -21
  85. data/test/functional/content_view/component/add_test.rb +0 -177
  86. data/test/functional/content_view/component/list_test.rb +0 -55
  87. data/test/functional/content_view/component/remove_test.rb +0 -107
  88. data/test/functional/content_view/component/update_test.rb +0 -134
  89. data/test/functional/content_view/content_view_helpers.rb +0 -20
  90. data/test/functional/content_view/copy_test.rb +0 -53
  91. data/test/functional/content_view/create_test.rb +0 -34
  92. data/test/functional/content_view/delete_test.rb +0 -62
  93. data/test/functional/content_view/filter/create_test.rb +0 -57
  94. data/test/functional/content_view/filter/delete_test.rb +0 -90
  95. data/test/functional/content_view/filter/info_test.rb +0 -89
  96. data/test/functional/content_view/filter/list_test.rb +0 -98
  97. data/test/functional/content_view/filter/update_test.rb +0 -91
  98. data/test/functional/content_view/list_test.rb +0 -68
  99. data/test/functional/content_view/publish_test.rb +0 -24
  100. data/test/functional/content_view/purge_test.rb +0 -97
  101. data/test/functional/content_view/remove_content_view_version_test.rb +0 -88
  102. data/test/functional/content_view/remove_test.rb +0 -79
  103. data/test/functional/content_view/update_test.rb +0 -53
  104. data/test/functional/content_view/version/cv_import_export_helper_test.rb +0 -20
  105. data/test/functional/content_view/version/default_export_test.rb +0 -40
  106. data/test/functional/content_view/version/export_test.rb +0 -148
  107. data/test/functional/content_view/version/import_test.rb +0 -346
  108. data/test/functional/content_view/version/incremental_update_test.rb +0 -108
  109. data/test/functional/content_view/version/list_test.rb +0 -44
  110. data/test/functional/content_view/version/promote_test.rb +0 -34
  111. data/test/functional/content_view/version/republish_repositories_test.rb +0 -34
  112. data/test/functional/content_view/version/update_test.rb +0 -48
  113. data/test/functional/erratum/erratum_helpers.rb +0 -91
  114. data/test/functional/erratum/info_test.rb +0 -29
  115. data/test/functional/erratum/list_test.rb +0 -108
  116. data/test/functional/file/file_helpers.rb +0 -13
  117. data/test/functional/file/info_test.rb +0 -162
  118. data/test/functional/file/list_test.rb +0 -112
  119. data/test/functional/filter_rule/create_test.rb +0 -99
  120. data/test/functional/filter_rule/delete_test.rb +0 -104
  121. data/test/functional/filter_rule/filter_rule_helpers.rb +0 -12
  122. data/test/functional/filter_rule/info_test.rb +0 -104
  123. data/test/functional/filter_rule/list_test.rb +0 -91
  124. data/test/functional/filter_rule/update_test.rb +0 -104
  125. data/test/functional/host/errata/apply_test.rb +0 -45
  126. data/test/functional/host/errata/info_test.rb +0 -27
  127. data/test/functional/host/errata/list_test.rb +0 -49
  128. data/test/functional/host/errata/recalculate_test.rb +0 -40
  129. data/test/functional/host/extensions/create_test.rb +0 -95
  130. data/test/functional/host/extensions/data/host.json +0 -320
  131. data/test/functional/host/extensions/data/host_list.json +0 -117
  132. data/test/functional/host/extensions/info_test.rb +0 -35
  133. data/test/functional/host/extensions/list_test.rb +0 -21
  134. data/test/functional/host/extensions/update_test.rb +0 -70
  135. data/test/functional/host/host_helpers.rb +0 -8
  136. data/test/functional/host/subscription/attach_test.rb +0 -54
  137. data/test/functional/host/subscription/auto_attach_test.rb +0 -35
  138. data/test/functional/host/subscription/content_override_test.rb +0 -96
  139. data/test/functional/host/subscription/product_content_test.rb +0 -27
  140. data/test/functional/host/subscription/register_test.rb +0 -53
  141. data/test/functional/host/subscription/remove_test.rb +0 -52
  142. data/test/functional/host/subscription/unregister_test.rb +0 -37
  143. data/test/functional/host/traces/list_test.rb +0 -37
  144. data/test/functional/host/traces/resolve_test.rb +0 -31
  145. data/test/functional/host_collection/add_host_test.rb +0 -90
  146. data/test/functional/host_collection/content_api_expectations.rb +0 -35
  147. data/test/functional/host_collection/content_install_test.rb +0 -62
  148. data/test/functional/host_collection/content_remove_test.rb +0 -37
  149. data/test/functional/host_collection/content_update_test.rb +0 -37
  150. data/test/functional/host_collection/copy_test.rb +0 -64
  151. data/test/functional/host_collection/create_test.rb +0 -43
  152. data/test/functional/host_collection/delete_test.rb +0 -57
  153. data/test/functional/host_collection/hosts_test.rb +0 -39
  154. data/test/functional/host_collection/info_test.rb +0 -57
  155. data/test/functional/host_collection/list_test.rb +0 -63
  156. data/test/functional/host_collection/remove_host_test.rb +0 -90
  157. data/test/functional/host_collection/update_test.rb +0 -57
  158. data/test/functional/hostgroup/create_test.rb +0 -112
  159. data/test/functional/hostgroup/data/hostgroup.json +0 -50
  160. data/test/functional/hostgroup/info_test.rb +0 -33
  161. data/test/functional/hostgroup/update_test.rb +0 -120
  162. data/test/functional/lifecycle_environment/create_test.rb +0 -14
  163. data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -18
  164. data/test/functional/lifecycle_environment/list_test.rb +0 -38
  165. data/test/functional/lifecycle_environment/update_test.rb +0 -14
  166. data/test/functional/local_helper_test.rb +0 -30
  167. data/test/functional/module_stream/info_test.rb +0 -58
  168. data/test/functional/module_stream/list_test.rb +0 -53
  169. data/test/functional/organization/delete_test.rb +0 -26
  170. data/test/functional/organization/organization_helpers.rb +0 -10
  171. data/test/functional/package/list_test.rb +0 -158
  172. data/test/functional/package_group/list_test.rb +0 -38
  173. data/test/functional/ping_test.rb +0 -20
  174. data/test/functional/product/create_test.rb +0 -54
  175. data/test/functional/product/delete_test.rb +0 -41
  176. data/test/functional/product/info_test.rb +0 -33
  177. data/test/functional/product/list_test.rb +0 -58
  178. data/test/functional/product/product_helpers.rb +0 -24
  179. data/test/functional/product/remove_sync_plan_test.rb +0 -35
  180. data/test/functional/product/set_sync_plan_test.rb +0 -49
  181. data/test/functional/product/update_proxy.rb +0 -48
  182. data/test/functional/product/update_test.rb +0 -46
  183. data/test/functional/repository/create_test.rb +0 -21
  184. data/test/functional/repository/delete_test.rb +0 -95
  185. data/test/functional/repository/export_test.rb +0 -121
  186. data/test/functional/repository/info_test.rb +0 -156
  187. data/test/functional/repository/list_test.rb +0 -68
  188. data/test/functional/repository/remove_content_test.rb +0 -108
  189. data/test/functional/repository/repository_helpers.rb +0 -18
  190. data/test/functional/repository/synchronize_test.rb +0 -57
  191. data/test/functional/repository/update_test.rb +0 -149
  192. data/test/functional/repository/upload_test.rb +0 -345
  193. data/test/functional/repository_set/available_repositories_test.rb +0 -18
  194. data/test/functional/repository_set/disable_test.rb +0 -42
  195. data/test/functional/repository_set/enable_test.rb +0 -42
  196. data/test/functional/repository_set/info_test.rb +0 -17
  197. data/test/functional/repository_set/list_test.rb +0 -18
  198. data/test/functional/repository_set/repository_set_helpers.rb +0 -20
  199. data/test/functional/search_helpers.rb +0 -17
  200. data/test/functional/simple_content_access/disable_test.rb +0 -48
  201. data/test/functional/simple_content_access/enable_test.rb +0 -46
  202. data/test/functional/srpm/list_test.rb +0 -92
  203. data/test/functional/subscription/list_test.rb +0 -86
  204. data/test/functional/sync_plan/create_test.rb +0 -60
  205. data/test/functional/sync_plan/delete_test.rb +0 -46
  206. data/test/functional/sync_plan/info_test.rb +0 -37
  207. data/test/functional/sync_plan/list_test.rb +0 -31
  208. data/test/functional/sync_plan/sync_plan_helpers.rb +0 -8
  209. data/test/functional/sync_plan/update_test.rb +0 -44
  210. data/test/functional/test_helper.rb +0 -24
  211. data/test/task_helper.rb +0 -7
  212. data/test/test_helper.rb +0 -38
  213. data/test/unit/id_name_options_validator_test.rb +0 -96
  214. data/test/unit/id_resolver_test.rb +0 -58
  215. data/test/unit/messages_test.rb +0 -7
  216. data/test/unit/search_options_creators_test.rb +0 -145
@@ -1,92 +0,0 @@
1
- require_relative '../test_helper'
2
- require_relative '../repository/repository_helpers'
3
- require_relative '../product/product_helpers'
4
- require_relative '../organization/organization_helpers'
5
- require 'hammer_cli_katello/package'
6
- require 'hammer_cli_katello/srpm'
7
-
8
- module HammerCLIKatello
9
- describe PackageCommand::ListCommand do
10
- include OrganizationHelpers
11
- include RepositoryHelpers
12
- include ProductHelpers
13
-
14
- it 'allows minimal options' do
15
- api_expects(:srpms, :index)
16
-
17
- run_cmd(%w(srpm list))
18
- end
19
-
20
- describe 'repository options' do
21
- it 'may be specified by ID' do
22
- api_expects(:srpms, :index).with_params('repository_id' => 1)
23
-
24
- run_cmd(%w(srpm list --repository-id 1))
25
- end
26
-
27
- it 'require product ID when given repository name' do
28
- api_expects_no_call
29
-
30
- r = run_cmd(%w(srpm list --repository repo1))
31
- assert(r.err.include?("--product-id, --product is required"), "Invalid error message")
32
- end
33
-
34
- it 'may be specified by name and product ID' do
35
- expect_repository_search(2, 'repo1', 1)
36
-
37
- api_expects(:srpms, :index).with_params('repository_id' => 1)
38
-
39
- run_cmd(%w(srpm list --repository repo1 --product-id 2))
40
- end
41
- end
42
-
43
- describe 'organization options' do
44
- it 'may be specified by ID' do
45
- api_expects(:srpms, :index).with_params('organization_id' => 1)
46
-
47
- run_cmd(%w(srpm list --organization-id 1))
48
- end
49
-
50
- it 'may be specified by name' do
51
- expect_organization_search('org3', 1)
52
- api_expects(:srpms, :index).with_params('organization_id' => 1)
53
-
54
- run_cmd(%w(srpm list --organization org3))
55
- end
56
-
57
- it 'may be specified by label' do
58
- expect_organization_search('org3', 1, field: 'label')
59
- api_expects(:srpms, :index).with_params('organization_id' => 1)
60
-
61
- run_cmd(%w(srpm list --organization-label org3))
62
- end
63
- end
64
-
65
- describe 'content-view options' do
66
- it 'may be specified by ID' do
67
- api_expects(:content_view_versions, :index)
68
- .with_params('content_view_id' => 1, 'version' => '2.1')
69
- .returns(index_response([{'id' => 5}]))
70
- api_expects(:srpms, :index).with_params('content_view_version_id' => 5)
71
-
72
- run_cmd(%w(srpm list --content-view-id 1 --content-view-version 2.1))
73
- end
74
-
75
- it 'requires organization ID when given content view name' do
76
- api_expects_no_call
77
-
78
- r = run_cmd(%w(srpm list --content-view cv1 --content-view-version 2.1))
79
- expected_error = "--organization-id, --organization, --organization-label is required"
80
- assert(r.err.include?(expected_error), "Invalid error message")
81
- end
82
-
83
- it 'requires content view ID when given content view version number' do
84
- api_expects_no_call
85
-
86
- r = run_cmd(%w(srpm list --content-view-version cvv1))
87
- assert(r.err.include?("--content-view-id, --content-view is required"),
88
- "Invalid error message")
89
- end
90
- end
91
- end
92
- end
@@ -1,86 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/subscription'
3
-
4
- module HammerCLIKatello
5
- describe SubscriptionCommand::ListCommand do
6
- before do
7
- @cmd = %w(subscription list)
8
- end
9
-
10
- let(:org_id) { 1 }
11
-
12
- it "returns the correct subscription type" do
13
- cmd = SubscriptionCommand::ListCommand.new({})
14
- assert_equal("Physical", cmd.get_subscription_type("virt_only" => false))
15
-
16
- hostname = "boo.com"
17
- with_hostname = cmd.get_subscription_type("virt_only" => true, "host" => {"name" => hostname})
18
- assert(with_hostname.include?(hostname))
19
-
20
- assert_equal("Temporary",
21
- cmd.get_subscription_type("virt_only" => true, "unmapper_guest" => true))
22
-
23
- assert_equal("Virtual",
24
- cmd.get_subscription_type("virt_only" => true))
25
- end
26
-
27
- it "lists an organizations subscriptions" do
28
- params = ["--organization-id=#{org_id}"]
29
-
30
- ex = api_expects(:subscriptions, :index, 'Subscription list') do |par|
31
- par['organization_id'] == org_id
32
- end
33
-
34
- ex.returns(index_response([]))
35
-
36
- result = run_cmd(@cmd + params)
37
-
38
- fields = ['ID', 'UUID', 'NAME', 'TYPE', 'CONTRACT', 'ACCOUNT', 'SUPPORT',
39
- 'START DATE', 'END DATE', 'QUANTITY', 'CONSUMED']
40
- expected_result = success_result(IndexMatcher.new([fields, []]))
41
- assert_cmd(expected_result, result)
42
- end
43
-
44
- it 'allows organization name' do
45
- api_expects(:organizations, :index) { |par| par[:search] == "name = \"org1\"" }
46
- .returns(index_response([{'id' => 1}]))
47
-
48
- api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
49
-
50
- run_cmd(%w(subscription list --organization org1))
51
- end
52
-
53
- it 'allows organization label' do
54
- api_expects(:organizations, :index) { |par| par[:search] == "label = \"org1\"" }
55
- .returns(index_response([{'id' => 1}]))
56
-
57
- api_expects(:subscriptions, :index) { |par| par['organization_id'].to_i == 1 }
58
-
59
- run_cmd(%w(subscription list --organization-label org1))
60
- end
61
-
62
- it 'allows host id' do
63
- api_expects(:subscriptions, :index) { |par| par['host_id'] == 1 }
64
- run_cmd(%w(subscription list --organization-id 1 --host-id 1))
65
- end
66
-
67
- it 'allows host name' do
68
- api_expects(:hosts, :index) { |par| par[:search] == "name = \"host1\"" }
69
- .returns(index_response([{'id' => 1}]))
70
- api_expects(:subscriptions, :index) { |par| par['host_id'] == 1 }
71
- run_cmd(%w(subscription list --organization-id 1 --host host1))
72
- end
73
-
74
- it 'allows activation key id' do
75
- api_expects(:subscriptions, :index) { |par| par['activation_key_id'] == 1 }
76
- run_cmd(%w(subscription list --organization-id 1 --activation-key-id 1))
77
- end
78
-
79
- it 'allows activation key name' do
80
- api_expects(:activation_keys, :index) { |par| par['name'] == "ak1" }
81
- .returns(index_response([{'id' => 1}]))
82
- api_expects(:subscriptions, :index) { |par| par['activation_key_id'] == 1 }
83
- run_cmd(%w(subscription list --organization-id 1 --activation-key ak1))
84
- end
85
- end
86
- end
@@ -1,60 +0,0 @@
1
- require_relative '../test_helper'
2
-
3
- describe "create sync plan" do
4
- let(:org_id) { 1 }
5
- let(:name) { "sync_plan1" }
6
- let(:hourly) { "hourly" }
7
- let(:custom) { "custom cron" }
8
- let(:cron) { "10 * * * *" }
9
- let(:date) { "2018-09-08T00:00:00+00:00" }
10
-
11
- it 'with organization ID,name,interval,date and enabled' do
12
- api_expects(:sync_plans, :create, 'create a sync plan').
13
- with_params('organization_id' => org_id,
14
- 'name' => name,
15
- 'interval' => hourly,
16
- 'sync_date' => date,
17
- 'enabled' => true)
18
- command = %W(sync-plan create --organization-id #{org_id} --name #{name}
19
- --interval #{hourly} --enabled 1 --sync-date #{date})
20
- assert_equal(0, run_cmd(command).exit_code)
21
- end
22
-
23
- it 'with custom cron' do
24
- api_expects(:sync_plans, :create, 'create a sync plan').
25
- with_params('organization_id' => org_id,
26
- 'name' => name,
27
- 'interval' => custom,
28
- 'cron_expression' => cron,
29
- 'sync_date' => date,
30
- 'enabled' => true)
31
- # end
32
- command = %W(sync-plan create --organization-id #{org_id} --name #{name} --interval #{custom}
33
- --cron-expression #{cron} --enabled 1 --sync-date #{date})
34
- assert_equal(0, run_cmd(command).exit_code)
35
- end
36
-
37
- it 'fails without organization-id' do
38
- command = %w(sync-plan create --name #{name}
39
- --interval #{hourly} --enabled 1 --sync-date #{date})
40
- refute_equal(0, run_cmd(command).exit_code)
41
- end
42
-
43
- it 'fails without name' do
44
- command = %w(sync-plan create --organization-id #{org_id}
45
- --interval #{hourly} --enabled 1 --sync-date #{date})
46
- refute_equal(0, run_cmd(command).err)
47
- end
48
-
49
- it 'fails without interval' do
50
- command = %w(sync-plan create --organization-id #{org_id} --name #{name}
51
- --enabled 1 --sync-date #{date})
52
- refute_equal(0, run_cmd(command).exit_code)
53
- end
54
-
55
- it 'fails without enabled' do
56
- command = %w(sync-plan create --organization-id #{org_id} --name #{name}
57
- --interval #{hourly} --sync-date #{date})
58
- refute_equal(0, run_cmd(command).exit_code)
59
- end
60
- end
@@ -1,46 +0,0 @@
1
- require_relative '../test_helper'
2
- require_relative 'sync_plan_helpers'
3
- require_relative '../organization/organization_helpers'
4
-
5
- describe 'delete a sync plan' do
6
- include OrganizationHelpers
7
- include SyncPlanHelpers
8
-
9
- let(:org_id) { 1 }
10
- let(:id) { 1 }
11
- let(:name) { "sync_plan1" }
12
- let(:org_name) { "org1" }
13
-
14
- it 'by organization ID and sync plan id' do
15
- api_expects(:sync_plans, :destroy, 'delete a sync plan').
16
- with_params('organization_id' => org_id,
17
- 'id' => id)
18
- command = %W(sync-plan delete --organization-id #{org_id} --id #{id})
19
- assert_equal(0, run_cmd(command).exit_code)
20
- end
21
-
22
- it 'by organization ID and sync plan name' do
23
- expect_sync_plan_search(1, 'sync_plan1', 1)
24
- api_expects(:sync_plans, :destroy, 'delete a sync plan').
25
- with_params('id' => id)
26
- command = %W(sync-plan delete --organization-id #{org_id} --name #{name})
27
- assert_equal(0, run_cmd(command).exit_code)
28
- end
29
-
30
- it 'by organization name and sync plan name' do
31
- expect_organization_search('org1', 1)
32
- expect_sync_plan_search(1, 'sync_plan1', 1)
33
- api_expects(:sync_plans, :destroy, 'delete a sync plan').
34
- with_params('id' => id)
35
- command = %W(sync-plan delete --organization #{org_name} --name #{name})
36
- assert_equal(0, run_cmd(command).exit_code)
37
- end
38
-
39
- it 'by organization name and sync plan id' do
40
- expect_organization_search(org_name, org_id)
41
- api_expects(:sync_plans, :destroy, 'delete a sync plan').
42
- with_params('id' => id)
43
- command = %W(sync-plan delete --organization #{org_name} --id #{id})
44
- assert_equal(0, run_cmd(command).exit_code)
45
- end
46
- end
@@ -1,37 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/sync_plan'
3
- require_relative 'sync_plan_helpers'
4
- require_relative '../organization/organization_helpers'
5
- module HammerCLIKatello
6
- describe SyncPlan::InfoCommand do
7
- include OrganizationHelpers
8
- include SyncPlanHelpers
9
-
10
- it 'allows ID' do
11
- api_expects(:sync_plans, :show).with_params('id' => 1)
12
-
13
- run_cmd(%w(sync-plan info --id 1))
14
- end
15
-
16
- it 'allows organization id and sync plan name' do
17
- org_id = 1
18
- name = "SyncPlan1"
19
- id = 100
20
- expect_sync_plan_search(org_id, name, id)
21
- api_expects(:sync_plans, :show).with_params('id' => id)
22
- run_cmd("sync-plan info --organization-id #{org_id} --name #{name}".split)
23
- end
24
-
25
- it 'allows organization name and sync plan name' do
26
- org_id = 1
27
- org_label = "org"
28
- name = "SyncPlan1"
29
- id = 100
30
-
31
- expect_organization_search(org_label, org_id, field: 'label')
32
- expect_sync_plan_search(org_id, name, id)
33
- api_expects(:sync_plans, :show).with_params('id' => id)
34
- run_cmd("sync-plan info --organization-label #{org_label} --name #{name}".split)
35
- end
36
- end
37
- end
@@ -1,31 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/sync_plan'
3
- require_relative 'sync_plan_helpers'
4
- require_relative '../organization/organization_helpers'
5
-
6
- module HammerCLIKatello
7
- describe SyncPlan::ListCommand do
8
- include SyncPlanHelpers
9
- include OrganizationHelpers
10
-
11
- it 'allows minimal options' do
12
- expect_sync_plan_search(1, nil, nil)
13
-
14
- run_cmd(%w(sync-plan list --organization-id 1))
15
- end
16
-
17
- it 'allows org name' do
18
- expect_organization_search('org1', 1)
19
- expect_sync_plan_search(1, nil, nil)
20
-
21
- run_cmd(%w(sync-plan list --organization org1))
22
- end
23
-
24
- it 'allows org label' do
25
- expect_organization_search('org1', 1, field: 'label')
26
- expect_sync_plan_search(1, nil, nil)
27
-
28
- run_cmd(%w(sync-plan list --organization-label org1))
29
- end
30
- end
31
- end
@@ -1,8 +0,0 @@
1
- module SyncPlanHelpers
2
- def expect_sync_plan_search(org_id, name, id)
3
- ex = api_expects(:sync_plans, :index, 'find sync plan') do |par|
4
- par['name'] == name && par['organization_id'] == org_id
5
- end
6
- ex.returns(index_response([{'id' => id}]))
7
- end
8
- end
@@ -1,44 +0,0 @@
1
- require_relative '../test_helper'
2
- require_relative 'sync_plan_helpers'
3
- require_relative '../organization/organization_helpers'
4
-
5
- describe 'update a sync plan' do
6
- include OrganizationHelpers
7
- include SyncPlanHelpers
8
-
9
- let(:org_id) { 1 }
10
- let(:id) { 1 }
11
- let(:name) { "sync_plan1" }
12
- let(:org_name) { "org1" }
13
- let(:desc) { "New Description" }
14
-
15
- it 'with organization id and sync plan ID' do
16
- api_expects(:sync_plans, :update, 'update a sync plan').
17
- with_params('description' => desc,
18
- 'id' => id)
19
- command = %W(sync-plan update --organization-id #{org_id} --id #{id}
20
- --description #{desc})
21
- assert_equal(0, run_cmd(command).exit_code)
22
- end
23
-
24
- it 'with organization ID and sync plan name' do
25
- expect_sync_plan_search(org_id, name, id)
26
- api_expects(:sync_plans, :update, 'update a sync plan').
27
- with_params('description' => desc,
28
- 'id' => id)
29
- command = %W(sync-plan update --organization-id #{org_id} --name #{name}
30
- --description #{desc})
31
- assert_equal(0, run_cmd(command).exit_code)
32
- end
33
-
34
- it 'with organization name and sync plan name' do
35
- expect_organization_search(org_name, org_id)
36
- expect_sync_plan_search(org_id, name, id)
37
- api_expects(:sync_plans, :update, 'update a sync plan').
38
- with_params('description' => desc,
39
- 'id' => id)
40
- command = %W(sync-plan update --organization #{org_name} --name #{name}
41
- --description #{desc})
42
- assert_equal(0, run_cmd(command).exit_code)
43
- end
44
- end
@@ -1,24 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../test_helper')
2
-
3
- require 'hammer_cli/testing/output_matchers'
4
- require 'hammer_cli/testing/command_assertions'
5
- require 'hammer_cli/testing/data_helpers'
6
- require 'hammer_cli_foreman/testing/api_expectations'
7
-
8
- include HammerCLI::Testing::OutputMatchers
9
- include HammerCLI::Testing::CommandAssertions
10
- include HammerCLI::Testing::DataHelpers
11
- include HammerCLIForeman::Testing::APIExpectations
12
-
13
- def assert_success(command_run_result)
14
- assert command_run_result.exit_code.zero?,
15
- "Nonzero exit code (#{command_run_result.exit_code}): #{command_run_result.err}"
16
- end
17
-
18
- def assert_failure(command_run_result, msg = nil)
19
- assert !command_run_result.exit_code.zero?, "Success exit code (0) when expecting failure"
20
- if msg
21
- assert command_run_result.err[msg],
22
- "Actual:\n#{command_run_result.err}\nExpected:\n#{msg.inspect}"
23
- end
24
- end
data/test/task_helper.rb DELETED
@@ -1,7 +0,0 @@
1
- module ForemanTaskHelpers
2
- def expect_foreman_task(task_id)
3
- ex = api_expects(:foreman_tasks, :show, 'Show task')
4
- ex.returns('id' => task_id, 'state' => 'stopped', 'progress' => 1,
5
- 'humanized' => {'output' => '', 'errors' => ''})
6
- end
7
- end
data/test/test_helper.rb DELETED
@@ -1,38 +0,0 @@
1
- if RUBY_VERSION > "2.2"
2
- # Coverage - Keep these two lines at the top of this file
3
- require 'simplecov'
4
- require 'coveralls'
5
- SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter]
6
- SimpleCov.start do
7
- minimum_coverage 70
8
- maximum_coverage_drop 0.1
9
- track_files "lib/**/*.rb"
10
- add_filter '/test/'
11
- end
12
- end
13
-
14
- require File.join(File.dirname(__FILE__), './task_helper.rb')
15
- require 'minitest/autorun'
16
- require 'minitest/spec'
17
- require 'mocha/minitest'
18
- require 'hammer_cli'
19
-
20
- KATELLO_VERSION = Gem::Version.new(ENV['TEST_API_VERSION'] || '4.0')
21
-
22
- if HammerCLI.context[:api_connection]
23
- HammerCLI.context[:api_connection].create('foreman') do
24
- HammerCLI::Apipie::ApiConnection.new(
25
- :apidoc_cache_dir => 'test/data/' + KATELLO_VERSION.to_s,
26
- :apidoc_cache_name => 'foreman_api',
27
- :dry_run => true
28
- )
29
- end
30
- else
31
- HammerCLIForeman.stubs(:resource_config).returns(
32
- :apidoc_cache_dir => 'test/data/' + KATELLO_VERSION.to_s,
33
- :apidoc_cache_name => 'foreman_api',
34
- :dry_run => true
35
- )
36
- end
37
-
38
- require 'hammer_cli_katello'
@@ -1,96 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/id_name_options_validator'
3
-
4
- module HammerCLIKatello
5
- describe IdNameOptionsValidator do
6
- before(:each) do
7
- @cmd = Object.new
8
- @cmd.extend(IdNameOptionsValidator)
9
- @cmd.class.send(:define_method, :validate_options) do |*_args, &block|
10
- block.call
11
- end
12
- end
13
-
14
- describe '#validate_id_or_name_with_parent' do
15
- it 'accepts no record name and validates id, name, and parent opts' do
16
- any_stub = stub(:required => true)
17
- option_stub = stub(:exist? => true)
18
- @cmd.stubs(:option).returns(option_stub)
19
-
20
- @cmd.expects(:any).with('option_id', 'option_name').returns(any_stub)
21
- @cmd.expects(:any).with('option_organization_id',
22
- 'option_organization_name',
23
- 'option_organization_label'
24
- ).returns(any_stub)
25
-
26
- @cmd.validate_id_or_name_with_parent
27
- end
28
-
29
- it 'accepts content view as a record name' do
30
- any_stub = stub(:required => true)
31
- option_stub = stub(:exist? => true)
32
- @cmd.stubs(:option).returns(option_stub)
33
-
34
- @cmd.expects(:any).with('option_content_view_id',
35
- 'option_content_view_name'
36
- ).returns(any_stub)
37
- @cmd.expects(:any).with('option_organization_id',
38
- 'option_organization_name',
39
- 'option_organization_label'
40
- ).returns(any_stub)
41
-
42
- @cmd.validate_id_or_name_with_parent(:content_view)
43
- end
44
-
45
- it 'does not validate org options if the name opt is not used' do
46
- any_stub = stub(:required => true)
47
- option_stub = stub(:exist? => false) # --name was not supplied
48
- @cmd.stubs(:option).returns(option_stub)
49
-
50
- @cmd.expects(:any).at_most_once.returns(any_stub)
51
-
52
- @cmd.validate_id_or_name_with_parent
53
- end
54
-
55
- it 'does not validate name or id if required is false' do
56
- any_stub = stub(:required => true)
57
- option_stub = stub(:exist? => true)
58
- @cmd.stubs(:option).returns(option_stub)
59
-
60
- @cmd.expects(:any).with('option_organization_id',
61
- 'option_organization_name',
62
- 'option_organization_label'
63
- ).returns(any_stub)
64
-
65
- @cmd.validate_id_or_name_with_parent(required: false)
66
- end
67
-
68
- it 'accepts a hash of fields for the parent' do
69
- any_stub = stub(:required => true)
70
- option_stub = stub(:exist? => true)
71
- @cmd.stubs(:option).returns(option_stub)
72
-
73
- @cmd.expects(:any).with('option_id', 'option_name').returns(any_stub)
74
- @cmd.expects(:any).with('option_product_test').returns(any_stub)
75
-
76
- @cmd.validate_id_or_name_with_parent(parent: {:product => ['test']})
77
- end
78
- end
79
-
80
- describe '#validate_id_or_name' do
81
- it 'validates that id or name is required' do
82
- any_stub = stub(:required => true)
83
- @cmd.expects(:any).with('option_id', 'option_name').returns(any_stub)
84
- @cmd.validate_id_or_name
85
- end
86
-
87
- it 'accepts a custom record name' do
88
- any_stub = stub(:required => true)
89
- @cmd.expects(:any).with('option_content_view_id',
90
- 'option_content_view_name'
91
- ).returns(any_stub)
92
- @cmd.validate_id_or_name(:content_view)
93
- end
94
- end
95
- end
96
- end
@@ -1,58 +0,0 @@
1
- require_relative '../test_helper'
2
- require 'hammer_cli_katello/id_resolver'
3
-
4
- module HammerCLIKatello
5
- describe IdResolver do
6
- let(:api) { mock('api') }
7
- let(:searchables) { mock('searchables') }
8
- let(:id_resolver) { IdResolver.new api, searchables }
9
-
10
- before(:each) do
11
- api.stubs(:resources).returns([])
12
- api.stubs(:resource).returns([])
13
- end
14
-
15
- describe '#repository_ids' do
16
- it 'accepts nil repository_names' do
17
- id_resolver.stubs(:find_resources).returns([])
18
- id_resolver.repository_ids({}).must_equal(nil)
19
- end
20
-
21
- it 'accepts repository_ids' do
22
- id_resolver.repository_ids(
23
- 'option_repository_ids' => [1, 2]
24
- ).must_equal [1, 2]
25
- end
26
-
27
- it 'accepts repository_names' do
28
- id_resolver.stubs(:find_resources).returns(
29
- [
30
- {'id' => 1, 'name' => 'repo1'},
31
- {'id' => 2, 'name' => 'repo2'}
32
- ]
33
- )
34
- id_resolver.repository_ids(
35
- 'option_names' => %w(repo1 repo2)
36
- ).must_equal [1, 2]
37
- end
38
- end
39
-
40
- describe '#repository_id' do
41
- it 'resolves ID from name' do
42
- id_resolver.expects(:find_resource).with(:repositories, name: 'repo1').returns('id' => 5)
43
- options = {name: 'repo1'}
44
- id_resolver.repository_id(options).must_equal 5
45
- end
46
- end
47
-
48
- describe '#content_view_version_id' do
49
- it 'resolves ID from version number' do
50
- options = {'option_version' => '2.0', 'option_content_view_id' => 4}
51
- id_resolver.expects(:find_resources)
52
- .with(:content_view_versions, options)
53
- .returns(['id' => 5])
54
- id_resolver.content_view_version_id(options).must_equal 5
55
- end
56
- end
57
- end
58
- end
@@ -1,7 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../test_helper')
2
- require 'hammer_cli/testing/messages'
3
-
4
- include HammerCLI::Testing::Messages
5
- describe "message formatting" do
6
- check_all_command_messages(HammerCLI::MainCommand, HammerCLIKatello::Command)
7
- end