|
9 | 9 | import mock
|
10 | 10 |
|
11 | 11 | from SoftLayer.CLI import exceptions
|
| 12 | +from SoftLayer import SoftLayerAPIError |
12 | 13 | from SoftLayer import testing
|
13 | 14 |
|
14 | 15 |
|
@@ -42,6 +43,8 @@ def test_detail_vs(self):
|
42 | 43 | 'cores': 2,
|
43 | 44 | 'created': '2013-08-01 15:23:45',
|
44 | 45 | 'datacenter': 'TEST00',
|
| 46 | + 'dedicated_host': 'test-dedicated', |
| 47 | + 'dedicated_host_id': 37401, |
45 | 48 | 'hostname': 'vs-test1',
|
46 | 49 | 'domain': 'test.sftlyr.ws',
|
47 | 50 | 'fqdn': 'vs-test1.test.sftlyr.ws',
|
@@ -88,6 +91,24 @@ def test_detail_vs_empty_tag(self):
|
88 | 91 | ['example-tag'],
|
89 | 92 | )
|
90 | 93 |
|
| 94 | + def test_detail_vs_dedicated_host_not_found(self): |
| 95 | + ex = SoftLayerAPIError('SoftLayer_Exception', 'Not found') |
| 96 | + mock = self.set_mock('SoftLayer_Virtual_DedicatedHost', 'getObject') |
| 97 | + mock.side_effect = ex |
| 98 | + result = self.run_command(['vs', 'detail', '100']) |
| 99 | + self.assert_no_fail(result) |
| 100 | + self.assertEqual(json.loads(result.output)['dedicated_host_id'], 37401) |
| 101 | + self.assertIsNone(json.loads(result.output)['dedicated_host']) |
| 102 | + |
| 103 | + def test_detail_vs_no_dedicated_host_hostname(self): |
| 104 | + mock = self.set_mock('SoftLayer_Virtual_DedicatedHost', 'getObject') |
| 105 | + mock.return_value = {'this_is_a_fudged_Virtual_DedicatedHost': True, |
| 106 | + 'name_is_not_provided': ''} |
| 107 | + result = self.run_command(['vs', 'detail', '100']) |
| 108 | + self.assert_no_fail(result) |
| 109 | + self.assertEqual(json.loads(result.output)['dedicated_host_id'], 37401) |
| 110 | + self.assertIsNone(json.loads(result.output)['dedicated_host']) |
| 111 | + |
91 | 112 | def test_create_options(self):
|
92 | 113 | result = self.run_command(['vs', 'create-options'])
|
93 | 114 |
|
|
0 commit comments