Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SoftLayer/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def assert_called_with(self, service, method, **props):
def assert_no_fail(self, result):
"""Fail when a failing click result has an error"""
if result.exception:
print(result.output)
print(result.exception)
raise result.exception

self.assertEqual(result.exit_code, 0)
Expand Down
9 changes: 9 additions & 0 deletions SoftLayer/testing/xmlrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ def do_POST(self):
except UnicodeDecodeError:
self.wfile.write(response_body)

except (NotImplementedError, NameError) as ex:
self.send_response(200)
self.end_headers()
response = xmlrpc.client.Fault(404, str(ex))
response_body = xmlrpc.client.dumps(response,
allow_none=True,
methodresponse=True)
self.wfile.write(response_body.encode('utf-8'))

except SoftLayer.SoftLayerAPIError as ex:
self.send_response(200)
self.end_headers()
Expand Down
35 changes: 35 additions & 0 deletions tests/CLI/modules/call_api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from SoftLayer.CLI import call_api
from SoftLayer.CLI import exceptions
from SoftLayer import SoftLayerAPIError
from SoftLayer import testing

import pytest
Expand Down Expand Up @@ -229,3 +230,37 @@ def test_parameters(self):
self.assert_no_fail(result)
self.assert_called_with('SoftLayer_Service', 'method',
args=('arg1', '1234'))

def test_fixture_not_implemented(self):
service = 'SoftLayer_Test'
method = 'getTest'
result = self.run_command(['call-api', service, method])
self.assertEqual(result.exit_code, 1)
self.assert_called_with(service, method)
self.assertIsInstance(result.exception, SoftLayerAPIError)
output = '{} fixture is not implemented'.format(service)
self.assertIn(output, result.exception.faultString)

def test_fixture_not_implemented_method(self):
call_service = 'SoftLayer_Account'
call_method = 'getTest'
result = self.run_command(['call-api', call_service, call_method])
self.assertEqual(result.exit_code, 1)
self.assert_called_with(call_service, call_method)
self.assertIsInstance(result.exception, SoftLayerAPIError)
output = '%s::%s fixture is not implemented' % (call_service, call_method)
self.assertIn(output, result.exception.faultString)

def test_fixture_exception(self):
call_service = 'SoftLayer_Account'
call_method = 'getTest'
result = self.run_command(['call-api', call_service, call_method])
try:
self.assert_no_fail(result)
except Exception as ex:
print(ex)
self.assertEqual(result.exit_code, 1)
self.assert_called_with(call_service, call_method)
self.assertIsInstance(result.exception, SoftLayerAPIError)
output = '%s::%s fixture is not implemented' % (call_service, call_method)
self.assertIn(output, result.exception.faultString)