hammer_cli_foreman 2.1.2 → 2.4.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/doc/release_notes.md +35 -4
- data/doc/testing.md +13 -0
- data/lib/hammer_cli_foreman.rb +0 -4
- data/lib/hammer_cli_foreman/architecture.rb +5 -5
- data/lib/hammer_cli_foreman/associating_commands.rb +4 -5
- data/lib/hammer_cli_foreman/auth.rb +4 -4
- data/lib/hammer_cli_foreman/bookmark.rb +6 -6
- data/lib/hammer_cli_foreman/command_extensions/ping.rb +10 -1
- data/lib/hammer_cli_foreman/command_extensions/status.rb +1 -1
- data/lib/hammer_cli_foreman/commands.rb +3 -1
- data/lib/hammer_cli_foreman/compute_profile.rb +5 -5
- data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +1 -0
- data/lib/hammer_cli_foreman/config_group.rb +5 -5
- data/lib/hammer_cli_foreman/host.rb +3 -2
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +17 -10
- data/lib/hammer_cli_foreman/location.rb +2 -0
- data/lib/hammer_cli_foreman/mail_notification.rb +2 -2
- data/lib/hammer_cli_foreman/model.rb +5 -5
- data/lib/hammer_cli_foreman/operating_system.rb +10 -9
- data/lib/hammer_cli_foreman/organization.rb +2 -0
- data/lib/hammer_cli_foreman/output/fields.rb +1 -1
- data/lib/hammer_cli_foreman/output/formatters.rb +1 -1
- data/lib/hammer_cli_foreman/ping.rb +20 -11
- data/lib/hammer_cli_foreman/references.rb +16 -0
- data/lib/hammer_cli_foreman/settings.rb +16 -2
- data/lib/hammer_cli_foreman/testing/api_expectations.rb +10 -0
- data/lib/hammer_cli_foreman/usergroup.rb +5 -5
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/minitest/coverage_reporter.rb +94 -0
- data/lib/minitest/hammer_coverage_plugin.rb +19 -0
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/functional/architecture_test.rb +49 -0
- data/test/functional/audit_test.rb +86 -63
- data/test/functional/bookmark_test.rb +20 -0
- data/test/functional/commands/list_test.rb +11 -11
- data/test/functional/compute_profile_test.rb +47 -2
- data/test/functional/config_group_test.rb +50 -0
- data/test/functional/filter_test.rb +114 -47
- data/test/functional/host_test.rb +105 -19
- data/test/functional/location_test.rb +134 -0
- data/test/functional/mail_notification_test.rb +20 -0
- data/test/functional/media_test.rb +130 -0
- data/test/functional/model_test.rb +50 -0
- data/test/functional/operating_system_test.rb +51 -0
- data/test/functional/organization_test.rb +52 -0
- data/test/functional/realm_test.rb +103 -0
- data/test/functional/role_test.rb +9 -12
- data/test/functional/settings_test.rb +78 -1
- data/test/functional/status_test.rb +79 -13
- data/test/functional/user_test.rb +39 -0
- data/test/functional/usergroup_test.rb +51 -0
- data/test/test_helper.rb +5 -2
- data/test/unit/api/interactive_basic_auth_test.rb +3 -1
- data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +2 -2
- data/test/unit/api/oauth/oauth_password_grant_test.rb +2 -2
- data/test/unit/api_test.rb +3 -4
- data/test/unit/apipie_resource_mock.rb +25 -4
- data/test/unit/architecture_test.rb +10 -1
- data/test/unit/bookmark_test.rb +99 -0
- data/test/unit/commands_test.rb +19 -19
- data/test/unit/common_parameter_test.rb +1 -1
- data/test/unit/compute_profile_test.rb +87 -0
- data/test/unit/config_group_test.rb +10 -0
- data/test/unit/dependency_resolver_test.rb +4 -4
- data/test/unit/exception_handler_test.rb +13 -13
- data/test/unit/helpers/command.rb +5 -5
- data/test/unit/helpers/resource_disabled.rb +2 -2
- data/test/unit/host_test.rb +1 -24
- data/test/unit/id_resolver_test.rb +23 -23
- data/test/unit/mail_notification_test.rb +53 -0
- data/test/unit/media_test.rb +1 -1
- data/test/unit/model_test.rb +10 -0
- data/test/unit/operating_system_test.rb +14 -1
- data/test/unit/option_builders_test.rb +49 -49
- data/test/unit/option_sources/id_params_test.rb +2 -2
- data/test/unit/option_sources/ids_params_test.rb +2 -2
- data/test/unit/output/formatters_test.rb +21 -21
- data/test/unit/param_filters_test.rb +17 -17
- data/test/unit/partition_table_test.rb +2 -2
- data/test/unit/role_test.rb +2 -2
- data/test/unit/sessions_test.rb +24 -24
- data/test/unit/settings_test.rb +4 -0
- data/test/unit/template_test.rb +1 -1
- data/test/unit/usergroup_test.rb +10 -0
- metadata +26 -7
- data/lib/hammer_cli_foreman/trend.rb +0 -47
- data/test/functional/trend_test.rb +0 -22
data/test/unit/media_test.rb
CHANGED
|
@@ -95,7 +95,7 @@ describe HammerCLIForeman::Medium do
|
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
with_params ["--id=1", "--new-name=medium_x", "--path=http://some.path/", "--operatingsystem-ids=1,2"] do
|
|
98
|
-
it_should_call_action :update, {'id' => '1', '
|
|
98
|
+
it_should_call_action :update, {'id' => '1', 'medium' => {'name' => 'medium_x', 'path' => 'http://some.path/', 'operatingsystem_ids' => ['1','2']}}
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
end
|
data/test/unit/model_test.rb
CHANGED
|
@@ -17,6 +17,8 @@ describe HammerCLIForeman::Model do
|
|
|
17
17
|
context "parameters" do
|
|
18
18
|
it_should_accept "no arguments"
|
|
19
19
|
it_should_accept_search_params
|
|
20
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
21
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
context "output" do
|
|
@@ -38,6 +40,8 @@ describe HammerCLIForeman::Model do
|
|
|
38
40
|
context "parameters" do
|
|
39
41
|
it_should_accept "id", ["--id=1"]
|
|
40
42
|
it_should_accept "name", ["--name=model"]
|
|
43
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
44
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
41
45
|
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
|
42
46
|
end
|
|
43
47
|
|
|
@@ -63,6 +67,8 @@ describe HammerCLIForeman::Model do
|
|
|
63
67
|
|
|
64
68
|
context "parameters" do
|
|
65
69
|
it_should_accept "name", ["--name=model", "--info=description", "--vendor-class=class", "--hardware-model=model"]
|
|
70
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
71
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
66
72
|
# it_should_fail_with "name missing", ["--info=description", "--vendor-class=class", "--hardware-model=model"]
|
|
67
73
|
# TODO: temporarily disabled, parameters are checked in the api
|
|
68
74
|
end
|
|
@@ -77,6 +83,8 @@ describe HammerCLIForeman::Model do
|
|
|
77
83
|
context "parameters" do
|
|
78
84
|
it_should_accept "name", ["--name=model"]
|
|
79
85
|
it_should_accept "id", ["--id=1"]
|
|
86
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
87
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
80
88
|
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
|
81
89
|
end
|
|
82
90
|
|
|
@@ -90,6 +98,8 @@ describe HammerCLIForeman::Model do
|
|
|
90
98
|
context "parameters" do
|
|
91
99
|
it_should_accept "name", ["--name=model", "--new-name=model2", "--info=description", "--vendor-class=class", "--hardware-model=model"]
|
|
92
100
|
it_should_accept "id", ["--id=1", "--new-name=model2", "--info=description", "--vendor-class=class", "--hardware-model=model"]
|
|
101
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
102
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
93
103
|
# it_should_fail_with "no params", []
|
|
94
104
|
# it_should_fail_with "name or id missing", ["--new-name=model2", "--info=description", "--vendor-class=class", "--hardware-model=model"]
|
|
95
105
|
# TODO: temporarily disabled, parameters are checked in the id resolver
|
|
@@ -18,6 +18,8 @@ describe HammerCLIForeman::OperatingSystem do
|
|
|
18
18
|
context "parameters" do
|
|
19
19
|
it_should_accept "no arguments"
|
|
20
20
|
it_should_accept_search_params
|
|
21
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
22
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
context "output" do
|
|
@@ -40,6 +42,8 @@ describe HammerCLIForeman::OperatingSystem do
|
|
|
40
42
|
context "parameters" do
|
|
41
43
|
it_should_accept "id", ["--id=1"]
|
|
42
44
|
it_should_accept "title", ["--title=Rhel 6.5"]
|
|
45
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
46
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
43
47
|
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
|
44
48
|
end
|
|
45
49
|
|
|
@@ -70,6 +74,8 @@ describe HammerCLIForeman::OperatingSystem do
|
|
|
70
74
|
|
|
71
75
|
context "parameters" do
|
|
72
76
|
it_should_accept "name, major, minor, family, release name", ["--name=media", "--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome"]
|
|
77
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
78
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
73
79
|
# it_should_fail_with "name missing", ["--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome"]
|
|
74
80
|
# TODO: temporarily disabled, parameters are checked in the api
|
|
75
81
|
end
|
|
@@ -87,6 +93,8 @@ describe HammerCLIForeman::OperatingSystem do
|
|
|
87
93
|
context "parameters" do
|
|
88
94
|
it_should_accept "id", ["--id=1"]
|
|
89
95
|
it_should_accept "title", ["--title=Rhel 6.5"]
|
|
96
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
97
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
90
98
|
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
|
91
99
|
# TODO: temporarily disabled, parameters are checked in the id resolver
|
|
92
100
|
end
|
|
@@ -102,6 +110,8 @@ describe HammerCLIForeman::OperatingSystem do
|
|
|
102
110
|
it_should_accept "id", ["--id=1"]
|
|
103
111
|
it_should_accept "title", ["--title=Rhel 6.5"]
|
|
104
112
|
it_should_accept "name, major, minor, family, release name", ["--id=83", "--name=os", "--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome"]
|
|
113
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
114
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
105
115
|
# it_should_fail_with "no params", []
|
|
106
116
|
# it_should_fail_with "label or id missing", ["--name=os", "--major=1", "--minor=2", "--family=Red Hat", "--release-name=awesome"]
|
|
107
117
|
# TODO: temporarily disabled, parameters are checked in the id resolver
|
|
@@ -126,6 +136,8 @@ describe HammerCLIForeman::OperatingSystem do
|
|
|
126
136
|
it_should_accept "name, value and os id", ["--name=domain", "--value=val", "--operatingsystem-id=1"]
|
|
127
137
|
it_should_accept "name, value and os title", ["--name=domain", "--value=val", "--operatingsystem=Rhel 6.5"]
|
|
128
138
|
it_should_accept "name, value, type and os id", ["--name=domain", "--value=val", "--parameter-type=string", "--operatingsystem-id=1"]
|
|
139
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
140
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
129
141
|
# it_should_fail_with "name missing", ["--value=val", "--operatingsystem-id=id"]
|
|
130
142
|
# it_should_fail_with "value missing", ["--name=name", "--operatingsystem-id=id"]
|
|
131
143
|
# it_should_fail_with "os id missing", ["--name=name", "--value=val"]
|
|
@@ -142,11 +154,12 @@ describe HammerCLIForeman::OperatingSystem do
|
|
|
142
154
|
context "parameters" do
|
|
143
155
|
it_should_accept "name and os id", ["--name=domain", "--operatingsystem-id=1"]
|
|
144
156
|
it_should_accept "name and os title", ["--name=domain", "--operatingsystem=Rhel 6.5"]
|
|
157
|
+
it_should_fail_with 'organization param', ['--organization-id=1']
|
|
158
|
+
it_should_fail_with 'location param', ['--location-id=1']
|
|
145
159
|
# it_should_fail_with "name missing", ["--operatingsystem-id=id"]
|
|
146
160
|
# it_should_fail_with "os id missing", ["--name=name"]
|
|
147
161
|
# TODO: temporarily disabled, parameters are checked in the id resolver
|
|
148
162
|
end
|
|
149
163
|
|
|
150
164
|
end
|
|
151
|
-
|
|
152
165
|
end
|
|
@@ -6,20 +6,20 @@ describe HammerCLIForeman::BuildParams do
|
|
|
6
6
|
let(:params) { HammerCLIForeman::BuildParams.new }
|
|
7
7
|
|
|
8
8
|
it "creates empty hash by default" do
|
|
9
|
-
params.to_hash.must_equal( {} )
|
|
9
|
+
_(params.to_hash).must_equal( {} )
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "can be prefonfigured" do
|
|
13
13
|
preconfigured_params = HammerCLIForeman::BuildParams.new(:expand => {:only => [:a, :b]}, :without => [:c, :d])
|
|
14
14
|
preconfigured_params.expand.including(:c, :d)
|
|
15
|
-
preconfigured_params.to_hash.must_equal( {:expand => {:only => [:a, :b], :including => [:c, :d]}, :without => [:c, :d]} )
|
|
15
|
+
_(preconfigured_params.to_hash).must_equal( {:expand => {:only => [:a, :b], :including => [:c, :d]}, :without => [:c, :d]} )
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
describe "without" do
|
|
19
19
|
|
|
20
20
|
it "sets :without" do
|
|
21
21
|
params.without(:organization_id, :location_id)
|
|
22
|
-
params.to_hash.must_equal( {:without => [:organization_id, :location_id]} )
|
|
22
|
+
_(params.to_hash).must_equal( {:without => [:organization_id, :location_id]} )
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
end
|
|
@@ -28,44 +28,44 @@ describe HammerCLIForeman::BuildParams do
|
|
|
28
28
|
|
|
29
29
|
it "can set expand all" do
|
|
30
30
|
params.expand(:all)
|
|
31
|
-
params.to_hash.must_equal( {:expand => {}} )
|
|
31
|
+
_(params.to_hash).must_equal( {:expand => {}} )
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "expands all by default" do
|
|
35
35
|
params.expand
|
|
36
|
-
params.to_hash.must_equal( {:expand => {}} )
|
|
36
|
+
_(params.to_hash).must_equal( {:expand => {}} )
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "can disable expansion" do
|
|
40
40
|
params.expand(:none)
|
|
41
|
-
params.to_hash.must_equal( {:expand => {:only => []}} )
|
|
41
|
+
_(params.to_hash).must_equal( {:expand => {:only => []}} )
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
describe "except" do
|
|
45
45
|
it "sets except field" do
|
|
46
46
|
params.expand.except(:organizations)
|
|
47
|
-
params.to_hash.must_equal( {:expand => {:except => [:organizations]}} )
|
|
47
|
+
_(params.to_hash).must_equal( {:expand => {:except => [:organizations]}} )
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
describe "including" do
|
|
52
52
|
it "sets including field" do
|
|
53
53
|
params.expand.including(:organizations)
|
|
54
|
-
params.to_hash.must_equal( {:expand => {:including => [:organizations]}} )
|
|
54
|
+
_(params.to_hash).must_equal( {:expand => {:including => [:organizations]}} )
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
describe "only" do
|
|
59
59
|
it "sets only field" do
|
|
60
60
|
params.expand.only(:organizations)
|
|
61
|
-
params.to_hash.must_equal( {:expand => {:only => [:organizations]}} )
|
|
61
|
+
_(params.to_hash).must_equal( {:expand => {:only => [:organizations]}} )
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
describe "primary" do
|
|
66
66
|
it "sets primary field" do
|
|
67
67
|
params.expand.primary(:organizations)
|
|
68
|
-
params.to_hash.must_equal( {:expand => {:primary => :organizations}} )
|
|
68
|
+
_(params.to_hash).must_equal( {:expand => {:primary => :organizations}} )
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
@@ -103,7 +103,7 @@ describe HammerCLIForeman::BuilderConfigurator do
|
|
|
103
103
|
let(:action) { resource.action(:index)}
|
|
104
104
|
|
|
105
105
|
it "adds no option builder" do
|
|
106
|
-
result_classes.must_equal []
|
|
106
|
+
_(result_classes).must_equal []
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -112,7 +112,7 @@ describe HammerCLIForeman::BuilderConfigurator do
|
|
|
112
112
|
let(:action) { resource.action(:show)}
|
|
113
113
|
|
|
114
114
|
it "adds searchable options builder" do
|
|
115
|
-
resource_names(builders_by_class(HammerCLIForeman::SearchablesOptionBuilder)).must_equal [:users]
|
|
115
|
+
_(resource_names(builders_by_class(HammerCLIForeman::SearchablesOptionBuilder))).must_equal [:users]
|
|
116
116
|
end
|
|
117
117
|
end
|
|
118
118
|
|
|
@@ -122,13 +122,13 @@ describe HammerCLIForeman::BuilderConfigurator do
|
|
|
122
122
|
let(:action) { resource.action(:show)}
|
|
123
123
|
|
|
124
124
|
it "adds searchable options builder" do
|
|
125
|
-
resource_names(builders_by_class(HammerCLIForeman::SearchablesOptionBuilder)).must_equal [:posts]
|
|
125
|
+
_(resource_names(builders_by_class(HammerCLIForeman::SearchablesOptionBuilder))).must_equal [:posts]
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
it "adds dependent searchable option builders" do
|
|
129
129
|
resources = resource_names(builders_by_class(HammerCLIForeman::DependentSearchablesOptionBuilder)).sort
|
|
130
130
|
expected = [:users]
|
|
131
|
-
resources.must_equal expected.sort
|
|
131
|
+
_(resources).must_equal expected.sort
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
end
|
|
@@ -162,7 +162,7 @@ describe HammerCLIForeman::ForemanOptionBuilder do
|
|
|
162
162
|
builder.stubs(:build).returns(options)
|
|
163
163
|
|
|
164
164
|
container.builders = [builder, builder]
|
|
165
|
-
container.build.must_equal options+options
|
|
165
|
+
_(container.build).must_equal options+options
|
|
166
166
|
end
|
|
167
167
|
|
|
168
168
|
it "passes build parameters to contained builders" do
|
|
@@ -183,13 +183,13 @@ describe HammerCLIForeman::ForemanOptionBuilder do
|
|
|
183
183
|
HammerCLIForeman::SearchablesOptionBuilder.new(api.resource(:users), FakeSearchables.new(["aaa", "bbb"]))
|
|
184
184
|
]
|
|
185
185
|
@build_options = {:expand => {:primary => false}}
|
|
186
|
-
option_switches.must_equal []
|
|
186
|
+
_(option_switches).must_equal []
|
|
187
187
|
end
|
|
188
188
|
|
|
189
189
|
it "can add custom searchable builder" do
|
|
190
190
|
container.builders = []
|
|
191
191
|
@build_options = {:expand => {:primary => :users}}
|
|
192
|
-
option_switches.must_equal [
|
|
192
|
+
_(option_switches).must_equal [
|
|
193
193
|
["--name"],
|
|
194
194
|
["--label"]
|
|
195
195
|
]
|
|
@@ -200,7 +200,7 @@ describe HammerCLIForeman::ForemanOptionBuilder do
|
|
|
200
200
|
HammerCLIForeman::SearchablesOptionBuilder.new(api.resource(:posts), FakeSearchables.new(["aaa", "bbb"]))
|
|
201
201
|
]
|
|
202
202
|
@build_options = {:expand => {:primary => :users}}
|
|
203
|
-
option_switches.must_equal [
|
|
203
|
+
_(option_switches).must_equal [
|
|
204
204
|
["--name"],
|
|
205
205
|
["--label"]
|
|
206
206
|
]
|
|
@@ -220,7 +220,7 @@ describe HammerCLIForeman::ForemanOptionBuilder do
|
|
|
220
220
|
|
|
221
221
|
it "does not filter searchable builders by default" do
|
|
222
222
|
@build_options = {:expand => {}}
|
|
223
|
-
option_switches.must_equal [
|
|
223
|
+
_(option_switches).must_equal [
|
|
224
224
|
["--user"],
|
|
225
225
|
["--user-label"],
|
|
226
226
|
["--user-id"],
|
|
@@ -232,7 +232,7 @@ describe HammerCLIForeman::ForemanOptionBuilder do
|
|
|
232
232
|
|
|
233
233
|
it "adds dependent searchable builders on explicit requirement" do
|
|
234
234
|
@build_options = {:expand => {:including => [:posts, :comments]}}
|
|
235
|
-
option_switches.must_equal [
|
|
235
|
+
_(option_switches).must_equal [
|
|
236
236
|
["--user"],
|
|
237
237
|
["--user-label"],
|
|
238
238
|
["--user-id"],
|
|
@@ -247,7 +247,7 @@ describe HammerCLIForeman::ForemanOptionBuilder do
|
|
|
247
247
|
|
|
248
248
|
it "filters dependent searchable builders on explicit requirement" do
|
|
249
249
|
@build_options = {:expand => {:except => [:users]}}
|
|
250
|
-
option_switches.must_equal [
|
|
250
|
+
_(option_switches).must_equal [
|
|
251
251
|
["--post"],
|
|
252
252
|
["--post-label"],
|
|
253
253
|
["--post-id"]
|
|
@@ -256,7 +256,7 @@ describe HammerCLIForeman::ForemanOptionBuilder do
|
|
|
256
256
|
|
|
257
257
|
it "specifies custom set of dependent searchable builders on explicit requirement" do
|
|
258
258
|
@build_options = {:expand => {:only => [:comments, :users]}}
|
|
259
|
-
option_switches.must_equal [
|
|
259
|
+
_(option_switches).must_equal [
|
|
260
260
|
["--user"],
|
|
261
261
|
["--user-label"],
|
|
262
262
|
["--user-id"],
|
|
@@ -285,33 +285,33 @@ describe HammerCLIForeman::SearchablesOptionBuilder do
|
|
|
285
285
|
let(:searchables) { FakeSearchables.new([]) }
|
|
286
286
|
|
|
287
287
|
it "builds no options for empty searchables" do
|
|
288
|
-
options.must_equal []
|
|
288
|
+
_(options).must_equal []
|
|
289
289
|
end
|
|
290
290
|
end
|
|
291
291
|
|
|
292
292
|
describe "multiple searchables" do
|
|
293
293
|
|
|
294
294
|
it "builds correct switches" do
|
|
295
|
-
options.map(&:switches).must_equal [["--name"], ["--label"]]
|
|
295
|
+
_(options.map(&:switches)).must_equal [["--name"], ["--label"]]
|
|
296
296
|
end
|
|
297
297
|
|
|
298
298
|
it "builds correct descriptions" do
|
|
299
|
-
options.map(&:description).must_equal ["Search by name", "Search by label"]
|
|
299
|
+
_(options.map(&:description)).must_equal ["Search by name", "Search by label"]
|
|
300
300
|
end
|
|
301
301
|
|
|
302
302
|
it "builds correct types" do
|
|
303
|
-
options.map(&:type).must_equal ["NAME", "LABEL"]
|
|
303
|
+
_(options.map(&:type)).must_equal ["NAME", "LABEL"]
|
|
304
304
|
end
|
|
305
305
|
|
|
306
306
|
it "builds correct attribute readers" do
|
|
307
|
-
options.map(&:read_method).must_equal [
|
|
307
|
+
_(options.map(&:read_method)).must_equal [
|
|
308
308
|
"option_name",
|
|
309
309
|
"option_label"
|
|
310
310
|
]
|
|
311
311
|
end
|
|
312
312
|
|
|
313
313
|
it "none of the options is required" do
|
|
314
|
-
options.any?{|opt| opt.required? }.must_equal false
|
|
314
|
+
_(options.any?{|opt| opt.required? }).must_equal false
|
|
315
315
|
end
|
|
316
316
|
end
|
|
317
317
|
end
|
|
@@ -335,14 +335,14 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
335
335
|
let(:searchables) { FakeSearchables.new([]) }
|
|
336
336
|
|
|
337
337
|
it "builds only id options" do
|
|
338
|
-
options.map(&:switches).must_equal [["--user-id"]]
|
|
338
|
+
_(options.map(&:switches)).must_equal [["--user-id"]]
|
|
339
339
|
end
|
|
340
340
|
end
|
|
341
341
|
|
|
342
342
|
describe "multiple searchables" do
|
|
343
343
|
|
|
344
344
|
it "creates correct switches" do
|
|
345
|
-
options.map(&:switches).must_equal [
|
|
345
|
+
_(options.map(&:switches)).must_equal [
|
|
346
346
|
["--user"], # first option does not have the suffix
|
|
347
347
|
["--user-label"], # other options with suffixes
|
|
348
348
|
["--user-uuid"],
|
|
@@ -351,7 +351,7 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
351
351
|
end
|
|
352
352
|
|
|
353
353
|
it "creates correct option types" do
|
|
354
|
-
options.map(&:type).must_equal [
|
|
354
|
+
_(options.map(&:type)).must_equal [
|
|
355
355
|
"USER_NAME",
|
|
356
356
|
"USER_LABEL",
|
|
357
357
|
"USER_UUID",
|
|
@@ -360,7 +360,7 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
360
360
|
end
|
|
361
361
|
|
|
362
362
|
it "creates correct descriptions" do
|
|
363
|
-
options.map(&:description).must_equal [
|
|
363
|
+
_(options.map(&:description)).must_equal [
|
|
364
364
|
"Search by name",
|
|
365
365
|
"Search by label",
|
|
366
366
|
"Search by uuid",
|
|
@@ -369,7 +369,7 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
369
369
|
end
|
|
370
370
|
|
|
371
371
|
it "creates correct attribute readers" do
|
|
372
|
-
options.map(&:read_method).must_equal [
|
|
372
|
+
_(options.map(&:read_method)).must_equal [
|
|
373
373
|
"option_user_name",
|
|
374
374
|
"option_user_label",
|
|
375
375
|
"option_user_uuid",
|
|
@@ -378,7 +378,7 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
378
378
|
end
|
|
379
379
|
|
|
380
380
|
it "none of the options is required" do
|
|
381
|
-
options.any?{|opt| opt.required? }.must_equal false
|
|
381
|
+
_(options.any?{|opt| opt.required? }).must_equal false
|
|
382
382
|
end
|
|
383
383
|
end
|
|
384
384
|
|
|
@@ -388,7 +388,7 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
388
388
|
let(:builder_params) { {:resource_mapping => {:user => :usr}} }
|
|
389
389
|
|
|
390
390
|
it "renames options" do
|
|
391
|
-
options.map(&:switches).must_equal [
|
|
391
|
+
_(options.map(&:switches)).must_equal [
|
|
392
392
|
["--usr"], # first option does not have the suffix
|
|
393
393
|
["--usr-label"], # other options with suffixes
|
|
394
394
|
["--usr-uuid"],
|
|
@@ -397,7 +397,7 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
397
397
|
end
|
|
398
398
|
|
|
399
399
|
it "renames option types" do
|
|
400
|
-
options.map(&:type).must_equal [
|
|
400
|
+
_(options.map(&:type)).must_equal [
|
|
401
401
|
"USR_NAME",
|
|
402
402
|
"USR_LABEL",
|
|
403
403
|
"USR_UUID",
|
|
@@ -406,7 +406,7 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
406
406
|
end
|
|
407
407
|
|
|
408
408
|
it "keeps option accessor the same" do
|
|
409
|
-
options.map(&:attribute_name).must_equal [
|
|
409
|
+
_(options.map(&:attribute_name)).must_equal [
|
|
410
410
|
"option_user_name",
|
|
411
411
|
"option_user_label",
|
|
412
412
|
"option_user_uuid",
|
|
@@ -418,7 +418,7 @@ describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
|
|
418
418
|
describe "resources with id parameter in show action" do
|
|
419
419
|
|
|
420
420
|
it "uses descriptions from the action" do
|
|
421
|
-
options.map(&:description).must_equal [
|
|
421
|
+
_(options.map(&:description)).must_equal [
|
|
422
422
|
"Search by name",
|
|
423
423
|
"Search by label",
|
|
424
424
|
"Search by uuid",
|
|
@@ -443,32 +443,32 @@ describe HammerCLIForeman::SearchablesUpdateOptionBuilder do
|
|
|
443
443
|
let(:searchables) { FakeSearchables.new([]) }
|
|
444
444
|
|
|
445
445
|
it "builds no options for empty searchables" do
|
|
446
|
-
options.must_equal []
|
|
446
|
+
_(options).must_equal []
|
|
447
447
|
end
|
|
448
448
|
end
|
|
449
449
|
|
|
450
450
|
describe "multiple searchables" do
|
|
451
451
|
|
|
452
452
|
it "builds correct switches" do
|
|
453
|
-
options.map(&:switches).must_equal [["--new-label"]]
|
|
453
|
+
_(options.map(&:switches)).must_equal [["--new-label"]]
|
|
454
454
|
end
|
|
455
455
|
|
|
456
456
|
it "builds correct descriptions" do
|
|
457
|
-
options.map(&:description).must_equal [" "]
|
|
457
|
+
_(options.map(&:description)).must_equal [" "]
|
|
458
458
|
end
|
|
459
459
|
|
|
460
460
|
it "builds correct types" do
|
|
461
|
-
options.map(&:type).must_equal ["NEW_LABEL"]
|
|
461
|
+
_(options.map(&:type)).must_equal ["NEW_LABEL"]
|
|
462
462
|
end
|
|
463
463
|
|
|
464
464
|
it "builds correct attribute readers" do
|
|
465
|
-
options.map(&:read_method).must_equal [
|
|
465
|
+
_(options.map(&:read_method)).must_equal [
|
|
466
466
|
"option_new_label"
|
|
467
467
|
]
|
|
468
468
|
end
|
|
469
469
|
|
|
470
470
|
it "none of the options is required" do
|
|
471
|
-
options.any?{|opt| opt.required? }.must_equal false
|
|
471
|
+
_(options.any?{|opt| opt.required? }).must_equal false
|
|
472
472
|
end
|
|
473
473
|
end
|
|
474
474
|
|
|
@@ -487,7 +487,7 @@ describe HammerCLIForeman::SearchablesUpdateOptionBuilder do
|
|
|
487
487
|
end
|
|
488
488
|
|
|
489
489
|
it "uses descriptions from the action" do
|
|
490
|
-
options.map(&:description).must_equal ["DESC"]
|
|
490
|
+
_(options.map(&:description)).must_equal ["DESC"]
|
|
491
491
|
end
|
|
492
492
|
end
|
|
493
493
|
end
|
|
@@ -504,11 +504,11 @@ describe HammerCLIForeman::IdOptionBuilder do
|
|
|
504
504
|
|
|
505
505
|
describe "resources with parameter :id in show action" do
|
|
506
506
|
it "creates options --id" do
|
|
507
|
-
options.map(&:switches).must_equal [["--id"]]
|
|
507
|
+
_(options.map(&:switches)).must_equal [["--id"]]
|
|
508
508
|
end
|
|
509
509
|
|
|
510
510
|
it "uses description from the :id param" do
|
|
511
|
-
options.map(&:description).must_equal ["DESC"]
|
|
511
|
+
_(options.map(&:description)).must_equal ["DESC"]
|
|
512
512
|
end
|
|
513
513
|
end
|
|
514
514
|
|
|
@@ -522,11 +522,11 @@ describe HammerCLIForeman::IdOptionBuilder do
|
|
|
522
522
|
end
|
|
523
523
|
|
|
524
524
|
it "creates options --id" do
|
|
525
|
-
options.map(&:switches).must_equal [["--id"]]
|
|
525
|
+
_(options.map(&:switches)).must_equal [["--id"]]
|
|
526
526
|
end
|
|
527
527
|
|
|
528
528
|
it "uses empty description" do
|
|
529
|
-
options.map(&:description).must_equal [" "]
|
|
529
|
+
_(options.map(&:description)).must_equal [" "]
|
|
530
530
|
end
|
|
531
531
|
end
|
|
532
532
|
|