def test_get_vnf_package_vnfd_with_valid_accept_headers( self, accept_headers, mock_vnf_by_id, mock_get_vnf_package_vnfd): mock_vnf_by_id.return_value = fakes.return_vnfpkg_obj() mock_get_vnf_package_vnfd.return_value = fakes.return_vnfd_data() req = fake_request.HTTPRequest.blank( '/vnf_packages/%s/vnfd' % constants.UUID) req.headers['Accept'] = accept_headers req.method = 'GET' resp = req.get_response(self.app) self.assertEqual(http_client.OK, resp.status_code)
def test_get_vnf_package_vnfd_failed_with_bad_request( self, mock_vnf_by_id, mock_get_vnf_package_vnfd): mock_vnf_by_id.return_value = fakes.return_vnfpkg_obj() mock_get_vnf_package_vnfd.return_value = fakes.return_vnfd_data() req = fake_request.HTTPRequest.blank( '/vnf_packages/%s/vnfd' % constants.UUID) req.headers['Accept'] = 'text/plain' req.method = 'GET' self.assertRaises(exc.HTTPBadRequest, self.controller.get_vnf_package_vnfd, req, constants.UUID)
def test_get_vnf_package_vnfd_for_content_type_text_plain(self, mock_vnf_by_id, mock_get_vnf_package_vnfd): mock_vnf_by_id.return_value = fakes.return_vnfpkg_obj() fake_vnfd_data = fakes.return_vnfd_data(multiple_yaml_files=False) mock_get_vnf_package_vnfd.return_value = fake_vnfd_data req = fake_request.HTTPRequest.blank( '/vnf_packages/%s/vnfd' % constants.UUID) req.headers['Accept'] = 'text/plain' req.method = 'GET' resp = req.get_response(self.app) self.assertEqual(http_client.OK, resp.status_code) self.assertEqual('text/plain', resp.content_type) self.assertEqual(fake_vnfd_data[list(fake_vnfd_data.keys())[0]], resp.text)