Skip to content

Commit ec04e85

Browse files
author
Khuong-Nguyen
committed
Fix unit tests
1 parent 058c5ed commit ec04e85

File tree

4 files changed

+99
-120
lines changed

4 files changed

+99
-120
lines changed

SoftLayer/fixtures/SoftLayer_Account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,11 @@
553553
'name': 'dal05'
554554
},
555555
'memoryCapacity': 242,
556-
'name': 'khnguyendh',
556+
'name': 'test-dedicated',
557557
'diskCapacity': 1200,
558558
'guestCount': 1,
559559
'cpuCount': 56,
560-
'id': 44701
560+
'id': 12345
561561
}]
562562

563563

SoftLayer/fixtures/SoftLayer_Virtual_DedicatedHost.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,57 +11,57 @@
1111

1212

1313
getAvailableRouters = [
14-
{'hostname': 'bcr01a.dal05', 'id': 51218},
15-
{'hostname': 'bcr02a.dal05', 'id': 83361},
16-
{'hostname': 'bcr03a.dal05', 'id': 122762},
17-
{'hostname': 'bcr04a.dal05', 'id': 147566}
14+
{'hostname': 'bcr01a.dal05', 'id': 12345},
15+
{'hostname': 'bcr02a.dal05', 'id': 12346},
16+
{'hostname': 'bcr03a.dal05', 'id': 12347},
17+
{'hostname': 'bcr04a.dal05', 'id': 12348}
1818
]
1919

2020
getObjectById = {
2121
'datacenter': {
22-
'id': 138124,
22+
'id': 12345,
2323
'name': 'dal05',
2424
'longName': 'Dallas 5'
2525
},
2626
'memoryCapacity': 242,
2727
'modifyDate': '2017-11-06T11:38:20-06:00',
28-
'name': 'khnguyendh',
28+
'name': 'test-dedicated',
2929
'diskCapacity': 1200,
3030
'backendRouter': {
31-
'domain': 'softlayer.com',
31+
'domain': 'test.com',
3232
'hostname': 'bcr01a.dal05',
33-
'id': 51218
33+
'id': 12345
3434
},
3535
'guestCount': 1,
3636
'cpuCount': 56,
3737
'guests': [{
38-
'domain': 'Softlayer.com',
39-
'hostname': 'khnguyenDHI',
40-
'id': 43546081,
41-
'uuid': '806a56ec-0383-4c2e-e6a9-7dc89c4b29a2'
38+
'domain': 'test.com',
39+
'hostname': 'test-dedicated',
40+
'id': 12345,
41+
'uuid': 'F9329795-4220-4B0A-B970-C86B950667FA'
4242
}],
4343
'billingItem': {
4444
'nextInvoiceTotalRecurringAmount': 1515.556,
4545
'orderItem': {
46-
'id': 263060473,
46+
'id': 12345,
4747
'order': {
4848
'status': 'APPROVED',
4949
'privateCloudOrderFlag': False,
5050
'modifyDate': '2017-11-02T11:42:50-07:00',
5151
'orderQuoteId': '',
52-
'userRecordId': 6908745,
52+
'userRecordId': 12345,
5353
'createDate': '2017-11-02T11:40:56-07:00',
5454
'impersonatingUserRecordId': '',
5555
'orderTypeId': 7,
5656
'presaleEventId': '',
5757
'userRecord': {
58-
'username': '232298_khuong'
58+
'username': 'test-dedicated'
5959
},
60-
'id': 20093269,
61-
'accountId': 232298
60+
'id': 12345,
61+
'accountId': 12345
6262
}
6363
},
64-
'id': 235379377,
64+
'id': 12345,
6565
'children': [
6666
{
6767
'nextInvoiceTotalRecurringAmount': 0.0,
@@ -73,6 +73,6 @@
7373
}
7474
]
7575
},
76-
'id': 44701,
76+
'id': 12345,
7777
'createDate': '2017-11-02T11:40:56-07:00'
7878
}

tests/CLI/modules/dedicatedhost_tests.py

Lines changed: 49 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,17 @@ def test_list_dedicated_hosts(self):
2929
'datacenter': 'dal05',
3030
'diskCapacity': 1200,
3131
'guestCount': 1,
32-
'id': 44701,
32+
'id': 12345,
3333
'memoryCapacity': 242,
34-
'name': 'khnguyendh'
34+
'name': 'test-dedicated'
3535
}]
3636
)
3737

38-
def tear_down(self):
39-
if os.path.exists("test.txt"):
40-
os.remove("test.txt")
41-
4238
def test_details(self):
4339
mock = self.set_mock('SoftLayer_Virtual_DedicatedHost', 'getObject')
4440
mock.return_value = SoftLayer_Virtual_DedicatedHost.getObjectById
4541

46-
result = self.run_command(['dedicatedhost', 'detail', '44701', '--price', '--guests'])
42+
result = self.run_command(['dedicatedhost', 'detail', '12345', '--price', '--guests'])
4743
self.assert_no_fail(result)
4844

4945
self.assertEqual(json.loads(result.output),
@@ -54,19 +50,19 @@ def test_details(self):
5450
'disk capacity': 1200,
5551
'guest count': 1,
5652
'guests': [{
57-
'domain': 'Softlayer.com',
58-
'hostname': 'khnguyenDHI',
59-
'id': 43546081,
60-
'uuid': '806a56ec-0383-4c2e-e6a9-7dc89c4b29a2'
53+
'domain': 'test.com',
54+
'hostname': 'test-dedicated',
55+
'id': 12345,
56+
'uuid': 'F9329795-4220-4B0A-B970-C86B950667FA'
6157
}],
62-
'id': 44701,
58+
'id': 12345,
6359
'memory capacity': 242,
6460
'modify date': '2017-11-06T11:38:20-06:00',
65-
'name': 'khnguyendh',
66-
'owner': '232298_khuong',
61+
'name': 'test-dedicated',
62+
'owner': 'test-dedicated',
6763
'price_rate': 1515.556,
6864
'router hostname': 'bcr01a.dal05',
69-
'router id': 51218}
65+
'router id': 12345}
7066
)
7167

7268
def test_details_no_owner(self):
@@ -85,18 +81,18 @@ def test_details_no_owner(self):
8581
'disk capacity': 1200,
8682
'guest count': 1,
8783
'guests': [{
88-
'domain': 'Softlayer.com',
89-
'hostname': 'khnguyenDHI',
90-
'id': 43546081,
91-
'uuid': '806a56ec-0383-4c2e-e6a9-7dc89c4b29a2'}],
92-
'id': 44701,
84+
'domain': 'test.com',
85+
'hostname': 'test-dedicated',
86+
'id': 12345,
87+
'uuid': 'F9329795-4220-4B0A-B970-C86B950667FA'}],
88+
'id': 12345,
9389
'memory capacity': 242,
9490
'modify date': '2017-11-06T11:38:20-06:00',
95-
'name': 'khnguyendh',
91+
'name': 'test-dedicated',
9692
'owner': None,
9793
'price_rate': 0,
9894
'router hostname': 'bcr01a.dal05',
99-
'router id': 51218}
95+
'router id': 12345}
10096
)
10197

10298
def test_create_options(self):
@@ -159,29 +155,29 @@ def test_create(self):
159155
mock_package_obj.return_value = SoftLayer_Product_Package.getAllObjectsDH
160156

161157
result = self.run_command(['dedicatedhost', 'create',
162-
'--hostname=host',
163-
'--domain=example.com',
158+
'--hostname=test-dedicated',
159+
'--domain=test.com',
164160
'--datacenter=dal05',
165161
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
166162
'--billing=hourly'])
167163
self.assert_no_fail(result)
168164
args = ({
169165
'hardware': [{
170-
'domain': 'example.com',
166+
'domain': 'test.com',
171167
'primaryBackendNetworkComponent': {
172168
'router': {
173-
'id': 51218
169+
'id': 12345
174170
}
175171
},
176-
'hostname': 'host'
177-
}],
178-
'prices': [{
179-
'id': 200269
172+
'hostname': 'test-dedicated'
180173
}],
174+
'useHourlyPricing': True,
181175
'location': 'DALLAS05',
182176
'packageId': 813,
183177
'complexType': 'SoftLayer_Container_Product_Order_Virtual_DedicatedHost',
184-
'useHourlyPricing': True,
178+
'prices': [{
179+
'id': 200269
180+
}],
185181
'quantity': 1},)
186182

187183
self.assert_called_with('SoftLayer_Product_Order', 'placeOrder',
@@ -195,21 +191,21 @@ def test_create_with_gpu(self):
195191
mock_package_obj.return_value = SoftLayer_Product_Package.getAllObjectsDHGpu
196192

197193
result = self.run_command(['dedicatedhost', 'create',
198-
'--hostname=host',
199-
'--domain=example.com',
194+
'--hostname=test-dedicated',
195+
'--domain=test.com',
200196
'--datacenter=dal05',
201197
'--flavor=56_CORES_X_484_RAM_X_1_5_TB_X_2_GPU_P100',
202198
'--billing=hourly'])
203199
self.assert_no_fail(result)
204200
args = ({
205201
'hardware': [{
206-
'domain': 'example.com',
202+
'domain': 'test.com',
207203
'primaryBackendNetworkComponent': {
208204
'router': {
209-
'id': 51218
205+
'id': 12345
210206
}
211207
},
212-
'hostname': 'host'
208+
'hostname': 'test-dedicated'
213209
}],
214210
'prices': [{
215211
'id': 200269
@@ -233,8 +229,8 @@ def test_create_verify(self):
233229

234230
result = self.run_command(['dedicatedhost', 'create',
235231
'--verify',
236-
'--hostname=host',
237-
'--domain=example.com',
232+
'--hostname=test-dedicated',
233+
'--domain=test.com',
238234
'--datacenter=dal05',
239235
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
240236
'--billing=hourly'])
@@ -244,12 +240,12 @@ def test_create_verify(self):
244240
'useHourlyPricing': True,
245241
'hardware': [{
246242

247-
'hostname': 'host',
248-
'domain': 'example.com',
243+
'hostname': 'test-dedicated',
244+
'domain': 'test.com',
249245

250246
'primaryBackendNetworkComponent': {
251247
'router': {
252-
'id': 51218
248+
'id': 12345
253249
}
254250
}
255251
}],
@@ -263,8 +259,8 @@ def test_create_verify(self):
263259

264260
result = self.run_command(['dh', 'create',
265261
'--verify',
266-
'--hostname=host',
267-
'--domain=example.com',
262+
'--hostname=test-dedicated',
263+
'--domain=test.com',
268264
'--datacenter=dal05',
269265
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
270266
'--billing=monthly'])
@@ -273,11 +269,11 @@ def test_create_verify(self):
273269
args = ({
274270
'useHourlyPricing': True,
275271
'hardware': [{
276-
'hostname': 'host',
277-
'domain': 'example.com',
272+
'hostname': 'test-dedicated',
273+
'domain': 'test.com',
278274
'primaryBackendNetworkComponent': {
279275
'router': {
280-
'id': 51218
276+
'id': 12345
281277
}
282278
}
283279
}],
@@ -296,32 +292,15 @@ def test_create_aborted(self):
296292
mock_package_obj.return_value = SoftLayer_Product_Package.getAllObjectsDH
297293

298294
result = self.run_command(['dh', 'create',
299-
'--hostname=host',
300-
'--domain=example.com',
295+
'--hostname=test-dedicated',
296+
'--domain=test.com',
301297
'--datacenter=dal05',
302298
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
303299
'--billing=monthly'])
304300

305301
self.assertEqual(result.exit_code, 2)
306302
self.assertIsInstance(result.exception, exceptions.CLIAbort)
307303

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-
325304
def test_create_verify_no_price_or_more_than_one(self):
326305
mock_package_obj = self.set_mock('SoftLayer_Product_Package', 'getAllObjects')
327306
mock_package_obj.return_value = SoftLayer_Product_Package.getAllObjectsDH
@@ -332,22 +311,22 @@ def test_create_verify_no_price_or_more_than_one(self):
332311

333312
result = self.run_command(['dedicatedhost', 'create',
334313
'--verify',
335-
'--hostname=host',
336-
'--domain=example.com',
314+
'--hostname=test-dedicated',
315+
'--domain=test.com',
337316
'--datacenter=dal05',
338317
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
339318
'--billing=hourly'])
340319

341320
self.assertIsInstance(result.exception, exceptions.ArgumentError)
342321
args = ({
343322
'hardware': [{
344-
'domain': 'example.com',
323+
'domain': 'test.com',
345324
'primaryBackendNetworkComponent': {
346325
'router': {
347-
'id': 51218
326+
'id': 12345
348327
}
349328
},
350-
'hostname': 'host'
329+
'hostname': 'test-dedicated'
351330
}],
352331
'prices': [{
353332
'id': 200269

0 commit comments

Comments
 (0)