hammer_cli_katello 0.1.3 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello.rb +1 -0
- data/lib/hammer_cli_katello/content_view.rb +1 -1
- data/lib/hammer_cli_katello/filter.rb +19 -0
- data/lib/hammer_cli_katello/filter_rule.rb +0 -10
- data/lib/hammer_cli_katello/host_extensions.rb +2 -0
- data/lib/hammer_cli_katello/id_name_options_validator.rb +73 -0
- data/lib/hammer_cli_katello/package.rb +2 -0
- data/lib/hammer_cli_katello/repository.rb +17 -5
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/functional/content_view/create_test.rb +0 -3
- data/test/functional/content_view/filter/delete_test.rb +93 -0
- data/test/functional/content_view/filter/info_test.rb +92 -0
- data/test/functional/content_view/filter/list_test.rb +98 -0
- data/test/functional/content_view/filter/update_test.rb +93 -0
- data/test/functional/filter_rule/create_test.rb +0 -79
- data/test/functional/host/extensions/data/host.json +4 -2
- data/test/functional/host/extensions/info_test.rb +3 -1
- data/test/functional/lifecycle_environment/create_test.rb +14 -0
- data/test/functional/lifecycle_environment/list_test.rb +38 -0
- data/test/functional/lifecycle_environment/update_test.rb +14 -0
- data/test/functional/organization/organization_helpers.rb +2 -2
- data/test/functional/package/list_test.rb +48 -0
- data/test/functional/repository/delete_test.rb +101 -0
- data/test/functional/repository/upload_test.rb +43 -0
- data/test/unit/id_name_options_validator_test.rb +96 -0
- metadata +26 -13
- data/test/functional/filter_rule/delete_test.rb +0 -104
- data/test/functional/filter_rule/info_test.rb +0 -104
- data/test/functional/filter_rule/list_test.rb +0 -91
- data/test/functional/filter_rule/update_test.rb +0 -104
@@ -95,4 +95,47 @@ describe 'upload repository' do
|
|
95
95
|
assert_equal(result.exit_code, 0)
|
96
96
|
File.delete("test.rpm")
|
97
97
|
end
|
98
|
+
|
99
|
+
it "supports globs" do
|
100
|
+
File.new("test.rpm", "w")
|
101
|
+
|
102
|
+
params = ["--id=#{repo_id}", "--path={test}.[r{1}]pm"]
|
103
|
+
|
104
|
+
ex = api_expects(:content_uploads, :create, "Create upload for content") do |par|
|
105
|
+
par[:repository_id] == repo_id.to_s
|
106
|
+
end
|
107
|
+
|
108
|
+
ex.returns(upload_response)
|
109
|
+
|
110
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload') do |par|
|
111
|
+
upload = {
|
112
|
+
:id => '1234',
|
113
|
+
:name => 'test.rpm',
|
114
|
+
:size => 0,
|
115
|
+
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
116
|
+
}
|
117
|
+
par[:id] == repo_id.to_s && par[:uploads] == [upload]
|
118
|
+
end
|
119
|
+
|
120
|
+
ex2.returns("")
|
121
|
+
|
122
|
+
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload") do |par|
|
123
|
+
par[:id] == upload_id && par[:repository_id] == repo_id.to_s
|
124
|
+
end
|
125
|
+
|
126
|
+
ex3.returns("")
|
127
|
+
|
128
|
+
result = run_cmd(@cmd + params)
|
129
|
+
assert_equal(result.exit_code, 0)
|
130
|
+
File.delete("test.rpm")
|
131
|
+
end
|
132
|
+
|
133
|
+
it "errors if there are no matching files" do
|
134
|
+
params = ["--id=#{repo_id}", "--path=#{path}"]
|
135
|
+
|
136
|
+
result = run_cmd(@cmd + params)
|
137
|
+
|
138
|
+
assert_equal "Could not find any files matching PATH\n", result.err
|
139
|
+
assert_equal HammerCLI::EX_NOINPUT, result.exit_code
|
140
|
+
end
|
98
141
|
end
|
@@ -0,0 +1,96 @@
|
|
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 |&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
|
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.
|
4
|
+
version: 0.2.0
|
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: 2016-
|
37
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
38
38
|
dependencies:
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: hammer_cli_foreman
|
@@ -196,14 +196,14 @@ dependencies:
|
|
196
196
|
requirements:
|
197
197
|
- - '='
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version: '0.
|
199
|
+
version: '0.42'
|
200
200
|
type: :development
|
201
201
|
prerelease: false
|
202
202
|
version_requirements: !ruby/object:Gem::Requirement
|
203
203
|
requirements:
|
204
204
|
- - '='
|
205
205
|
- !ruby/object:Gem::Version
|
206
|
-
version: '0.
|
206
|
+
version: '0.42'
|
207
207
|
- !ruby/object:Gem::Dependency
|
208
208
|
name: rubocop-checkstyle_formatter
|
209
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- lib/hammer_cli_katello/hostgroup.rb
|
256
256
|
- lib/hammer_cli_katello/hostgroup_extensions.rb
|
257
257
|
- lib/hammer_cli_katello/i18n.rb
|
258
|
+
- lib/hammer_cli_katello/id_name_options_validator.rb
|
258
259
|
- lib/hammer_cli_katello/id_resolver.rb
|
259
260
|
- lib/hammer_cli_katello/katello_environment_name_resolvable.rb
|
260
261
|
- lib/hammer_cli_katello/lifecycle_environment.rb
|
@@ -315,6 +316,10 @@ files:
|
|
315
316
|
- test/functional/content_view/content_view_helpers.rb
|
316
317
|
- test/functional/content_view/create_test.rb
|
317
318
|
- test/functional/content_view/filter/create_test.rb
|
319
|
+
- test/functional/content_view/filter/delete_test.rb
|
320
|
+
- test/functional/content_view/filter/info_test.rb
|
321
|
+
- test/functional/content_view/filter/list_test.rb
|
322
|
+
- test/functional/content_view/filter/update_test.rb
|
318
323
|
- test/functional/content_view/list_test.rb
|
319
324
|
- test/functional/content_view/publish_test.rb
|
320
325
|
- test/functional/content_view/puppet_module/add_test.rb
|
@@ -323,10 +328,6 @@ files:
|
|
323
328
|
- test/functional/content_view/version/list_test.rb
|
324
329
|
- test/functional/content_view/version/promote_test.rb
|
325
330
|
- test/functional/filter_rule/create_test.rb
|
326
|
-
- test/functional/filter_rule/delete_test.rb
|
327
|
-
- test/functional/filter_rule/info_test.rb
|
328
|
-
- test/functional/filter_rule/list_test.rb
|
329
|
-
- test/functional/filter_rule/update_test.rb
|
330
331
|
- test/functional/host/errata/apply_test.rb
|
331
332
|
- test/functional/host/extensions/data/host.json
|
332
333
|
- test/functional/host/extensions/data/host_list.json
|
@@ -354,8 +355,12 @@ files:
|
|
354
355
|
- test/functional/hostgroup/data/hostgroup.json
|
355
356
|
- test/functional/hostgroup/info_test.rb
|
356
357
|
- test/functional/hostgroup/update_test.rb
|
358
|
+
- test/functional/lifecycle_environment/create_test.rb
|
357
359
|
- test/functional/lifecycle_environment/lifecycle_environment_helpers.rb
|
360
|
+
- test/functional/lifecycle_environment/list_test.rb
|
361
|
+
- test/functional/lifecycle_environment/update_test.rb
|
358
362
|
- test/functional/organization/organization_helpers.rb
|
363
|
+
- test/functional/package/list_test.rb
|
359
364
|
- test/functional/ping_test.rb
|
360
365
|
- test/functional/product/create_test.rb
|
361
366
|
- test/functional/product/delete_test.rb
|
@@ -365,6 +370,7 @@ files:
|
|
365
370
|
- test/functional/product/remove_sync_plan_test.rb
|
366
371
|
- test/functional/product/set_sync_plan_test.rb
|
367
372
|
- test/functional/product/update_test.rb
|
373
|
+
- test/functional/repository/delete_test.rb
|
368
374
|
- test/functional/repository/info_test.rb
|
369
375
|
- test/functional/repository/list_test.rb
|
370
376
|
- test/functional/repository/remove_content_test.rb
|
@@ -376,6 +382,7 @@ files:
|
|
376
382
|
- test/functional/test_helper.rb
|
377
383
|
- test/task_helper.rb
|
378
384
|
- test/test_helper.rb
|
385
|
+
- test/unit/id_name_options_validator_test.rb
|
379
386
|
- test/unit/id_resolver_test.rb
|
380
387
|
- test/unit/search_options_creators_test.rb
|
381
388
|
homepage: http://github.com/theforeman/hammer-cli-katello
|
@@ -398,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
398
405
|
version: '0'
|
399
406
|
requirements: []
|
400
407
|
rubyforge_project:
|
401
|
-
rubygems_version: 2.4.
|
408
|
+
rubygems_version: 2.4.8
|
402
409
|
signing_key:
|
403
410
|
specification_version: 4
|
404
411
|
summary: Katello commands for Hammer
|
@@ -426,6 +433,10 @@ test_files:
|
|
426
433
|
- test/functional/content_view/content_view_helpers.rb
|
427
434
|
- test/functional/content_view/create_test.rb
|
428
435
|
- test/functional/content_view/filter/create_test.rb
|
436
|
+
- test/functional/content_view/filter/delete_test.rb
|
437
|
+
- test/functional/content_view/filter/info_test.rb
|
438
|
+
- test/functional/content_view/filter/list_test.rb
|
439
|
+
- test/functional/content_view/filter/update_test.rb
|
429
440
|
- test/functional/content_view/list_test.rb
|
430
441
|
- test/functional/content_view/publish_test.rb
|
431
442
|
- test/functional/content_view/puppet_module/add_test.rb
|
@@ -434,10 +445,6 @@ test_files:
|
|
434
445
|
- test/functional/content_view/version/list_test.rb
|
435
446
|
- test/functional/content_view/version/promote_test.rb
|
436
447
|
- test/functional/filter_rule/create_test.rb
|
437
|
-
- test/functional/filter_rule/delete_test.rb
|
438
|
-
- test/functional/filter_rule/info_test.rb
|
439
|
-
- test/functional/filter_rule/list_test.rb
|
440
|
-
- test/functional/filter_rule/update_test.rb
|
441
448
|
- test/functional/host/errata/apply_test.rb
|
442
449
|
- test/functional/host/extensions/data/host.json
|
443
450
|
- test/functional/host/extensions/data/host_list.json
|
@@ -465,8 +472,12 @@ test_files:
|
|
465
472
|
- test/functional/hostgroup/data/hostgroup.json
|
466
473
|
- test/functional/hostgroup/info_test.rb
|
467
474
|
- test/functional/hostgroup/update_test.rb
|
475
|
+
- test/functional/lifecycle_environment/create_test.rb
|
468
476
|
- test/functional/lifecycle_environment/lifecycle_environment_helpers.rb
|
477
|
+
- test/functional/lifecycle_environment/list_test.rb
|
478
|
+
- test/functional/lifecycle_environment/update_test.rb
|
469
479
|
- test/functional/organization/organization_helpers.rb
|
480
|
+
- test/functional/package/list_test.rb
|
470
481
|
- test/functional/ping_test.rb
|
471
482
|
- test/functional/product/create_test.rb
|
472
483
|
- test/functional/product/delete_test.rb
|
@@ -476,6 +487,7 @@ test_files:
|
|
476
487
|
- test/functional/product/remove_sync_plan_test.rb
|
477
488
|
- test/functional/product/set_sync_plan_test.rb
|
478
489
|
- test/functional/product/update_test.rb
|
490
|
+
- test/functional/repository/delete_test.rb
|
479
491
|
- test/functional/repository/info_test.rb
|
480
492
|
- test/functional/repository/list_test.rb
|
481
493
|
- test/functional/repository/remove_content_test.rb
|
@@ -487,5 +499,6 @@ test_files:
|
|
487
499
|
- test/functional/test_helper.rb
|
488
500
|
- test/task_helper.rb
|
489
501
|
- test/test_helper.rb
|
502
|
+
- test/unit/id_name_options_validator_test.rb
|
490
503
|
- test/unit/id_resolver_test.rb
|
491
504
|
- test/unit/search_options_creators_test.rb
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
require 'hammer_cli_katello/filter_rule'
|
3
|
-
|
4
|
-
module HammerCLIKatello
|
5
|
-
describe FilterRule::DeleteCommand do
|
6
|
-
it 'allows minimal options' do
|
7
|
-
api_expects(:content_view_filter_rules, :destroy) do |p|
|
8
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
9
|
-
end
|
10
|
-
run_cmd(%w(content-view filter rule delete --content-view-filter-id 1 --id 9))
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'resolves rule ID from rule name and filter ID' do
|
14
|
-
ex = api_expects(:content_view_filter_rules, :index) do |p|
|
15
|
-
p['content_view_filter_id'] == 1 && p['name'] == 'rule9'
|
16
|
-
end
|
17
|
-
ex.returns(index_response([{'id' => 9}]))
|
18
|
-
|
19
|
-
api_expects(:content_view_filter_rules, :destroy) do |p|
|
20
|
-
p['content_view_filter_id'] == 1 && p['id'] == 9
|
21
|
-
end
|
22
|
-
run_cmd(%w(content-view filter rule delete --content-view-filter-id 1 --name rule9))
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'allows name resolution of filter with content-view-id' do
|
26
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
27
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
28
|
-
end
|
29
|
-
ex.returns(index_response([{'id' => 1}]))
|
30
|
-
|
31
|
-
api_expects(:content_view_filter_rules, :destroy) do |p|
|
32
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
33
|
-
end
|
34
|
-
run_cmd(%w(content-view filter rule delete --content-view-filter cvf1 --content-view-id 3
|
35
|
-
--id 9))
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'organization' do
|
39
|
-
it 'ID can be specified to resolve content view name' do
|
40
|
-
ex = api_expects(:content_views, :index) do |p|
|
41
|
-
p['name'] == 'cv3' && p['organization_id'] == '6'
|
42
|
-
end
|
43
|
-
ex.returns(index_response([{'id' => 3}]))
|
44
|
-
|
45
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
46
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
47
|
-
end
|
48
|
-
ex.returns(index_response([{'id' => 1}]))
|
49
|
-
|
50
|
-
api_expects(:content_view_filter_rules, :destroy) do |p|
|
51
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
52
|
-
end
|
53
|
-
run_cmd(%w(content-view filter rule delete --content-view-filter cvf1 --organization-id 6
|
54
|
-
--content-view cv3 --id 9))
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'name can be specified to resolve content view name' do
|
58
|
-
ex = api_expects(:organizations, :index) do |p|
|
59
|
-
p[:search] == "name = \"org6\""
|
60
|
-
end
|
61
|
-
ex.returns(index_response([{'id' => 6}]))
|
62
|
-
|
63
|
-
ex = api_expects(:content_views, :index) do |p|
|
64
|
-
p['name'] == 'cv3' && p['organization_id'] == 6
|
65
|
-
end
|
66
|
-
ex.returns(index_response([{'id' => 3}]))
|
67
|
-
|
68
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
69
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
70
|
-
end
|
71
|
-
ex.returns(index_response([{'id' => 1}]))
|
72
|
-
|
73
|
-
api_expects(:content_view_filter_rules, :destroy) do |p|
|
74
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
75
|
-
end
|
76
|
-
run_cmd(%w(content-view filter rule delete --content-view-filter cvf1 --organization org6
|
77
|
-
--content-view cv3 --id 9))
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'label can be specified to resolve content view name' do
|
81
|
-
ex = api_expects(:organizations, :index) do |p|
|
82
|
-
p[:search] == "label = \"org6\""
|
83
|
-
end
|
84
|
-
ex.returns(index_response([{'id' => 6}]))
|
85
|
-
|
86
|
-
ex = api_expects(:content_views, :index) do |p|
|
87
|
-
p['name'] == 'cv3' && p['organization_id'] == 6
|
88
|
-
end
|
89
|
-
ex.returns(index_response([{'id' => 3}]))
|
90
|
-
|
91
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
92
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
93
|
-
end
|
94
|
-
ex.returns(index_response([{'id' => 1}]))
|
95
|
-
|
96
|
-
api_expects(:content_view_filter_rules, :destroy) do |p|
|
97
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
98
|
-
end
|
99
|
-
run_cmd(%w(content-view filter rule delete --content-view-filter cvf1 --organization-label
|
100
|
-
org6 --content-view cv3 --id 9))
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
require_relative '../test_helper'
|
2
|
-
require 'hammer_cli_katello/filter_rule'
|
3
|
-
|
4
|
-
module HammerCLIKatello
|
5
|
-
describe FilterRule::InfoCommand do
|
6
|
-
it 'allows minimal options' do
|
7
|
-
api_expects(:content_view_filter_rules, :show) do |p|
|
8
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
9
|
-
end
|
10
|
-
run_cmd(%w(content-view filter rule info --content-view-filter-id 1 --id 9))
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'resolves rule ID from rule name and filter ID' do
|
14
|
-
ex = api_expects(:content_view_filter_rules, :index) do |p|
|
15
|
-
p['content_view_filter_id'] == 1 && p['name'] == 'rule9'
|
16
|
-
end
|
17
|
-
ex.returns(index_response([{'id' => 9}]))
|
18
|
-
|
19
|
-
api_expects(:content_view_filter_rules, :show) do |p|
|
20
|
-
p['content_view_filter_id'] == 1 && p['id'] == 9
|
21
|
-
end
|
22
|
-
run_cmd(%w(content-view filter rule info --content-view-filter-id 1 --name rule9))
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'allows name resolution of filter with content-view-id' do
|
26
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
27
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
28
|
-
end
|
29
|
-
ex.returns(index_response([{'id' => 1}]))
|
30
|
-
|
31
|
-
api_expects(:content_view_filter_rules, :show) do |p|
|
32
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
33
|
-
end
|
34
|
-
run_cmd(%w(content-view filter rule info --content-view-filter cvf1 --content-view-id 3
|
35
|
-
--id 9))
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'organization' do
|
39
|
-
it 'ID can be specified to resolve content view name' do
|
40
|
-
ex = api_expects(:content_views, :index) do |p|
|
41
|
-
p['name'] == 'cv3' && p['organization_id'] == '6'
|
42
|
-
end
|
43
|
-
ex.returns(index_response([{'id' => 3}]))
|
44
|
-
|
45
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
46
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
47
|
-
end
|
48
|
-
ex.returns(index_response([{'id' => 1}]))
|
49
|
-
|
50
|
-
api_expects(:content_view_filter_rules, :show) do |p|
|
51
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
52
|
-
end
|
53
|
-
run_cmd(%w(content-view filter rule info --content-view-filter cvf1 --organization-id 6
|
54
|
-
--content-view cv3 --id 9))
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'name can be specified to resolve content view name' do
|
58
|
-
ex = api_expects(:organizations, :index) do |p|
|
59
|
-
p[:search] == "name = \"org6\""
|
60
|
-
end
|
61
|
-
ex.returns(index_response([{'id' => 6}]))
|
62
|
-
|
63
|
-
ex = api_expects(:content_views, :index) do |p|
|
64
|
-
p['name'] == 'cv3' && p['organization_id'] == 6
|
65
|
-
end
|
66
|
-
ex.returns(index_response([{'id' => 3}]))
|
67
|
-
|
68
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
69
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
70
|
-
end
|
71
|
-
ex.returns(index_response([{'id' => 1}]))
|
72
|
-
|
73
|
-
api_expects(:content_view_filter_rules, :show) do |p|
|
74
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
75
|
-
end
|
76
|
-
run_cmd(%w(content-view filter rule info --content-view-filter cvf1 --organization org6
|
77
|
-
--content-view cv3 --id 9))
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'label can be specified to resolve content view name' do
|
81
|
-
ex = api_expects(:organizations, :index) do |p|
|
82
|
-
p[:search] == "label = \"org6\""
|
83
|
-
end
|
84
|
-
ex.returns(index_response([{'id' => 6}]))
|
85
|
-
|
86
|
-
ex = api_expects(:content_views, :index) do |p|
|
87
|
-
p['name'] == 'cv3' && p['organization_id'] == 6
|
88
|
-
end
|
89
|
-
ex.returns(index_response([{'id' => 3}]))
|
90
|
-
|
91
|
-
ex = api_expects(:content_view_filters, :index) do |p|
|
92
|
-
p['name'] == 'cvf1' && p['content_view_id'] == 3
|
93
|
-
end
|
94
|
-
ex.returns(index_response([{'id' => 1}]))
|
95
|
-
|
96
|
-
api_expects(:content_view_filter_rules, :show) do |p|
|
97
|
-
p['content_view_filter_id'] == 1 && p['id'] == '9'
|
98
|
-
end
|
99
|
-
run_cmd(%w(content-view filter rule info --content-view-filter cvf1 --organization-label
|
100
|
-
org6 --content-view cv3 --id 9))
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|