hammer_cli_katello 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hammer_cli_katello/content_export_complete.rb +8 -0
  3. data/lib/hammer_cli_katello/content_export_helper.rb +55 -3
  4. data/lib/hammer_cli_katello/content_export_incremental.rb +8 -0
  5. data/lib/hammer_cli_katello/content_import.rb +9 -0
  6. data/lib/hammer_cli_katello/host_collection.rb +2 -0
  7. data/lib/hammer_cli_katello/id_resolver.rb +3 -2
  8. data/lib/hammer_cli_katello/organization.rb +11 -0
  9. data/lib/hammer_cli_katello/repository.rb +39 -2
  10. data/lib/hammer_cli_katello/version.rb +1 -1
  11. metadata +4 -398
  12. data/test/data/2.5/foreman_api.json +0 -1
  13. data/test/data/3.0/foreman_api.json +0 -1
  14. data/test/data/3.10/foreman_api.json +0 -1
  15. data/test/data/3.11/foreman_api.json +0 -1
  16. data/test/data/3.12/foreman_api.json +0 -1
  17. data/test/data/3.13/foreman_api.json +0 -1
  18. data/test/data/3.14/foreman_api.json +0 -1
  19. data/test/data/3.15/foreman_api.json +0 -1
  20. data/test/data/3.16/foreman_api.json +0 -1
  21. data/test/data/3.17/foreman_api.json +0 -1
  22. data/test/data/3.18/foreman_api.json +0 -1
  23. data/test/data/3.19/foreman_api.json +0 -1
  24. data/test/data/3.2/foreman_api.json +0 -1
  25. data/test/data/3.4/foreman_api.json +0 -1
  26. data/test/data/3.5/foreman_api.json +0 -1
  27. data/test/data/3.6/foreman_api.json +0 -1
  28. data/test/data/3.7/foreman_api.json +0 -1
  29. data/test/data/3.8/foreman_api.json +0 -1
  30. data/test/data/3.9/foreman_api.json +0 -1
  31. data/test/data/4.0/foreman_api.json +0 -1
  32. data/test/data/4.1/foreman_api.json +0 -1
  33. data/test/data/4.3/foreman_api.json +0 -1
  34. data/test/data/4.4/foreman_api.json +0 -1
  35. data/test/data/Readme.md +0 -5
  36. data/test/functional/activation_key/add_host_collection_test.rb +0 -62
  37. data/test/functional/activation_key/content_override_test.rb +0 -92
  38. data/test/functional/activation_key/create_test.rb +0 -33
  39. data/test/functional/activation_key/data/activation_key.json +0 -17
  40. data/test/functional/activation_key/info_test.rb +0 -29
  41. data/test/functional/activation_key/list_test.rb +0 -68
  42. data/test/functional/activation_key/product_content_test.rb +0 -23
  43. data/test/functional/activation_key/remove_host_collection_test.rb +0 -62
  44. data/test/functional/activation_key/subscriptions_test.rb +0 -74
  45. data/test/functional/activation_key/update_test.rb +0 -26
  46. data/test/functional/apipie_helper_test.rb +0 -31
  47. data/test/functional/capsule/capsule_helpers.rb +0 -13
  48. data/test/functional/capsule/content/add_lifecycle_environment_test.rb +0 -40
  49. data/test/functional/capsule/content/cancel_synchronization_test.rb +0 -42
  50. data/test/functional/capsule/content/capsule_content_helpers.rb +0 -24
  51. data/test/functional/capsule/content/data/library_env.json +0 -47
  52. data/test/functional/capsule/content/data/sync_status.json +0 -6
  53. data/test/functional/capsule/content/data/sync_tasks.json +0 -62
  54. data/test/functional/capsule/content/info_test.rb +0 -61
  55. data/test/functional/capsule/content/lifecycle_environments_test.rb +0 -19
  56. data/test/functional/capsule/content/remove_lifecycle_environment_test.rb +0 -40
  57. data/test/functional/capsule/content/synchronization_status_test.rb +0 -107
  58. data/test/functional/capsule/info_test.rb +0 -25
  59. data/test/functional/capsule/list_test.rb +0 -24
  60. data/test/functional/content_credentials/create_test.rb +0 -32
  61. data/test/functional/content_credentials/data/test_cert.json +0 -43
  62. data/test/functional/content_credentials/info_test.rb +0 -50
  63. data/test/functional/content_credentials/list_test.rb +0 -66
  64. data/test/functional/content_export/complete/library_test.rb +0 -155
  65. data/test/functional/content_export/complete/version_test.rb +0 -252
  66. data/test/functional/content_export/content_export_helpers.rb +0 -26
  67. data/test/functional/content_export/generate_metadata_test.rb +0 -64
  68. data/test/functional/content_export/incremental/library_test.rb +0 -172
  69. data/test/functional/content_export/incremental/version_test.rb +0 -268
  70. data/test/functional/content_export/list_test.rb +0 -64
  71. data/test/functional/content_import/library_test.rb +0 -85
  72. data/test/functional/content_import/list_test.rb +0 -65
  73. data/test/functional/content_import/metadata.json +0 -1
  74. data/test/functional/content_import/version_test.rb +0 -85
  75. data/test/functional/content_units/info_test.rb +0 -29
  76. data/test/functional/content_units/list_test.rb +0 -106
  77. data/test/functional/content_view/add_content_view_version_test.rb +0 -88
  78. data/test/functional/content_view/add_repository_test.rb +0 -21
  79. data/test/functional/content_view/component/add_test.rb +0 -177
  80. data/test/functional/content_view/component/list_test.rb +0 -55
  81. data/test/functional/content_view/component/remove_test.rb +0 -107
  82. data/test/functional/content_view/component/update_test.rb +0 -134
  83. data/test/functional/content_view/content_view_helpers.rb +0 -20
  84. data/test/functional/content_view/copy_test.rb +0 -53
  85. data/test/functional/content_view/create_test.rb +0 -34
  86. data/test/functional/content_view/delete_test.rb +0 -62
  87. data/test/functional/content_view/filter/create_test.rb +0 -57
  88. data/test/functional/content_view/filter/delete_test.rb +0 -90
  89. data/test/functional/content_view/filter/info_test.rb +0 -89
  90. data/test/functional/content_view/filter/list_test.rb +0 -98
  91. data/test/functional/content_view/filter/update_test.rb +0 -91
  92. data/test/functional/content_view/list_test.rb +0 -68
  93. data/test/functional/content_view/publish_test.rb +0 -24
  94. data/test/functional/content_view/purge_test.rb +0 -97
  95. data/test/functional/content_view/remove_content_view_version_test.rb +0 -88
  96. data/test/functional/content_view/remove_test.rb +0 -79
  97. data/test/functional/content_view/update_test.rb +0 -53
  98. data/test/functional/content_view/version/incremental_update_test.rb +0 -108
  99. data/test/functional/content_view/version/list_test.rb +0 -44
  100. data/test/functional/content_view/version/promote_test.rb +0 -75
  101. data/test/functional/content_view/version/republish_repositories_test.rb +0 -34
  102. data/test/functional/content_view/version/update_test.rb +0 -48
  103. data/test/functional/erratum/erratum_helpers.rb +0 -91
  104. data/test/functional/erratum/info_test.rb +0 -29
  105. data/test/functional/erratum/list_test.rb +0 -108
  106. data/test/functional/file/file_helpers.rb +0 -13
  107. data/test/functional/file/info_test.rb +0 -162
  108. data/test/functional/file/list_test.rb +0 -112
  109. data/test/functional/filter_rule/create_test.rb +0 -99
  110. data/test/functional/filter_rule/delete_test.rb +0 -104
  111. data/test/functional/filter_rule/filter_rule_helpers.rb +0 -12
  112. data/test/functional/filter_rule/info_test.rb +0 -104
  113. data/test/functional/filter_rule/list_test.rb +0 -91
  114. data/test/functional/filter_rule/update_test.rb +0 -104
  115. data/test/functional/host/errata/apply_test.rb +0 -45
  116. data/test/functional/host/errata/info_test.rb +0 -27
  117. data/test/functional/host/errata/list_test.rb +0 -49
  118. data/test/functional/host/errata/recalculate_test.rb +0 -26
  119. data/test/functional/host/extensions/create_test.rb +0 -95
  120. data/test/functional/host/extensions/data/host.json +0 -320
  121. data/test/functional/host/extensions/data/host_list.json +0 -117
  122. data/test/functional/host/extensions/info_test.rb +0 -35
  123. data/test/functional/host/extensions/list_test.rb +0 -21
  124. data/test/functional/host/extensions/update_test.rb +0 -70
  125. data/test/functional/host/host_helpers.rb +0 -8
  126. data/test/functional/host/subscription/attach_test.rb +0 -54
  127. data/test/functional/host/subscription/auto_attach_test.rb +0 -35
  128. data/test/functional/host/subscription/content_override_test.rb +0 -96
  129. data/test/functional/host/subscription/product_content_test.rb +0 -27
  130. data/test/functional/host/subscription/register_test.rb +0 -53
  131. data/test/functional/host/subscription/remove_test.rb +0 -52
  132. data/test/functional/host/subscription/unregister_test.rb +0 -37
  133. data/test/functional/host/traces/list_test.rb +0 -37
  134. data/test/functional/host/traces/resolve_test.rb +0 -31
  135. data/test/functional/host_collection/add_host_test.rb +0 -90
  136. data/test/functional/host_collection/content_api_expectations.rb +0 -35
  137. data/test/functional/host_collection/content_install_test.rb +0 -62
  138. data/test/functional/host_collection/content_remove_test.rb +0 -37
  139. data/test/functional/host_collection/content_update_test.rb +0 -37
  140. data/test/functional/host_collection/copy_test.rb +0 -64
  141. data/test/functional/host_collection/create_test.rb +0 -54
  142. data/test/functional/host_collection/delete_test.rb +0 -57
  143. data/test/functional/host_collection/hosts_test.rb +0 -39
  144. data/test/functional/host_collection/info_test.rb +0 -57
  145. data/test/functional/host_collection/list_test.rb +0 -63
  146. data/test/functional/host_collection/remove_host_test.rb +0 -90
  147. data/test/functional/host_collection/update_test.rb +0 -57
  148. data/test/functional/hostgroup/create_test.rb +0 -112
  149. data/test/functional/hostgroup/data/hostgroup.json +0 -50
  150. data/test/functional/hostgroup/info_test.rb +0 -33
  151. data/test/functional/hostgroup/update_test.rb +0 -120
  152. data/test/functional/lifecycle_environment/create_test.rb +0 -14
  153. data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +0 -18
  154. data/test/functional/lifecycle_environment/list_test.rb +0 -38
  155. data/test/functional/lifecycle_environment/update_test.rb +0 -14
  156. data/test/functional/local_helper_test.rb +0 -30
  157. data/test/functional/module_stream/info_test.rb +0 -58
  158. data/test/functional/module_stream/list_test.rb +0 -53
  159. data/test/functional/organization/cdn_configuration_test.rb +0 -45
  160. data/test/functional/organization/delete_test.rb +0 -26
  161. data/test/functional/organization/info_test.rb +0 -39
  162. data/test/functional/organization/organization_helpers.rb +0 -10
  163. data/test/functional/package/list_test.rb +0 -160
  164. data/test/functional/package_group/list_test.rb +0 -38
  165. data/test/functional/ping_test.rb +0 -61
  166. data/test/functional/product/create_test.rb +0 -54
  167. data/test/functional/product/delete_test.rb +0 -41
  168. data/test/functional/product/info_test.rb +0 -33
  169. data/test/functional/product/list_test.rb +0 -58
  170. data/test/functional/product/product_helpers.rb +0 -24
  171. data/test/functional/product/remove_sync_plan_test.rb +0 -35
  172. data/test/functional/product/set_sync_plan_test.rb +0 -49
  173. data/test/functional/product/update_proxy.rb +0 -48
  174. data/test/functional/product/update_test.rb +0 -46
  175. data/test/functional/repository/create_test.rb +0 -21
  176. data/test/functional/repository/delete_test.rb +0 -95
  177. data/test/functional/repository/info_test.rb +0 -162
  178. data/test/functional/repository/list_test.rb +0 -68
  179. data/test/functional/repository/reclaim_space_test.rb +0 -105
  180. data/test/functional/repository/remove_content_test.rb +0 -108
  181. data/test/functional/repository/repository_helpers.rb +0 -18
  182. data/test/functional/repository/synchronize_test.rb +0 -57
  183. data/test/functional/repository/update_test.rb +0 -149
  184. data/test/functional/repository/upload_test.rb +0 -368
  185. data/test/functional/repository_set/available_repositories_test.rb +0 -18
  186. data/test/functional/repository_set/disable_test.rb +0 -42
  187. data/test/functional/repository_set/enable_test.rb +0 -42
  188. data/test/functional/repository_set/info_test.rb +0 -17
  189. data/test/functional/repository_set/list_test.rb +0 -18
  190. data/test/functional/repository_set/repository_set_helpers.rb +0 -20
  191. data/test/functional/search_helpers.rb +0 -17
  192. data/test/functional/simple_content_access/disable_test.rb +0 -48
  193. data/test/functional/simple_content_access/enable_test.rb +0 -46
  194. data/test/functional/srpm/list_test.rb +0 -92
  195. data/test/functional/subscription/list_test.rb +0 -86
  196. data/test/functional/sync_plan/create_test.rb +0 -60
  197. data/test/functional/sync_plan/delete_test.rb +0 -46
  198. data/test/functional/sync_plan/info_test.rb +0 -37
  199. data/test/functional/sync_plan/list_test.rb +0 -31
  200. data/test/functional/sync_plan/sync_plan_helpers.rb +0 -8
  201. data/test/functional/sync_plan/update_test.rb +0 -44
  202. data/test/functional/test_helper.rb +0 -24
  203. data/test/task_helper.rb +0 -7
  204. data/test/test_helper.rb +0 -38
  205. data/test/unit/id_name_options_validator_test.rb +0 -96
  206. data/test/unit/id_resolver_test.rb +0 -58
  207. data/test/unit/messages_test.rb +0 -7
  208. data/test/unit/search_options_creators_test.rb +0 -145
@@ -1,268 +0,0 @@
1
- require_relative '../../test_helper'
2
- require 'hammer_cli_katello/content_export'
3
- require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
4
- require_relative '../../content_view/content_view_helpers'
5
- require_relative '../content_export_helpers'
6
-
7
- describe 'content-export incremental version' do
8
- include ForemanTaskHelpers
9
- include ContentExportHelpers
10
- include ContentViewHelpers
11
- include LifecycleEnvironmentHelpers
12
-
13
- before do
14
- @cmd = %w(content-export incremental version)
15
- end
16
-
17
- let(:task_id) { '5' }
18
- let(:response) do
19
- {
20
- 'id' => task_id,
21
- 'state' => 'planned',
22
- 'output' => {
23
- 'export_history_id' => 2
24
- }
25
- }
26
- end
27
-
28
- let(:export_history_id) { 1000 }
29
-
30
- let(:export_history) do
31
- {
32
- "id": export_history_id,
33
- "path": "/tmp",
34
- "metadata": {}
35
- }
36
- end
37
-
38
- let(:content_view_id) { '77' }
39
- let(:content_view_version_id) { 100 }
40
-
41
- let(:version) { '10.0' }
42
- let(:destination_server) { "dream.example.com" }
43
-
44
- it "performs export with required options and async" do
45
- params = [
46
- "--id=#{content_view_version_id}",
47
- '--destination-server=foo',
48
- '--async'
49
- ]
50
- expects_repositories_in_version(content_view_version_id)
51
-
52
- ex = api_expects(:content_export_incrementals, :version)
53
- ex.returns(response)
54
-
55
- result = run_cmd(@cmd + params)
56
-
57
- assert_equal("Content view version is being exported in task #{task_id}.\n"\
58
- + "Once the task completes the export metadata must be generated with the "\
59
- + "command:\n hammer content-export generate-metadata --task-id #{task_id}\n", result.out)
60
- assert_equal(HammerCLI::EX_OK, result.exit_code)
61
- end
62
-
63
- it "performs export with required options" do
64
- params = [
65
- "--id=#{content_view_version_id}",
66
- '--destination-server=foo'
67
- ]
68
-
69
- expects_repositories_in_version(content_view_version_id)
70
- ex = api_expects(:content_export_incrementals, :version)
71
- ex.returns(response)
72
-
73
- expect_foreman_task(task_id).at_least_once
74
-
75
- HammerCLIKatello::ContentExportIncremental::VersionCommand.
76
- any_instance.
77
- expects(:fetch_export_history).
78
- returns(export_history)
79
-
80
- result = run_cmd(@cmd + params)
81
- assert_match(/Generated .*metadata.*json/, result.out)
82
- assert_equal(HammerCLI::EX_OK, result.exit_code)
83
- end
84
-
85
- it "performs export with history id" do
86
- params = [
87
- "--id=#{content_view_version_id}",
88
- "--destination-server=#{destination_server}",
89
- "--from-history-id=#{export_history_id}"
90
- ]
91
- expects_repositories_in_version(content_view_version_id)
92
- api_expects(:content_export_incrementals, :version)
93
- .with_params('id' => content_view_version_id,
94
- 'destination_server' => destination_server,
95
- 'from_history_id' => export_history_id)
96
- .returns(response)
97
-
98
- expect_foreman_task(task_id).at_least_once
99
-
100
- HammerCLIKatello::ContentExportIncremental::VersionCommand.
101
- any_instance.
102
- expects(:fetch_export_history).
103
- returns(export_history)
104
-
105
- result = run_cmd(@cmd + params)
106
- assert_match(/Generated .*metadata.*json/, result.out)
107
- assert_equal(HammerCLI::EX_OK, result.exit_code)
108
- end
109
-
110
- it 'fails on missing required params' do
111
- params = [
112
- '--boo-id=2'
113
- ]
114
-
115
- result = run_cmd(@cmd + params)
116
- expected_error = "Could not export the content view version:\n"
117
-
118
- assert_equal(result.exit_code, HammerCLI::EX_USAGE)
119
- assert_equal(result.err[/#{expected_error}/], expected_error)
120
- end
121
-
122
- it 'correctly resolves content-view-id and content view version number' do
123
- params = ["--content-view-id=#{content_view_id}",
124
- "--version=#{version}",
125
- "--destination-server=#{destination_server}",
126
- "--async"]
127
- expects_repositories_in_version(content_view_version_id)
128
- cvv_expect = api_expects(:content_view_versions, :index) do |p|
129
- assert_equal p['content_view_id'].to_s, content_view_id.to_s
130
- assert_equal p["version"], version
131
- end
132
-
133
- cvv_expect.at_least_once.
134
- returns(index_response([{'id' => content_view_version_id}]))
135
-
136
- ex = api_expects(:content_export_incrementals, :version) do |p|
137
- assert_equal p['id'], content_view_version_id
138
- assert_equal p["destination_server"], destination_server
139
- end
140
- ex.returns(response)
141
-
142
- run_cmd(@cmd + params)
143
- end
144
-
145
- it 'fails on missing content-view name/id' do
146
- params = []
147
-
148
- result = run_cmd(@cmd + params)
149
- expected_error = " At least one of options --id, --content-view, --content-view-id is required"
150
-
151
- assert_equal(result.exit_code, HammerCLI::EX_USAGE)
152
- assert_match(/#{expected_error}/, result.err)
153
- end
154
-
155
- it 'fails on missing content-view version' do
156
- params = ["--content-view-id=2"]
157
- result = run_cmd(@cmd + params)
158
-
159
- expected_error = "--version, --lifecycle-environment-id, --lifecycle-environment is required."
160
- assert_equal(result.exit_code, HammerCLI::EX_USAGE)
161
- assert_match(/#{expected_error}/, result.err)
162
- end
163
-
164
- it 'fails on missing content-view missing org' do
165
- params = ["--content-view=lol", "--version=4.0"]
166
- result = run_cmd(@cmd + params)
167
- expected_error = "At least one of options --organization-id, "\
168
- "--organization, --organization-label is required."
169
-
170
- assert_equal(result.exit_code, HammerCLI::EX_USAGE)
171
- assert_match(/#{expected_error}/, result.err)
172
- end
173
-
174
- it 'correctly resolves content-view-id and content view version number' do
175
- params = ["--content-view-id=#{content_view_id}",
176
- "--version=#{version}",
177
- "--destination-server=#{destination_server}",
178
- "--async"]
179
-
180
- cvv_expect = api_expects(:content_view_versions, :index) do |p|
181
- assert_equal p['content_view_id'].to_s, content_view_id.to_s
182
- assert_equal p["version"], version
183
- end
184
-
185
- cvv_expect.at_least_once.
186
- returns(index_response([{'id' => content_view_version_id}]))
187
-
188
- api_expects(:content_export_incrementals, :version)
189
- .with_params('id' => content_view_version_id)
190
- .returns(response)
191
-
192
- expects_repositories_in_version(content_view_version_id)
193
- run_cmd(@cmd + params)
194
- end
195
-
196
- it 'warns of lazy repositories' do
197
- params = ["--id=#{content_view_version_id}"]
198
- expects_repositories_in_version(content_view_version_id, [{id: 200}])
199
-
200
- api_expects(:content_export_incrementals, :version)
201
- .with_params('id' => content_view_version_id)
202
- .returns(response)
203
-
204
- expect_foreman_task(task_id).at_least_once
205
-
206
- HammerCLIKatello::ContentExportIncremental::VersionCommand.
207
- any_instance.
208
- expects(:fetch_export_history).
209
- returns(export_history)
210
-
211
- result = run_cmd(@cmd + params)
212
- assert_match(/Unable to fully export this version because/, result.out)
213
- assert_match(/200/, result.out)
214
- assert_equal(HammerCLI::EX_OK, result.exit_code)
215
- end
216
-
217
- it 'Errors out on lazy repositories if --fail-on-missing-content' do
218
- params = ["--id=#{content_view_version_id}",
219
- "--fail-on-missing-content"]
220
- expects_repositories_in_version(content_view_version_id, [{id: 200}])
221
-
222
- ex = api_expects(:content_export_incrementals, :version)
223
- ex.returns(response)
224
-
225
- expect_foreman_task(task_id).at_least_once
226
-
227
- HammerCLIKatello::ContentExportIncremental::VersionCommand.
228
- any_instance.
229
- expects(:fetch_export_history).
230
- returns(export_history)
231
-
232
- HammerCLIKatello::ContentExportIncremental::VersionCommand.
233
- any_instance.
234
- expects(:exit).with(HammerCLI::EX_SOFTWARE)
235
-
236
- result = run_cmd(@cmd + params)
237
- assert_match(/Unable to fully export this version because/, result.out)
238
- assert_match(/200/, result.out)
239
- end
240
-
241
- it 'should accept content view and lifecycle environment and get the right version' do
242
- env = "foo"
243
- org_id = '100'
244
- env_id = '223'
245
- params = ["--content-view-id=#{content_view_id}",
246
- "--lifecycle-environment=#{env}",
247
- "--organization-id=#{org_id}"]
248
- expect_lifecycle_environment_search(org_id, env, env_id)
249
- expect_content_view_version_search({'environment_id' => env_id,
250
- 'content_view_id' => content_view_id},
251
- 'id' => content_view_version_id).at_least_once
252
-
253
- expects_repositories_in_version(content_view_version_id)
254
- ex = api_expects(:content_export_incrementals, :version)
255
- ex.returns(response)
256
-
257
- expect_foreman_task(task_id).at_least_once
258
-
259
- HammerCLIKatello::ContentExportIncremental::VersionCommand.
260
- any_instance.
261
- expects(:fetch_export_history).
262
- returns(export_history)
263
-
264
- result = run_cmd(@cmd + params)
265
- assert_match(/Generated .*metadata.*json/, result.out)
266
- assert_equal(HammerCLI::EX_OK, result.exit_code)
267
- end
268
- end
@@ -1,64 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
- require 'hammer_cli_katello/content_export'
3
-
4
- describe 'content-export list' do
5
- let(:empty_response) do
6
- {
7
- "total" => 0,
8
- "subtotal" => 0,
9
- "page" => "1",
10
- "per_page" => "1000",
11
- "error" => nil,
12
- "search" => nil,
13
- "sort" => {
14
- "by" => nil,
15
- "order" => nil
16
- },
17
- "results" => []
18
- }
19
- end
20
-
21
- it 'allows minimal options' do
22
- ex = api_expects(:content_exports, :index)
23
-
24
- ex.returns(empty_response)
25
- # rubocop:disable LineLength
26
- expected_result = success_result('---|--------------------|------|------|----------------------|-------------------------|------------|-----------
27
- ID | DESTINATION SERVER | PATH | TYPE | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
28
- ---|--------------------|------|------|----------------------|-------------------------|------------|-----------
29
- ')
30
- # rubocop:enable LineLength
31
- result = run_cmd(%w(content-export list))
32
- assert_cmd(expected_result, result)
33
- end
34
-
35
- it 'works with content-view-id only' do
36
- api_expects(:content_view_versions, :index).returns(empty_response)
37
-
38
- ex = api_expects(:content_exports, :index)
39
-
40
- ex.returns(empty_response)
41
- # rubocop:disable LineLength
42
- expected_result = success_result('---|--------------------|------|------|----------------------|-------------------------|------------|-----------
43
- ID | DESTINATION SERVER | PATH | TYPE | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
44
- ---|--------------------|------|------|----------------------|-------------------------|------------|-----------
45
- ')
46
- # rubocop:enable LineLength
47
- result = run_cmd(%w(content-export list --content-view-id=1))
48
- assert_cmd(expected_result, result)
49
- end
50
-
51
- it 'works with content-view-version-id only' do
52
- ex = api_expects(:content_exports, :index)
53
-
54
- ex.returns(empty_response)
55
- # rubocop:disable LineLength
56
- expected_result = success_result('---|--------------------|------|------|----------------------|-------------------------|------------|-----------
57
- ID | DESTINATION SERVER | PATH | TYPE | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
58
- ---|--------------------|------|------|----------------------|-------------------------|------------|-----------
59
- ')
60
- # rubocop:enable LineLength
61
- result = run_cmd(%w(content-export list --content-view-version-id=1))
62
- assert_cmd(expected_result, result)
63
- end
64
- end
@@ -1,85 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
- require 'hammer_cli_katello/content_import'
3
-
4
- describe 'content-import library' do
5
- include ForemanTaskHelpers
6
-
7
- before do
8
- @cmd = %w(content-import library)
9
- end
10
-
11
- let(:task_id) { '5' }
12
-
13
- let(:response) do
14
- {
15
- 'id' => task_id,
16
- 'state' => 'planned'
17
- }
18
- end
19
-
20
- let(:path) do
21
- File.dirname(__FILE__)
22
- end
23
-
24
- let(:metadata) do
25
- JSON.parse(File.read("#{path}/metadata.json"))
26
- end
27
-
28
- let(:organization_id) { 3 }
29
-
30
- it "performs import with required options and async" do
31
- params = [
32
- "--organization-id=#{organization_id}",
33
- "--path=#{path}",
34
- '--async'
35
- ]
36
- api_expects(:content_imports, :library)
37
- .with_params('organization_id' => organization_id, 'path' => path, 'metadata' => metadata)
38
- .returns(response)
39
-
40
- result = run_cmd(@cmd + params)
41
-
42
- assert_equal("Archive is being imported in task #{task_id}.\n", result.out)
43
- assert_equal(HammerCLI::EX_OK, result.exit_code)
44
- end
45
-
46
- it "performs import with required options" do
47
- params = [
48
- "--organization-id=#{organization_id}",
49
- "--path=#{path}"
50
- ]
51
-
52
- api_expects(:content_imports, :library)
53
- .with_params('organization_id' => organization_id, 'path' => path, 'metadata' => metadata)
54
- .returns(response)
55
-
56
- expect_foreman_task(task_id)
57
-
58
- result = run_cmd(@cmd + params)
59
- assert_equal(HammerCLI::EX_OK, result.exit_code)
60
- end
61
-
62
- it 'fails on missing required params' do
63
- params = [
64
- '--id=2'
65
- ]
66
-
67
- result = run_cmd(@cmd + params)
68
- expected_error = "Could not import the archive."
69
-
70
- assert_equal(result.exit_code, HammerCLI::EX_USAGE)
71
- assert_equal(result.err[/#{expected_error}/], expected_error)
72
- end
73
-
74
- it 'fails on missing metadata.json' do
75
- bad_path = "/nosuchdir"
76
- params = [
77
- "--organization-id=#{organization_id}",
78
- "--path=#{bad_path}"
79
- ]
80
- result = run_cmd(@cmd + params)
81
- expected_error = "Unable to find '#{bad_path}/metadata.json'."
82
-
83
- assert_match(/#{expected_error}/, result.err)
84
- end
85
- end
@@ -1,65 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
- require 'hammer_cli_katello/content_import'
3
-
4
- describe 'content-import list' do
5
- let(:empty_response) do
6
- {
7
- "total" => 0,
8
- "subtotal" => 0,
9
- "page" => "1",
10
- "per_page" => "1000",
11
- "error" => nil,
12
- "search" => nil,
13
- "sort" => {
14
- "by" => nil,
15
- "order" => nil
16
- },
17
- "results" => []
18
- }
19
- end
20
-
21
- it 'allows minimal options' do
22
- ex = api_expects(:content_imports, :index)
23
-
24
- ex.returns(empty_response)
25
-
26
- # rubocop:disable LineLength
27
- expected_result = success_result('---|------|------|----------------------|-------------------------|------------|-----------
28
- ID | PATH | TYPE | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
29
- ---|------|------|----------------------|-------------------------|------------|-----------
30
- ')
31
- # rubocop:enable LineLength
32
- result = run_cmd(%w(content-import list))
33
- assert_cmd(expected_result, result)
34
- end
35
-
36
- it 'works with content-view-id only' do
37
- api_expects(:content_view_versions, :index).returns(empty_response)
38
-
39
- ex = api_expects(:content_imports, :index)
40
-
41
- ex.returns(empty_response)
42
- # rubocop:disable LineLength
43
- expected_result = success_result('---|------|------|----------------------|-------------------------|------------|-----------
44
- ID | PATH | TYPE | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
45
- ---|------|------|----------------------|-------------------------|------------|-----------
46
- ')
47
- # rubocop:enable LineLength
48
- result = run_cmd(%w(content-import list --content-view-id=1))
49
- assert_cmd(expected_result, result)
50
- end
51
-
52
- it 'works with content-view-version-id only' do
53
- ex = api_expects(:content_imports, :index)
54
-
55
- ex.returns(empty_response)
56
- # rubocop:disable LineLength
57
- expected_result = success_result('---|------|------|----------------------|-------------------------|------------|-----------
58
- ID | PATH | TYPE | CONTENT VIEW VERSION | CONTENT VIEW VERSION ID | CREATED AT | UPDATED AT
59
- ---|------|------|----------------------|-------------------------|------------|-----------
60
- ')
61
- # rubocop:enable LineLength
62
- result = run_cmd(%w(content-import list --content-view-version-id=1))
63
- assert_cmd(expected_result, result)
64
- end
65
- end
@@ -1 +0,0 @@
1
- {"organization":"export-9697","repository_mapping":{"katello-15062":{"repository":"katello","product":"prod","redhat":false},"misc-28137":{"repository":"misc","product":"prod","redhat":false},"candlepin-37918":{"repository":"candlepin","product":"prod","redhat":false}},"content_view":"view","content_view_version":{"major":1,"minor":0},"incremental":false,"toc":"export-24d91ced-3d11-4fa2-b5ea-19a41f7b97a5-20201118_1523-toc.json"}
@@ -1,85 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../test_helper')
2
- require 'hammer_cli_katello/content_import'
3
-
4
- describe 'content-import version' do
5
- include ForemanTaskHelpers
6
-
7
- before do
8
- @cmd = %w(content-import version)
9
- end
10
-
11
- let(:task_id) { '5' }
12
-
13
- let(:response) do
14
- {
15
- 'id' => task_id,
16
- 'state' => 'planned'
17
- }
18
- end
19
-
20
- let(:path) do
21
- File.dirname(__FILE__)
22
- end
23
-
24
- let(:metadata) do
25
- JSON.parse(File.read("#{path}/metadata.json"))
26
- end
27
-
28
- let(:organization_id) { 3 }
29
-
30
- it "performs import with required options and async" do
31
- params = [
32
- "--organization-id=#{organization_id}",
33
- "--path=#{path}",
34
- '--async'
35
- ]
36
- api_expects(:content_imports, :version)
37
- .with_params('organization_id' => organization_id, 'path' => path, 'metadata' => metadata)
38
- .returns(response)
39
-
40
- result = run_cmd(@cmd + params)
41
-
42
- assert_equal("Archive is being imported in task #{task_id}.\n", result.out)
43
- assert_equal(HammerCLI::EX_OK, result.exit_code)
44
- end
45
-
46
- it "performs import with required options" do
47
- params = [
48
- "--organization-id=#{organization_id}",
49
- "--path=#{path}"
50
- ]
51
-
52
- api_expects(:content_imports, :version)
53
- .with_params('organization_id' => organization_id, 'path' => path, 'metadata' => metadata)
54
- .returns(response)
55
-
56
- expect_foreman_task(task_id)
57
-
58
- result = run_cmd(@cmd + params)
59
- assert_equal(HammerCLI::EX_OK, result.exit_code)
60
- end
61
-
62
- it 'fails on missing required params' do
63
- params = [
64
- '--id=2'
65
- ]
66
-
67
- result = run_cmd(@cmd + params)
68
- expected_error = "Could not import the archive."
69
-
70
- assert_equal(result.exit_code, HammerCLI::EX_USAGE)
71
- assert_equal(result.err[/#{expected_error}/], expected_error)
72
- end
73
-
74
- it 'fails on missing metadata.json' do
75
- bad_path = "/nosuchdir"
76
- params = [
77
- "--organization-id=#{organization_id}",
78
- "--path=#{bad_path}"
79
- ]
80
- result = run_cmd(@cmd + params)
81
- expected_error = "Unable to find '#{bad_path}/metadata.json'."
82
-
83
- assert_match(/#{expected_error}/, result.err)
84
- end
85
- end
@@ -1,29 +0,0 @@
1
- require_relative '../test_helper.rb'
2
- require_relative '../organization/organization_helpers'
3
- require_relative '../content_view/content_view_helpers'
4
- require_relative '../repository/repository_helpers'
5
- require_relative '../product/product_helpers'
6
- require 'hammer_cli_katello/content_units'
7
-
8
- module HammerCLIKatello
9
- describe ContentUnitsCommand::InfoCommand do
10
- include ContentViewHelpers
11
- include RepositoryHelpers
12
- include ProductHelpers
13
- include OrganizationHelpers
14
-
15
- it 'allows minimal options' do
16
- api_expects(:generic_content_units, :show)
17
- .with_params('content_type' => 'python_package', 'id' => '1492')
18
-
19
- run_cmd(%w(content-units info --content-type python_package --id 1492))
20
- end
21
-
22
- it 'requires content_type param' do
23
- api_expects_no_call
24
-
25
- r = run_cmd(%w(content-units info --id 1492))
26
- assert(r.err.include?("Missing arguments for '--content-type'"), "Invalid error message")
27
- end
28
- end
29
- end