Skip to content

Commit 2bd5cee

Browse files
author
Yingchao Huang
committed
Update test cases
Minium update, Not all tests passed.
1 parent 258f5f7 commit 2bd5cee

7 files changed

Lines changed: 45 additions & 31 deletions

File tree

tests/CLI/modules/dedicatedhost_tests.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def test_details(self):
6161
'owner': 'test-dedicated',
6262
'price_rate': 1515.556,
6363
'router hostname': 'bcr01a.dal05',
64-
'router id': 12345}
64+
'router id': 12345,
65+
'tags': None}
6566
)
6667

6768
def test_details_no_owner(self):
@@ -91,7 +92,8 @@ def test_details_no_owner(self):
9192
'owner': None,
9293
'price_rate': 0,
9394
'router hostname': 'bcr01a.dal05',
94-
'router id': 12345}
95+
'router id': 12345,
96+
'tags': None}
9597
)
9698

9799
def test_create_options(self):
@@ -154,7 +156,7 @@ def test_create(self):
154156
mock_package_obj.return_value = SoftLayer_Product_Package.getAllObjectsDH
155157

156158
result = self.run_command(['dedicatedhost', 'create',
157-
'--hostname=test-dedicated',
159+
'--hostnames=test-dedicated',
158160
'--domain=test.com',
159161
'--datacenter=dal05',
160162
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
@@ -190,7 +192,7 @@ def test_create_with_gpu(self):
190192
mock_package_obj.return_value = SoftLayer_Product_Package.getAllObjectsDHGpu
191193

192194
result = self.run_command(['dedicatedhost', 'create',
193-
'--hostname=test-dedicated',
195+
'--hostnames=test-dedicated',
194196
'--domain=test.com',
195197
'--datacenter=dal05',
196198
'--flavor=56_CORES_X_484_RAM_X_1_5_TB_X_2_GPU_P100',
@@ -228,7 +230,7 @@ def test_create_verify(self):
228230

229231
result = self.run_command(['dedicatedhost', 'create',
230232
'--verify',
231-
'--hostname=test-dedicated',
233+
'--hostnames=test-dedicated',
232234
'--domain=test.com',
233235
'--datacenter=dal05',
234236
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
@@ -258,7 +260,7 @@ def test_create_verify(self):
258260

259261
result = self.run_command(['dh', 'create',
260262
'--verify',
261-
'--hostname=test-dedicated',
263+
'--hostnames=test-dedicated',
262264
'--domain=test.com',
263265
'--datacenter=dal05',
264266
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
@@ -291,7 +293,7 @@ def test_create_aborted(self):
291293
mock_package_obj.return_value = SoftLayer_Product_Package.getAllObjectsDH
292294

293295
result = self.run_command(['dh', 'create',
294-
'--hostname=test-dedicated',
296+
'--hostnames=test-dedicated',
295297
'--domain=test.com',
296298
'--datacenter=dal05',
297299
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',
@@ -310,7 +312,7 @@ def test_create_verify_no_price_or_more_than_one(self):
310312

311313
result = self.run_command(['dedicatedhost', 'create',
312314
'--verify',
313-
'--hostname=test-dedicated',
315+
'--hostnames=test-dedicated',
314316
'--domain=test.com',
315317
'--datacenter=dal05',
316318
'--flavor=56_CORES_X_242_RAM_X_1_4_TB',

tests/CLI/modules/server_tests.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def test_create_server_test_flag(self, verify_mock):
293293

294294
result = self.run_command(['--really', 'server', 'create',
295295
'--size=S1270_8GB_2X1TBSATA_NORAID',
296-
'--hostname=test',
296+
'--hostnames=test',
297297
'--domain=example.com',
298298
'--datacenter=TEST00',
299299
'--port-speed=100',
@@ -332,7 +332,7 @@ def test_create_server(self, order_mock):
332332

333333
result = self.run_command(['--really', 'server', 'create',
334334
'--size=S1270_8GB_2X1TBSATA_NORAID',
335-
'--hostname=test',
335+
'--hostnames=test',
336336
'--domain=example.com',
337337
'--datacenter=TEST00',
338338
'--port-speed=100',
@@ -350,7 +350,7 @@ def test_create_server_missing_required(self):
350350
# This is missing a required argument
351351
result = self.run_command(['server', 'create',
352352
# Note: no chassis id
353-
'--hostname=test',
353+
'--hostnames=test',
354354
'--domain=example.com',
355355
'--datacenter=TEST00',
356356
'--network=100',
@@ -366,7 +366,7 @@ def test_create_server_with_export(self, export_mock):
366366
self.skipTest("Test doesn't work in Windows")
367367
result = self.run_command(['--really', 'server', 'create',
368368
'--size=S1270_8GB_2X1TBSATA_NORAID',
369-
'--hostname=test',
369+
'--hostnames=test',
370370
'--domain=example.com',
371371
'--datacenter=TEST00',
372372
'--port-speed=100',
@@ -383,7 +383,7 @@ def test_create_server_with_export(self, export_mock):
383383
'datacenter': 'TEST00',
384384
'domain': 'example.com',
385385
'extra': (),
386-
'hostname': 'test',
386+
'hostnames': 'test',
387387
'key': (),
388388
'os': 'UBUNTU_12_64',
389389
'port_speed': 100,
@@ -392,7 +392,11 @@ def test_create_server_with_export(self, export_mock):
392392
'test': False,
393393
'no_public': True,
394394
'wait': None,
395-
'template': None},
395+
'template': None,
396+
'output_json': False,
397+
'subnet_private': None,
398+
'vlan_private': None,
399+
'quantity': 1,},
396400
exclude=['wait', 'test'])
397401

398402
def test_edit_server_userdata_and_file(self):

tests/CLI/modules/sshkey_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_add_by_option(self):
4141

4242
self.assert_no_fail(result)
4343
self.assertEqual(json.loads(result.output),
44-
"SSH key added: aa:bb:cc:dd")
44+
{'fingerprint': 'aa:bb:cc:dd', 'id': 1234, 'label': 'label'})
4545
self.assert_called_with('SoftLayer_Security_Ssh_Key', 'createObject',
4646
args=({'notes': 'my key',
4747
'key': mock_key,
@@ -55,7 +55,7 @@ def test_add_by_file(self):
5555

5656
self.assert_no_fail(result)
5757
self.assertEqual(json.loads(result.output),
58-
"SSH key added: aa:bb:cc:dd")
58+
{'fingerprint': 'aa:bb:cc:dd', 'id': 1234, 'label': 'label'})
5959
service = self.client['Security_Ssh_Key']
6060
mock_key = service.getObject()['key']
6161
self.assert_called_with('SoftLayer_Security_Ssh_Key', 'createObject',

tests/CLI/modules/subnet_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_detail(self):
3636
'private_ip': '10.0.1.2'
3737
}
3838
],
39-
'hardware': 'none',
39+
'hardware': [],
4040
'usable ips': 22
4141
},
4242
json.loads(result.output))

tests/CLI/modules/vs/vs_create_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_create(self, confirm_mock):
2020
result = self.run_command(['vs', 'create',
2121
'--cpu=2',
2222
'--domain=example.com',
23-
'--hostname=host',
23+
'--hostnames=host',
2424
'--os=UBUNTU_LATEST',
2525
'--memory=1',
2626
'--network=100',
@@ -441,7 +441,7 @@ def test_create_like_image(self, confirm_mock):
441441
'blockDeviceTemplateGroup': {'globalIdentifier': 'aaa1xxx1122233'},
442442
'networkComponents': [{'maxSpeed': 100}],
443443
'supplementalCreateObjectOptions': {'bootMode': None}},)
444-
self.assert_called_with('SoftLayer_Virtual_Guest', 'generateOrderTemplate', args=args)
444+
self.assert_called_with('SoftLayer_Virtual_Guest', 'generateOrderTemplate', args=args) #
445445

446446
@mock.patch('SoftLayer.CLI.formatting.confirm')
447447
def test_create_like_flavor(self, confirm_mock):

tests/managers/dedicated_host_tests.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,14 @@ def test_get_host(self):
7878
domain,
7979
uuid
8080
],
81-
guestCount
81+
guestCount,
82+
tagReferences[
83+
id,
84+
tag[
85+
name,
86+
id
87+
]
88+
]
8289
''')
8390
self.dedicated_host.host.getObject.assert_called_once_with(id=12345, mask=mask)
8491

@@ -116,13 +123,13 @@ def test_place_order(self):
116123
hourly = True
117124
flavor = '56_CORES_X_242_RAM_X_1_4_TB'
118125

119-
self.dedicated_host.place_order(hostname=hostname,
126+
self.dedicated_host.place_order(hostnames=[hostname],
120127
domain=domain,
121128
location=location,
122129
flavor=flavor,
123130
hourly=hourly)
124131

125-
create_dict.assert_called_once_with(hostname=hostname,
132+
create_dict.assert_called_once_with(hostnames=[hostname],
126133
router=None,
127134
domain=domain,
128135
datacenter=location,
@@ -167,13 +174,13 @@ def test_place_order_with_gpu(self):
167174
hourly = True
168175
flavor = '56_CORES_X_484_RAM_X_1_5_TB_X_2_GPU_P100'
169176

170-
self.dedicated_host.place_order(hostname=hostname,
177+
self.dedicated_host.place_order(hostnames=[hostname],
171178
domain=domain,
172179
location=location,
173180
flavor=flavor,
174181
hourly=hourly)
175182

176-
create_dict.assert_called_once_with(hostname=hostname,
183+
create_dict.assert_called_once_with(hostnames=[hostname],
177184
router=None,
178185
domain=domain,
179186
datacenter=location,
@@ -218,13 +225,13 @@ def test_verify_order(self):
218225
hourly = True
219226
flavor = '56_CORES_X_242_RAM_X_1_4_TB'
220227

221-
self.dedicated_host.verify_order(hostname=hostname,
228+
self.dedicated_host.verify_order(hostnames=[hostname],
222229
domain=domain,
223230
location=location,
224231
flavor=flavor,
225232
hourly=hourly)
226233

227-
create_dict.assert_called_once_with(hostname=hostname,
234+
create_dict.assert_called_once_with(hostnames=[hostname],
228235
router=None,
229236
domain=domain,
230237
datacenter=location,
@@ -248,7 +255,7 @@ def test_generate_create_dict_without_router(self):
248255
hourly = True
249256
flavor = '56_CORES_X_242_RAM_X_1_4_TB'
250257

251-
results = self.dedicated_host._generate_create_dict(hostname=hostname,
258+
results = self.dedicated_host._generate_create_dict(hostnames=[hostname],
252259
domain=domain,
253260
datacenter=location,
254261
flavor=flavor,
@@ -294,7 +301,7 @@ def test_generate_create_dict_with_router(self):
294301
flavor = '56_CORES_X_242_RAM_X_1_4_TB'
295302

296303
results = self.dedicated_host._generate_create_dict(
297-
hostname=hostname,
304+
hostnames=[hostname],
298305
router=router,
299306
domain=domain,
300307
datacenter=location,

tests/managers/hardware_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
MINIMAL_TEST_CREATE_ARGS = {
2020
'size': 'S1270_8GB_2X1TBSATA_NORAID',
21-
'hostname': 'unicorn',
21+
'hostnames': ['unicorn'],
2222
'domain': 'giggles.woo',
2323
'location': 'wdc01',
2424
'os': 'UBUNTU_14_64',
@@ -177,7 +177,7 @@ def test_generate_create_dict_no_regions(self):
177177
def test_generate_create_dict_invalid_size(self):
178178
args = {
179179
'size': 'UNKNOWN_SIZE',
180-
'hostname': 'unicorn',
180+
'hostnames': ['unicorn'],
181181
'domain': 'giggles.woo',
182182
'location': 'wdc01',
183183
'os': 'UBUNTU_14_64',
@@ -191,7 +191,7 @@ def test_generate_create_dict_invalid_size(self):
191191
def test_generate_create_dict(self):
192192
args = {
193193
'size': 'S1270_8GB_2X1TBSATA_NORAID',
194-
'hostname': 'unicorn',
194+
'hostnames': ['unicorn'],
195195
'domain': 'giggles.woo',
196196
'location': 'wdc01',
197197
'os': 'UBUNTU_14_64',
@@ -220,6 +220,7 @@ def test_generate_create_dict(self):
220220
'useHourlyPricing': True,
221221
'provisionScripts': ['http://example.com/script.php'],
222222
'sshKeys': [{'sshKeyIds': [10]}],
223+
'quantity': 1,
223224
}
224225

225226
data = self.hardware._generate_create_dict(**args)

0 commit comments

Comments
 (0)