66"""
77import json
88import mock
9- import os
109import SoftLayer
1110
1211from SoftLayer .CLI import exceptions
@@ -29,21 +28,17 @@ def test_list_dedicated_hosts(self):
2928 'datacenter' : 'dal05' ,
3029 'diskCapacity' : 1200 ,
3130 'guestCount' : 1 ,
32- 'id' : 44701 ,
31+ 'id' : 12345 ,
3332 'memoryCapacity' : 242 ,
34- 'name' : 'khnguyendh '
33+ 'name' : 'test-dedicated '
3534 }]
3635 )
3736
38- def tear_down (self ):
39- if os .path .exists ("test.txt" ):
40- os .remove ("test.txt" )
41-
4237 def test_details (self ):
4338 mock = self .set_mock ('SoftLayer_Virtual_DedicatedHost' , 'getObject' )
4439 mock .return_value = SoftLayer_Virtual_DedicatedHost .getObjectById
4540
46- result = self .run_command (['dedicatedhost' , 'detail' , '44701 ' , '--price' , '--guests' ])
41+ result = self .run_command (['dedicatedhost' , 'detail' , '12345 ' , '--price' , '--guests' ])
4742 self .assert_no_fail (result )
4843
4944 self .assertEqual (json .loads (result .output ),
@@ -54,19 +49,19 @@ def test_details(self):
5449 'disk capacity' : 1200 ,
5550 'guest count' : 1 ,
5651 'guests' : [{
57- 'domain' : 'Softlayer .com' ,
58- 'hostname' : 'khnguyenDHI ' ,
59- 'id' : 43546081 ,
60- 'uuid' : '806a56ec-0383-4c2e-e6a9-7dc89c4b29a2 '
52+ 'domain' : 'test .com' ,
53+ 'hostname' : 'test-dedicated ' ,
54+ 'id' : 12345 ,
55+ 'uuid' : 'F9329795-4220-4B0A-B970-C86B950667FA '
6156 }],
62- 'id' : 44701 ,
57+ 'id' : 12345 ,
6358 'memory capacity' : 242 ,
6459 'modify date' : '2017-11-06T11:38:20-06:00' ,
65- 'name' : 'khnguyendh ' ,
66- 'owner' : '232298_khuong ' ,
60+ 'name' : 'test-dedicated ' ,
61+ 'owner' : 'test-dedicated ' ,
6762 'price_rate' : 1515.556 ,
6863 'router hostname' : 'bcr01a.dal05' ,
69- 'router id' : 51218 }
64+ 'router id' : 12345 }
7065 )
7166
7267 def test_details_no_owner (self ):
@@ -85,18 +80,18 @@ def test_details_no_owner(self):
8580 'disk capacity' : 1200 ,
8681 'guest count' : 1 ,
8782 'guests' : [{
88- 'domain' : 'Softlayer .com' ,
89- 'hostname' : 'khnguyenDHI ' ,
90- 'id' : 43546081 ,
91- 'uuid' : '806a56ec-0383-4c2e-e6a9-7dc89c4b29a2 ' }],
92- 'id' : 44701 ,
83+ 'domain' : 'test .com' ,
84+ 'hostname' : 'test-dedicated ' ,
85+ 'id' : 12345 ,
86+ 'uuid' : 'F9329795-4220-4B0A-B970-C86B950667FA ' }],
87+ 'id' : 12345 ,
9388 'memory capacity' : 242 ,
9489 'modify date' : '2017-11-06T11:38:20-06:00' ,
95- 'name' : 'khnguyendh ' ,
90+ 'name' : 'test-dedicated ' ,
9691 'owner' : None ,
9792 'price_rate' : 0 ,
9893 'router hostname' : 'bcr01a.dal05' ,
99- 'router id' : 51218 }
94+ 'router id' : 12345 }
10095 )
10196
10297 def test_create_options (self ):
@@ -159,29 +154,29 @@ def test_create(self):
159154 mock_package_obj .return_value = SoftLayer_Product_Package .getAllObjectsDH
160155
161156 result = self .run_command (['dedicatedhost' , 'create' ,
162- '--hostname=host ' ,
163- '--domain=example .com' ,
157+ '--hostname=test-dedicated ' ,
158+ '--domain=test .com' ,
164159 '--datacenter=dal05' ,
165160 '--flavor=56_CORES_X_242_RAM_X_1_4_TB' ,
166161 '--billing=hourly' ])
167162 self .assert_no_fail (result )
168163 args = ({
169164 'hardware' : [{
170- 'domain' : 'example .com' ,
165+ 'domain' : 'test .com' ,
171166 'primaryBackendNetworkComponent' : {
172167 'router' : {
173- 'id' : 51218
168+ 'id' : 12345
174169 }
175170 },
176- 'hostname' : 'host'
177- }],
178- 'prices' : [{
179- 'id' : 200269
171+ 'hostname' : 'test-dedicated'
180172 }],
173+ 'useHourlyPricing' : True ,
181174 'location' : 'DALLAS05' ,
182175 'packageId' : 813 ,
183176 'complexType' : 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost' ,
184- 'useHourlyPricing' : True ,
177+ 'prices' : [{
178+ 'id' : 200269
179+ }],
185180 'quantity' : 1 },)
186181
187182 self .assert_called_with ('SoftLayer_Product_Order' , 'placeOrder' ,
@@ -195,21 +190,21 @@ def test_create_with_gpu(self):
195190 mock_package_obj .return_value = SoftLayer_Product_Package .getAllObjectsDHGpu
196191
197192 result = self .run_command (['dedicatedhost' , 'create' ,
198- '--hostname=host ' ,
199- '--domain=example .com' ,
193+ '--hostname=test-dedicated ' ,
194+ '--domain=test .com' ,
200195 '--datacenter=dal05' ,
201196 '--flavor=56_CORES_X_484_RAM_X_1_5_TB_X_2_GPU_P100' ,
202197 '--billing=hourly' ])
203198 self .assert_no_fail (result )
204199 args = ({
205200 'hardware' : [{
206- 'domain' : 'example .com' ,
201+ 'domain' : 'test .com' ,
207202 'primaryBackendNetworkComponent' : {
208203 'router' : {
209- 'id' : 51218
204+ 'id' : 12345
210205 }
211206 },
212- 'hostname' : 'host '
207+ 'hostname' : 'test-dedicated '
213208 }],
214209 'prices' : [{
215210 'id' : 200269
@@ -233,8 +228,8 @@ def test_create_verify(self):
233228
234229 result = self .run_command (['dedicatedhost' , 'create' ,
235230 '--verify' ,
236- '--hostname=host ' ,
237- '--domain=example .com' ,
231+ '--hostname=test-dedicated ' ,
232+ '--domain=test .com' ,
238233 '--datacenter=dal05' ,
239234 '--flavor=56_CORES_X_242_RAM_X_1_4_TB' ,
240235 '--billing=hourly' ])
@@ -244,12 +239,12 @@ def test_create_verify(self):
244239 'useHourlyPricing' : True ,
245240 'hardware' : [{
246241
247- 'hostname' : 'host ' ,
248- 'domain' : 'example .com' ,
242+ 'hostname' : 'test-dedicated ' ,
243+ 'domain' : 'test .com' ,
249244
250245 'primaryBackendNetworkComponent' : {
251246 'router' : {
252- 'id' : 51218
247+ 'id' : 12345
253248 }
254249 }
255250 }],
@@ -263,8 +258,8 @@ def test_create_verify(self):
263258
264259 result = self .run_command (['dh' , 'create' ,
265260 '--verify' ,
266- '--hostname=host ' ,
267- '--domain=example .com' ,
261+ '--hostname=test-dedicated ' ,
262+ '--domain=test .com' ,
268263 '--datacenter=dal05' ,
269264 '--flavor=56_CORES_X_242_RAM_X_1_4_TB' ,
270265 '--billing=monthly' ])
@@ -273,11 +268,11 @@ def test_create_verify(self):
273268 args = ({
274269 'useHourlyPricing' : True ,
275270 'hardware' : [{
276- 'hostname' : 'host ' ,
277- 'domain' : 'example .com' ,
271+ 'hostname' : 'test-dedicated ' ,
272+ 'domain' : 'test .com' ,
278273 'primaryBackendNetworkComponent' : {
279274 'router' : {
280- 'id' : 51218
275+ 'id' : 12345
281276 }
282277 }
283278 }],
@@ -296,32 +291,15 @@ def test_create_aborted(self):
296291 mock_package_obj .return_value = SoftLayer_Product_Package .getAllObjectsDH
297292
298293 result = self .run_command (['dh' , 'create' ,
299- '--hostname=host ' ,
300- '--domain=example .com' ,
294+ '--hostname=test-dedicated ' ,
295+ '--domain=test .com' ,
301296 '--datacenter=dal05' ,
302297 '--flavor=56_CORES_X_242_RAM_X_1_4_TB' ,
303298 '--billing=monthly' ])
304299
305300 self .assertEqual (result .exit_code , 2 )
306301 self .assertIsInstance (result .exception , exceptions .CLIAbort )
307302
308- def test_create_export (self ):
309- mock_package_obj = self .set_mock ('SoftLayer_Product_Package' , 'getAllObjects' )
310- mock_package_obj .return_value = SoftLayer_Product_Package .getAllObjectsDH
311- mock_package = self .set_mock ('SoftLayer_Product_Order' , 'verifyOrder' )
312- mock_package .return_value = SoftLayer_Product_Package .verifyOrderDH
313-
314- self .run_command (['dedicatedhost' , 'create' ,
315- '--verify' ,
316- '--hostname=host' ,
317- '--domain=example.com' ,
318- '--datacenter=dal05' ,
319- '--flavor=56_CORES_X_242_RAM_X_1_4_TB' ,
320- '--billing=hourly' ,
321- '--export=test.txt' ])
322-
323- self .assertEqual (os .path .exists ("test.txt" ), True )
324-
325303 def test_create_verify_no_price_or_more_than_one (self ):
326304 mock_package_obj = self .set_mock ('SoftLayer_Product_Package' , 'getAllObjects' )
327305 mock_package_obj .return_value = SoftLayer_Product_Package .getAllObjectsDH
@@ -332,22 +310,22 @@ def test_create_verify_no_price_or_more_than_one(self):
332310
333311 result = self .run_command (['dedicatedhost' , 'create' ,
334312 '--verify' ,
335- '--hostname=host ' ,
336- '--domain=example .com' ,
313+ '--hostname=test-dedicated ' ,
314+ '--domain=test .com' ,
337315 '--datacenter=dal05' ,
338316 '--flavor=56_CORES_X_242_RAM_X_1_4_TB' ,
339317 '--billing=hourly' ])
340318
341319 self .assertIsInstance (result .exception , exceptions .ArgumentError )
342320 args = ({
343321 'hardware' : [{
344- 'domain' : 'example .com' ,
322+ 'domain' : 'test .com' ,
345323 'primaryBackendNetworkComponent' : {
346324 'router' : {
347- 'id' : 51218
325+ 'id' : 12345
348326 }
349327 },
350- 'hostname' : 'host '
328+ 'hostname' : 'test-dedicated '
351329 }],
352330 'prices' : [{
353331 'id' : 200269
0 commit comments