@@ -35,4 +35,130 @@ def test_redfish_provider_reboot
3535 to_return ( status : 200 , body : JSON . generate ( { } ) )
3636 assert @bmc . powerreboot
3737 end
38+
39+ def test_bootdevice_pxe_uses_patch_if_match
40+ # Test that bootdevice uses patch_if_match for PXE boot
41+ system_mock = mock ( 'system' )
42+
43+ system_mock . expects ( :patch_if_match ) . with (
44+ 'Boot' => {
45+ 'BootSourceOverrideTarget' => 'Pxe' ,
46+ 'BootSourceOverrideEnabled' => 'Once' ,
47+ }
48+ ) . returns ( true )
49+
50+ @bmc . expects ( :system ) . returns ( system_mock )
51+ @bmc . expects ( :powercycle ) . never
52+
53+ result = @bmc . bootdevice = { :device => 'pxe' , :reboot => false , :persistent => false }
54+ assert_not_nil result
55+ end
56+
57+ def test_bootdevice_disk_persistent_uses_patch_if_match
58+ # Test that bootdevice uses patch_if_match with persistent boot
59+ system_mock = mock ( 'system' )
60+
61+ system_mock . expects ( :patch_if_match ) . with (
62+ 'Boot' => {
63+ 'BootSourceOverrideTarget' => 'Hdd' ,
64+ 'BootSourceOverrideEnabled' => 'Enabled' ,
65+ }
66+ ) . returns ( true )
67+
68+ @bmc . expects ( :system ) . returns ( system_mock )
69+ @bmc . expects ( :powercycle ) . never
70+
71+ result = @bmc . bootdevice = { :device => 'disk' , :reboot => false , :persistent => true }
72+ assert_not_nil result
73+ end
74+
75+ def test_bootdevice_with_reboot
76+ # Test bootdevice with reboot option
77+ system_mock = mock ( 'system' )
78+
79+ system_mock . expects ( :patch_if_match ) . with (
80+ 'Boot' => {
81+ 'BootSourceOverrideTarget' => 'Pxe' ,
82+ 'BootSourceOverrideEnabled' => 'Enabled' ,
83+ }
84+ ) . returns ( true )
85+
86+ @bmc . expects ( :system ) . returns ( system_mock )
87+ @bmc . expects ( :powercycle ) . once
88+
89+ result = @bmc . bootdevice = { :device => 'pxe' , :reboot => true , :persistent => true }
90+ assert_not_nil result
91+ end
92+
93+ def test_bootpxe_calls_bootdevice
94+ # Test that convenience method bootpxe works
95+ system_mock = mock ( 'system' )
96+
97+ system_mock . expects ( :patch_if_match ) . with (
98+ 'Boot' => {
99+ 'BootSourceOverrideTarget' => 'Pxe' ,
100+ 'BootSourceOverrideEnabled' => 'Once' ,
101+ }
102+ ) . returns ( true )
103+
104+ @bmc . expects ( :system ) . returns ( system_mock )
105+ @bmc . expects ( :powercycle ) . never
106+
107+ result = @bmc . bootpxe ( false , false )
108+ assert_not_nil result
109+ end
110+
111+ def test_bootdisk_calls_bootdevice
112+ # Test that convenience method bootdisk works
113+ system_mock = mock ( 'system' )
114+
115+ system_mock . expects ( :patch_if_match ) . with (
116+ 'Boot' => {
117+ 'BootSourceOverrideTarget' => 'Hdd' ,
118+ 'BootSourceOverrideEnabled' => 'Once' ,
119+ }
120+ ) . returns ( true )
121+
122+ @bmc . expects ( :system ) . returns ( system_mock )
123+ @bmc . expects ( :powercycle ) . never
124+
125+ result = @bmc . bootdisk ( false , false )
126+ assert_not_nil result
127+ end
128+
129+ def test_bootbios_calls_bootdevice
130+ # Test that convenience method bootbios works
131+ system_mock = mock ( 'system' )
132+
133+ system_mock . expects ( :patch_if_match ) . with (
134+ 'Boot' => {
135+ 'BootSourceOverrideTarget' => 'BiosSetup' ,
136+ 'BootSourceOverrideEnabled' => 'Once' ,
137+ }
138+ ) . returns ( true )
139+
140+ @bmc . expects ( :system ) . returns ( system_mock )
141+ @bmc . expects ( :powercycle ) . never
142+
143+ result = @bmc . bootbios ( false , false )
144+ assert_not_nil result
145+ end
146+
147+ def test_bootcdrom_calls_bootdevice
148+ # Test that convenience method bootcdrom works
149+ system_mock = mock ( 'system' )
150+
151+ system_mock . expects ( :patch_if_match ) . with (
152+ 'Boot' => {
153+ 'BootSourceOverrideTarget' => 'Cd' ,
154+ 'BootSourceOverrideEnabled' => 'Once' ,
155+ }
156+ ) . returns ( true )
157+
158+ @bmc . expects ( :system ) . returns ( system_mock )
159+ @bmc . expects ( :powercycle ) . never
160+
161+ result = @bmc . bootcdrom ( false , false )
162+ assert_not_nil result
163+ end
38164end
0 commit comments