hammer_cli_foreman 0.1.0 → 0.1.1
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.
Potentially problematic release.
This version of hammer_cli_foreman might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +12 -1
- data/doc/configuration.md +13 -0
- data/lib/hammer_cli_foreman.rb +3 -0
- data/lib/hammer_cli_foreman/architecture.rb +9 -9
- data/lib/hammer_cli_foreman/associating_commands.rb +57 -34
- data/lib/hammer_cli_foreman/commands.rb +188 -101
- data/lib/hammer_cli_foreman/common_parameter.rb +7 -10
- data/lib/hammer_cli_foreman/compute_resource.rb +8 -11
- data/lib/hammer_cli_foreman/domain.rb +14 -40
- data/lib/hammer_cli_foreman/environment.rb +10 -15
- data/lib/hammer_cli_foreman/exceptions.rb +4 -0
- data/lib/hammer_cli_foreman/fact.rb +5 -5
- data/lib/hammer_cli_foreman/host.rb +76 -132
- data/lib/hammer_cli_foreman/hostgroup.rb +26 -61
- data/lib/hammer_cli_foreman/id_resolver.rb +163 -0
- data/lib/hammer_cli_foreman/image.rb +14 -50
- data/lib/hammer_cli_foreman/location.rb +35 -17
- data/lib/hammer_cli_foreman/media.rb +9 -16
- data/lib/hammer_cli_foreman/model.rb +6 -8
- data/lib/hammer_cli_foreman/operating_system.rb +129 -63
- data/lib/hammer_cli_foreman/organization.rb +36 -16
- data/lib/hammer_cli_foreman/output/fields.rb +10 -2
- data/lib/hammer_cli_foreman/output/formatters.rb +44 -18
- data/lib/hammer_cli_foreman/parameter.rb +45 -41
- data/lib/hammer_cli_foreman/partition_table.rb +9 -12
- data/lib/hammer_cli_foreman/puppet_class.rb +14 -14
- data/lib/hammer_cli_foreman/references.rb +122 -0
- data/lib/hammer_cli_foreman/report.rb +3 -6
- data/lib/hammer_cli_foreman/searchables_option_builder.rb +99 -0
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +17 -13
- data/lib/hammer_cli_foreman/smart_proxy.rb +18 -28
- data/lib/hammer_cli_foreman/subnet.rb +12 -13
- data/lib/hammer_cli_foreman/template.rb +10 -19
- data/lib/hammer_cli_foreman/user.rb +9 -28
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/locale/hammer-cli-foreman.pot +828 -817
- data/test/unit/apipie_resource_mock.rb +33 -11
- data/test/unit/architecture_test.rb +7 -10
- data/test/unit/commands_test.rb +8 -9
- data/test/unit/common_parameter_test.rb +6 -8
- data/test/unit/compute_resource_test.rb +9 -12
- data/test/unit/data/1.5/foreman_api.json +14130 -0
- data/test/unit/domain_test.rb +19 -22
- data/test/unit/environment_test.rb +9 -11
- data/test/unit/fact_test.rb +5 -6
- data/test/unit/helpers/command.rb +115 -59
- data/test/unit/helpers/fake_searchables.rb +19 -0
- data/test/unit/host_test.rb +44 -33
- data/test/unit/hostgroup_test.rb +19 -26
- data/test/unit/id_resolver_test.rb +225 -0
- data/test/unit/image_test.rb +16 -18
- data/test/unit/location_test.rb +8 -10
- data/test/unit/media_test.rb +11 -13
- data/test/unit/model_test.rb +8 -10
- data/test/unit/operating_system_test.rb +23 -23
- data/test/unit/organization_test.rb +9 -10
- data/test/unit/output/formatters_test.rb +133 -20
- data/test/unit/partition_table_test.rb +12 -9
- data/test/unit/puppet_class_test.rb +3 -7
- data/test/unit/report_test.rb +3 -7
- data/test/unit/searchables_option_builder_test.rb +172 -0
- data/test/unit/smart_class_parameter_test.rb +5 -7
- data/test/unit/smart_proxy_test.rb +11 -12
- data/test/unit/subnet_test.rb +15 -16
- data/test/unit/template_test.rb +15 -12
- data/test/unit/test_helper.rb +1 -1
- data/test/unit/user_test.rb +9 -12
- metadata +536 -509
@@ -5,10 +5,10 @@ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
|
5
5
|
describe HammerCLIForeman::PartitionTable do
|
6
6
|
|
7
7
|
|
8
|
-
|
8
|
+
include CommandTestHelper
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
cmd.stubs(:
|
11
|
+
cmd.stubs(:get_identifier).returns(1)
|
12
12
|
|
13
13
|
::File.stubs(:read).returns("FILE_CONTENT")
|
14
14
|
end
|
@@ -39,7 +39,8 @@ describe HammerCLIForeman::PartitionTable do
|
|
39
39
|
context "parameters" do
|
40
40
|
it_should_accept "id", ["--id=1"]
|
41
41
|
it_should_accept "name", ["--name=ptable"]
|
42
|
-
|
42
|
+
|
43
|
+
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
43
44
|
end
|
44
45
|
|
45
46
|
context "output" do
|
@@ -67,7 +68,7 @@ describe HammerCLIForeman::PartitionTable do
|
|
67
68
|
context "parameters" do
|
68
69
|
it_should_accept "id", ["--id=1"]
|
69
70
|
it_should_accept "name", ["--name=ptable"]
|
70
|
-
it_should_fail_with "id or name missing", []
|
71
|
+
# it_should_fail_with "id or name missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
71
72
|
end
|
72
73
|
|
73
74
|
with_params ["--id=83"] do
|
@@ -91,8 +92,9 @@ describe HammerCLIForeman::PartitionTable do
|
|
91
92
|
|
92
93
|
context "parameters" do
|
93
94
|
it_should_accept "name, file, os family", ["--name=tpl", "--file=~/table.sh", "--os-family=RedHat"]
|
94
|
-
it_should_fail_with "name missing", ["--file=~/table.sh", "--os-family=RedHat"]
|
95
|
-
it_should_fail_with "file missing", ["--name=tpl", "--os-family=RedHat"]
|
95
|
+
# it_should_fail_with "name missing", ["--file=~/table.sh", "--os-family=RedHat"]
|
96
|
+
# it_should_fail_with "file missing", ["--name=tpl", "--os-family=RedHat"]
|
97
|
+
# TODO: temporarily disabled, parameters are checked in the api
|
96
98
|
end
|
97
99
|
|
98
100
|
with_params ["--name=ptable","--file=~/table.sh", "--os-family=RedHat"] do
|
@@ -109,11 +111,12 @@ describe HammerCLIForeman::PartitionTable do
|
|
109
111
|
context "parameters" do
|
110
112
|
it_should_accept "id, new-name, file, type, audit comment, os ids", ["--id=83", "--new-name=ptable","--file=~/table.sh", "--os-family=RedHat"]
|
111
113
|
it_should_accept "name, new-name, file, type, audit comment, os ids", ["--name=ptable", "--new-name=ptable2", "--file=~/table.sh", "--os-family=RedHat"]
|
112
|
-
it_should_fail_with "id and name missing", ["--new-name=ptable","--file=~/table.sh", "--os-family=RedHat"]
|
114
|
+
# it_should_fail_with "id and name missing", ["--new-name=ptable","--file=~/table.sh", "--os-family=RedHat"]
|
115
|
+
# TODO: temporarily disabled, parameters are checked in the id resolver
|
113
116
|
end
|
114
117
|
|
115
118
|
with_params ["--id=83", "--new-name=ptable","--file=~/table.sh", "--os-family=RedHat"] do
|
116
|
-
it_should_call_action :update, {'id' => '83', 'ptable' => {'name' => 'ptable', 'layout' => 'FILE_CONTENT', 'os_family' => 'RedHat'}}
|
119
|
+
it_should_call_action :update, {'id' => '83', 'name' => 'ptable', 'ptable' => {'name' => 'ptable', 'layout' => 'FILE_CONTENT', 'os_family' => 'RedHat'}}
|
117
120
|
end
|
118
121
|
|
119
122
|
end
|
@@ -126,7 +129,7 @@ describe HammerCLIForeman::PartitionTable do
|
|
126
129
|
context "parameters" do
|
127
130
|
it_should_accept "id", ["--id=1"]
|
128
131
|
it_should_accept "name", ["--name=ptable"]
|
129
|
-
it_should_fail_with "id or name missing", []
|
132
|
+
# it_should_fail_with "id or name missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
130
133
|
end
|
131
134
|
|
132
135
|
with_params ["--id=1"] do
|
@@ -4,11 +4,7 @@ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
|
4
4
|
|
5
5
|
describe HammerCLIForeman::PuppetClass do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
cmd.stubs(:name_to_id).returns(1)
|
11
|
-
end
|
7
|
+
include CommandTestHelper
|
12
8
|
|
13
9
|
context "ListCommand" do
|
14
10
|
|
@@ -37,7 +33,7 @@ describe HammerCLIForeman::PuppetClass do
|
|
37
33
|
|
38
34
|
context "parameters" do
|
39
35
|
it_should_accept "id", ["--id=1"]
|
40
|
-
it_should_fail_with "no arguments"
|
36
|
+
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
41
37
|
end
|
42
38
|
|
43
39
|
context "output" do
|
@@ -62,7 +58,7 @@ describe HammerCLIForeman::PuppetClass do
|
|
62
58
|
context "parameters" do
|
63
59
|
it_should_accept "name", ["--name=env"]
|
64
60
|
it_should_accept "id", ["--id=1"]
|
65
|
-
it_should_fail_with "name or id missing", []
|
61
|
+
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
66
62
|
end
|
67
63
|
|
68
64
|
end
|
data/test/unit/report_test.rb
CHANGED
@@ -4,11 +4,7 @@ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
|
4
4
|
|
5
5
|
describe HammerCLIForeman::Report do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
cmd.stubs(:name_to_id).returns(1)
|
11
|
-
end
|
7
|
+
include CommandTestHelper
|
12
8
|
|
13
9
|
context "ListCommand" do
|
14
10
|
|
@@ -43,7 +39,7 @@ describe HammerCLIForeman::Report do
|
|
43
39
|
|
44
40
|
context "parameters" do
|
45
41
|
it_should_accept "id", ["--id=1"]
|
46
|
-
it_should_fail_with "no arguments"
|
42
|
+
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
47
43
|
end
|
48
44
|
|
49
45
|
end
|
@@ -55,7 +51,7 @@ describe HammerCLIForeman::Report do
|
|
55
51
|
|
56
52
|
context "parameters" do
|
57
53
|
it_should_accept "id", ["--id=1"]
|
58
|
-
it_should_fail_with "
|
54
|
+
# it_should_fail_with "no params", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
59
55
|
end
|
60
56
|
|
61
57
|
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), 'helpers/fake_searchables')
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
describe HammerCLIForeman::SearchablesOptionBuilder do
|
7
|
+
|
8
|
+
let(:resource) { HammerCLIForeman.foreman_resource(:architectures) }
|
9
|
+
let(:searchables) { FakeSearchables.new(["name", "label"]) }
|
10
|
+
let(:builder) { HammerCLIForeman::SearchablesOptionBuilder.new(resource, searchables) }
|
11
|
+
let(:options) { builder.build }
|
12
|
+
|
13
|
+
describe "empty searchables" do
|
14
|
+
let(:searchables) { FakeSearchables.new([]) }
|
15
|
+
|
16
|
+
it "builds no options for empty searchables" do
|
17
|
+
options.must_equal []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "multiple searchables" do
|
22
|
+
|
23
|
+
it "builds correct switches" do
|
24
|
+
options.map(&:switches).must_equal [["--name"], ["--label"]]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "builds correct descriptions" do
|
28
|
+
options.map(&:description).must_equal ["Search by name", "Search by label"]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "builds correct types" do
|
32
|
+
options.map(&:type).must_equal ["NAME", "LABEL"]
|
33
|
+
end
|
34
|
+
|
35
|
+
it "builds correct attribute readers" do
|
36
|
+
options.map(&:read_method).must_equal [
|
37
|
+
"option_name",
|
38
|
+
"option_label"
|
39
|
+
]
|
40
|
+
end
|
41
|
+
|
42
|
+
it "none of the options is required" do
|
43
|
+
options.any?{|opt| opt.required? }.must_equal false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
describe HammerCLIForeman::DependentSearchablesOptionBuilder do
|
51
|
+
|
52
|
+
let(:resource) { HammerCLIForeman.foreman_resource(:architectures) }
|
53
|
+
let(:searchables) { FakeSearchables.new(["name", "label", "uuid"]) }
|
54
|
+
let(:builder) { HammerCLIForeman::DependentSearchablesOptionBuilder.new(resource, searchables) }
|
55
|
+
let(:options) { builder.build }
|
56
|
+
|
57
|
+
describe "empty searchables" do
|
58
|
+
|
59
|
+
let(:searchables) { FakeSearchables.new([]) }
|
60
|
+
|
61
|
+
it "builds only id options" do
|
62
|
+
options.map(&:switches).must_equal [["--architecture-id"]]
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
describe "multiple searchables" do
|
69
|
+
|
70
|
+
it "creates correct switches" do
|
71
|
+
options.map(&:switches).must_equal [
|
72
|
+
["--architecture"], # first option does not have the suffix
|
73
|
+
["--architecture-label"], # other options with suffixes
|
74
|
+
["--architecture-uuid"],
|
75
|
+
["--architecture-id"] # additional id
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "creates correct option types" do
|
80
|
+
options.map(&:type).must_equal [
|
81
|
+
"ARCHITECTURE_NAME",
|
82
|
+
"ARCHITECTURE_LABEL",
|
83
|
+
"ARCHITECTURE_UUID",
|
84
|
+
"ARCHITECTURE_ID",
|
85
|
+
]
|
86
|
+
end
|
87
|
+
|
88
|
+
it "creates correct attribute readers" do
|
89
|
+
options.map(&:read_method).must_equal [
|
90
|
+
"option_architecture_name",
|
91
|
+
"option_architecture_label",
|
92
|
+
"option_architecture_uuid",
|
93
|
+
"option_architecture_id",
|
94
|
+
]
|
95
|
+
end
|
96
|
+
|
97
|
+
it "none of the options is required" do
|
98
|
+
options.any?{|opt| opt.required? }.must_equal false
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
describe "multiple resources" do
|
104
|
+
|
105
|
+
let(:resource) { [
|
106
|
+
HammerCLIForeman.foreman_resource(:architectures),
|
107
|
+
HammerCLIForeman.foreman_resource(:domains)
|
108
|
+
] }
|
109
|
+
let(:searchables) { FakeSearchables.new(["name", "label"]) }
|
110
|
+
|
111
|
+
it "builds options for all resources" do
|
112
|
+
options.map(&:switches).must_equal [
|
113
|
+
["--architecture"], # first option does not have the suffix
|
114
|
+
["--architecture-label"], # other options with suffixes
|
115
|
+
["--architecture-id"], # additional id
|
116
|
+
["--domain"], # first option does not have the suffix
|
117
|
+
["--domain-label"], # other options with suffixes
|
118
|
+
["--domain-id"] # additional id
|
119
|
+
]
|
120
|
+
end
|
121
|
+
|
122
|
+
it "none of the options is required" do
|
123
|
+
options.any?{|opt| opt.required? }.must_equal false
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
describe HammerCLIForeman::SearchablesUpdateOptionBuilder do
|
132
|
+
|
133
|
+
let(:resource) { HammerCLIForeman.foreman_resource(:architectures) }
|
134
|
+
let(:searchables) { FakeSearchables.new(["name"], ["label"]) }
|
135
|
+
let(:builder) { HammerCLIForeman::SearchablesUpdateOptionBuilder.new(resource, searchables) }
|
136
|
+
let(:options) { builder.build }
|
137
|
+
|
138
|
+
describe "empty searchables" do
|
139
|
+
let(:searchables) { FakeSearchables.new([]) }
|
140
|
+
|
141
|
+
it "builds no options for empty searchables" do
|
142
|
+
options.must_equal []
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe "multiple searchables" do
|
147
|
+
|
148
|
+
it "builds correct switches" do
|
149
|
+
options.map(&:switches).must_equal [["--new-label"]]
|
150
|
+
end
|
151
|
+
|
152
|
+
it "builds correct descriptions" do
|
153
|
+
options.map(&:description).must_equal [" "]
|
154
|
+
end
|
155
|
+
|
156
|
+
it "builds correct types" do
|
157
|
+
options.map(&:type).must_equal ["NEW_LABEL"]
|
158
|
+
end
|
159
|
+
|
160
|
+
it "builds correct attribute readers" do
|
161
|
+
options.map(&:read_method).must_equal [
|
162
|
+
"option_new_label"
|
163
|
+
]
|
164
|
+
end
|
165
|
+
|
166
|
+
it "none of the options is required" do
|
167
|
+
options.any?{|opt| opt.required? }.must_equal false
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
end
|
@@ -4,11 +4,7 @@ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
|
4
4
|
|
5
5
|
describe HammerCLIForeman::SmartClassParameter do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
cmd.stubs(:name_to_id).returns(1)
|
11
|
-
end
|
7
|
+
include CommandTestHelper
|
12
8
|
|
13
9
|
context "ListCommand" do
|
14
10
|
|
@@ -53,7 +49,8 @@ describe HammerCLIForeman::SmartClassParameter do
|
|
53
49
|
context "parameters" do
|
54
50
|
it_should_accept "id", ["--id=1"]
|
55
51
|
it_should_accept "name", ["--name=param"]
|
56
|
-
it_should_fail_with "no arguments"
|
52
|
+
# it_should_fail_with "no arguments"
|
53
|
+
# TODO: temporarily disabled, parameters are checked in the id resolver
|
57
54
|
end
|
58
55
|
end
|
59
56
|
|
@@ -74,7 +71,8 @@ describe HammerCLIForeman::SmartClassParameter do
|
|
74
71
|
it_should_accept "parameter-type ", ["--id=1","--parameter-type=string"]
|
75
72
|
it_should_accept "required", ["--id=1","--required=true"]
|
76
73
|
|
77
|
-
it_should_fail_with "
|
74
|
+
# it_should_fail_with "no params", []
|
75
|
+
# TODO: temporarily disabled, parameters are checked in the id resolver
|
78
76
|
end
|
79
77
|
|
80
78
|
end
|
@@ -4,11 +4,7 @@ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
|
4
4
|
|
5
5
|
describe HammerCLIForeman::SmartProxy do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
cmd.stubs(:name_to_id).returns(1)
|
11
|
-
end
|
7
|
+
include CommandTestHelper
|
12
8
|
|
13
9
|
context "ListCommand" do
|
14
10
|
|
@@ -36,7 +32,7 @@ describe HammerCLIForeman::SmartProxy do
|
|
36
32
|
context "parameters" do
|
37
33
|
it_should_accept "id", ["--id=1"]
|
38
34
|
it_should_accept "name", ["--name=proxy"]
|
39
|
-
it_should_fail_with "no arguments"
|
35
|
+
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
40
36
|
end
|
41
37
|
|
42
38
|
context "output" do
|
@@ -55,8 +51,9 @@ describe HammerCLIForeman::SmartProxy do
|
|
55
51
|
|
56
52
|
context "parameters" do
|
57
53
|
it_should_accept "name and url", ["--name=proxy", "--url=localhost"]
|
58
|
-
it_should_fail_with "name missing", ["--url=
|
59
|
-
it_should_fail_with "url missing", ["--name=proxy"]
|
54
|
+
# it_should_fail_with "name missing", ["--url=localhost"]
|
55
|
+
# it_should_fail_with "url missing", ["--name=proxy"]
|
56
|
+
# TODO: temporarily disabled, parameters are checked in the api
|
60
57
|
end
|
61
58
|
|
62
59
|
end
|
@@ -69,7 +66,7 @@ describe HammerCLIForeman::SmartProxy do
|
|
69
66
|
context "parameters" do
|
70
67
|
it_should_accept "id", ["--id=1"]
|
71
68
|
it_should_accept "name", ["--name=proxy"]
|
72
|
-
it_should_fail_with "name or id missing", []
|
69
|
+
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
73
70
|
end
|
74
71
|
|
75
72
|
end
|
@@ -82,8 +79,9 @@ describe HammerCLIForeman::SmartProxy do
|
|
82
79
|
context "parameters" do
|
83
80
|
it_should_accept "id", ["--id=1", "--new-name=proxy2", "--url=localhost"]
|
84
81
|
it_should_accept "name", ["--name=proxy", "--new-name=proxy2", "--url=localhost"]
|
85
|
-
it_should_fail_with "no params", []
|
86
|
-
it_should_fail_with "name or id missing", ["--new-name=proxy2"]
|
82
|
+
# it_should_fail_with "no params", []
|
83
|
+
# it_should_fail_with "name or id missing", ["--new-name=proxy2"]
|
84
|
+
# TODO: temporarily disabled, parameters are checked in the id resolver
|
87
85
|
end
|
88
86
|
|
89
87
|
end
|
@@ -94,7 +92,8 @@ describe HammerCLIForeman::SmartProxy do
|
|
94
92
|
|
95
93
|
context "parameters" do
|
96
94
|
it_should_accept "id, environment-id and dryrun", ["--id=1", "--environment-id=1", "--dryrun"]
|
97
|
-
it_should_fail_with "id missing", [
|
95
|
+
# it_should_fail_with "id missing", []
|
96
|
+
# TODO: temporarily disabled, parameters are checked in the id resolver
|
98
97
|
end
|
99
98
|
|
100
99
|
end
|
data/test/unit/subnet_test.rb
CHANGED
@@ -4,11 +4,7 @@ require File.join(File.dirname(__FILE__), 'apipie_resource_mock')
|
|
4
4
|
|
5
5
|
describe HammerCLIForeman::Subnet do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
cmd.stubs(:name_to_id).returns(1)
|
11
|
-
end
|
7
|
+
include CommandTestHelper
|
12
8
|
|
13
9
|
context "ListCommand" do
|
14
10
|
|
@@ -36,17 +32,18 @@ describe HammerCLIForeman::Subnet do
|
|
36
32
|
context "parameters" do
|
37
33
|
it_should_accept "id", ["--id=1"]
|
38
34
|
it_should_accept "name", ["--name=arch"]
|
39
|
-
it_should_fail_with "no arguments"
|
35
|
+
# it_should_fail_with "no arguments" # TODO: temporarily disabled, parameters are checked in the id resolver
|
40
36
|
end
|
41
37
|
|
42
38
|
context "output" do
|
43
|
-
|
39
|
+
|
40
|
+
with_params ["--name=subnet"] do
|
44
41
|
it_should_print_n_records 1
|
45
42
|
it_should_print_columns ["Id", "Name", "Network", "Mask"]
|
46
43
|
it_should_print_columns ["Priority"]
|
47
|
-
it_should_print_columns ["DNS", "
|
48
|
-
it_should_print_columns ["
|
49
|
-
it_should_print_columns ["
|
44
|
+
it_should_print_columns ["DNS", "Primary DNS", "Secondary DNS"]
|
45
|
+
it_should_print_columns ["Domains", "TFTP", "DHCP"]
|
46
|
+
it_should_print_columns ["VLAN ID", "Gateway", "From", "To"]
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
@@ -59,9 +56,10 @@ describe HammerCLIForeman::Subnet do
|
|
59
56
|
|
60
57
|
context "parameters" do
|
61
58
|
it_should_accept "name", ["--name=arch", "--network=192.168.83.0", "--mask=255.255.255.0"]
|
62
|
-
it_should_fail_with "name missing", ["--network=192.168.83.0", "--mask=255.255.255.0"]
|
63
|
-
it_should_fail_with "network missing", ["--name=arch", "--mask=255.255.255.0"]
|
64
|
-
it_should_fail_with "mask missing", ["--name=arch", "--network=192.168.83.0"]
|
59
|
+
# it_should_fail_with "name missing", ["--network=192.168.83.0", "--mask=255.255.255.0"]
|
60
|
+
# it_should_fail_with "network missing", ["--name=arch", "--mask=255.255.255.0"]
|
61
|
+
# it_should_fail_with "mask missing", ["--name=arch", "--network=192.168.83.0"]
|
62
|
+
# TODO: temporarily disabled, parameters are checked in the api
|
65
63
|
end
|
66
64
|
|
67
65
|
end
|
@@ -74,7 +72,7 @@ describe HammerCLIForeman::Subnet do
|
|
74
72
|
context "parameters" do
|
75
73
|
it_should_accept "name", ["--name=arch"]
|
76
74
|
it_should_accept "id", ["--id=1"]
|
77
|
-
it_should_fail_with "name or id missing", []
|
75
|
+
# it_should_fail_with "name or id missing", [] # TODO: temporarily disabled, parameters are checked in the id resolver
|
78
76
|
end
|
79
77
|
|
80
78
|
end
|
@@ -87,8 +85,9 @@ describe HammerCLIForeman::Subnet do
|
|
87
85
|
context "parameters" do
|
88
86
|
it_should_accept "name", ["--name=arch", "--new-name=arch2"]
|
89
87
|
it_should_accept "id", ["--id=1", "--new-name=arch2"]
|
90
|
-
it_should_fail_with "no params", []
|
91
|
-
it_should_fail_with "name or id missing", ["--new-name=arch2"]
|
88
|
+
# it_should_fail_with "no params", []
|
89
|
+
# it_should_fail_with "name or id missing", ["--new-name=arch2"]
|
90
|
+
# TODO: temporarily disabled, parameters are checked in the id resolver
|
92
91
|
end
|
93
92
|
|
94
93
|
end
|