Commit 5df293de authored by Romain Courteaud's avatar Romain Courteaud

erp5_json_rpc_api: test experiment

parent 9afbeb92
......@@ -25,6 +25,7 @@
#
##############################################################################
import base64
import binascii
import json
......
......@@ -45,40 +45,40 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class JsonRpcAPITestCase(ERP5TypeTestCase):
_type_id = NotImplemented # type: str
_open_api_schema = NotImplemented # type: str
_open_api_schema_content_type = 'application/json'
_public_api = True
"""
a
"""
class JsonRpcAPITestCase2(JsonRpcAPITestCase):
_type_id = 'JSON RPC API Test Service'
def afterSetUp(self):
open_api_type = self.portal.portal_types.newContent(
portal_type='Open API Type',
id=self._type_id,
text_content=self._open_api_schema,
self.portal.portal_types.newContent(
portal_type='JSON RPC API Type',
id=self._type_id
)
open_api_type.setContentType(self._open_api_schema_content_type, )
if self._public_api:
open_api_type.setTypeWorkflowList(['publication_workflow'])
web_service_tool_type = self.portal.portal_types['Web Service Tool']
web_service_tool_type.setTypeAllowedContentTypeList(
sorted(
set(web_service_tool_type.getTypeAllowedContentTypeList())
| set([self._type_id])))
self.tic()
self.connector = self.portal.portal_web_services.newContent(
portal_type=self._type_id,
title=self.id(),
)
if self._public_api:
self.connector.publish()
else:
self.connector.validate()
self.tic()
self._python_script_id_to_cleanup = []
def beforeTearDown(self):
self.abort()
self.tic()
connector_id_list = [
c.getId() for c in self.portal.portal_web_services.contentValues(
portal_type=self._type_id)
]
if connector_id_list:
self.portal.portal_web_services.manage_delObjects(connector_id_list)
if self.portal.portal_types.get(self._type_id):
self.portal.portal_types.manage_delObjects([self._type_id])
web_service_tool_type = self.portal.portal_types['Web Service Tool']
......@@ -86,12 +86,50 @@ class JsonRpcAPITestCase(ERP5TypeTestCase):
sorted(
set(web_service_tool_type.getTypeAllowedContentTypeList())
- set([self._type_id])))
self.tic()
"""
self.abort()
connector_id_list = [
c.getId() for c in self.portal.portal_web_services.contentValues(
portal_type=self._type_id)
]
if connector_id_list:
self.portal.portal_web_services.manage_delObjects(connector_id_list)
self.tic()
"""
def test_couscous(self):
ret = self.publish(self.connector.getPath(), user='ERP5TypeTestCase')
self.assertEqual(ret.getStatus(), 200)
self.assertEqual(ret.getHeader('content-type'), 'text/html; charset=utf-8')
self.assertIn(b'<html', ret.getBody())
"""
_type_id = NotImplemented # type: str
_open_api_schema = NotImplemented # type: str
_open_api_schema_content_type = 'application/json'
_public_api = True
def afterSetUp(self):
if self._public_api:
open_api_type.setTypeWorkflowList(['publication_workflow'])
self.tic()
self.connector = self.portal.portal_web_services.newContent(
portal_type=self._type_id,
title=self.id(),
)
if self._public_api:
self.connector.publish()
else:
self.connector.validate()
self.tic()
self._python_script_id_to_cleanup = []
def beforeTearDown(self):
skin_folder = self.portal.portal_skins['custom']
if self._python_script_id_to_cleanup:
......@@ -110,7 +148,7 @@ class JsonRpcAPITestCase(ERP5TypeTestCase):
self.tic()
self.portal.changeSkin(None)
"""
class OpenAPIPetStoreTestCase(JsonRpcAPITestCase):
_type_id = 'Test Pet Store Open API'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment