Merge "Show proper error message for non-existing vnf package"
This commit is contained in:
commit
e712c255d0
@ -326,3 +326,34 @@ class TestUploadVnfPackage(TestVnfPackage):
|
||||
self.upload_vnf_package.take_action, parsed_args)
|
||||
# Delete temporary folder
|
||||
shutil.rmtree(temp_dir)
|
||||
|
||||
def test_upload_vnf_package_failed_with_404_not_found(self):
|
||||
# Scenario in which vnf package is not found
|
||||
zip_file, temp_dir = _create_zip()
|
||||
arglist = [
|
||||
'dumy-id',
|
||||
"--path", zip_file
|
||||
]
|
||||
verifylist = [
|
||||
('path', zip_file),
|
||||
('vnf_package', 'dumy-id')
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.upload_vnf_package, arglist,
|
||||
verifylist)
|
||||
|
||||
error_message = "Can not find requested vnf package: dummy-id"
|
||||
body = {"itemNotFound": {"message": error_message, "code": 404}}
|
||||
url = self.url + '/vnfpkgm/v1/vnf_packages/dumy-id/package_content'
|
||||
|
||||
self.requests_mock.register_uri(
|
||||
'PUT', url, json=body,
|
||||
status_code=404)
|
||||
|
||||
exception = self.assertRaises(
|
||||
exceptions.TackerClientException,
|
||||
self.upload_vnf_package.take_action, parsed_args)
|
||||
|
||||
self.assertEqual(error_message, exception.message)
|
||||
# Delete temporary folder
|
||||
shutil.rmtree(temp_dir)
|
||||
|
@ -205,6 +205,10 @@ class ClientBase(object):
|
||||
action, method, body=body,
|
||||
content_type=self.content_type())
|
||||
|
||||
if ('application/json' in resp.headers.get('Content-Type',
|
||||
'application/json')):
|
||||
self.format = 'json'
|
||||
|
||||
status_code = resp.status_code
|
||||
if status_code in (requests.codes.ok,
|
||||
requests.codes.created,
|
||||
|
Loading…
Reference in New Issue
Block a user