|
8 | 8 |
|
9 | 9 | from SoftLayer.CLI import call_api |
10 | 10 | from SoftLayer.CLI import exceptions |
| 11 | +from SoftLayer import SoftLayerAPIError |
11 | 12 | from SoftLayer import testing |
12 | 13 |
|
13 | 14 | import pytest |
@@ -229,3 +230,37 @@ def test_parameters(self): |
229 | 230 | self.assert_no_fail(result) |
230 | 231 | self.assert_called_with('SoftLayer_Service', 'method', |
231 | 232 | args=('arg1', '1234')) |
| 233 | + |
| 234 | + def test_fixture_not_implemented(self): |
| 235 | + service = 'SoftLayer_Test' |
| 236 | + method = 'getTest' |
| 237 | + result = self.run_command(['call-api', service, method]) |
| 238 | + self.assertEqual(result.exit_code, 1) |
| 239 | + self.assert_called_with(service, method) |
| 240 | + self.assertIsInstance(result.exception, SoftLayerAPIError) |
| 241 | + output = '{} fixture is not implemented'.format(service) |
| 242 | + self.assertIn(output, result.exception.faultString) |
| 243 | + |
| 244 | + def test_fixture_not_implemented_method(self): |
| 245 | + call_service = 'SoftLayer_Account' |
| 246 | + call_method = 'getTest' |
| 247 | + result = self.run_command(['call-api', call_service, call_method]) |
| 248 | + self.assertEqual(result.exit_code, 1) |
| 249 | + self.assert_called_with(call_service, call_method) |
| 250 | + self.assertIsInstance(result.exception, SoftLayerAPIError) |
| 251 | + output = '%s::%s fixture is not implemented' % (call_service, call_method) |
| 252 | + self.assertIn(output, result.exception.faultString) |
| 253 | + |
| 254 | + def test_fixture_exception(self): |
| 255 | + call_service = 'SoftLayer_Account' |
| 256 | + call_method = 'getTest' |
| 257 | + result = self.run_command(['call-api', call_service, call_method]) |
| 258 | + try: |
| 259 | + self.assert_no_fail(result) |
| 260 | + except Exception as ex: |
| 261 | + print(ex) |
| 262 | + self.assertEqual(result.exit_code, 1) |
| 263 | + self.assert_called_with(call_service, call_method) |
| 264 | + self.assertIsInstance(result.exception, SoftLayerAPIError) |
| 265 | + output = '%s::%s fixture is not implemented' % (call_service, call_method) |
| 266 | + self.assertIn(output, result.exception.faultString) |
0 commit comments