Commit 5144c256 authored by Jérome Perrin's avatar Jérome Perrin

test_result: use monaco to edit SlapOS parameters

( until we finalize the complete integration of SlapOS parameter
editor )
parent 7b4ed528
Pipeline #27690 passed with stage
in 0 seconds
from six.moves import urllib
import requests
from Products.ERP5Type.XMLObject import XMLObject from Products.ERP5Type.XMLObject import XMLObject
from DateTime import DateTime from DateTime import DateTime
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
...@@ -30,6 +33,36 @@ class TestSuite(XMLObject, PeriodicityMixin): ...@@ -30,6 +33,36 @@ class TestSuite(XMLObject, PeriodicityMixin):
return portal.portal_task_distribution.getMemcachedDict().get( return portal.portal_task_distribution.getMemcachedDict().get(
"%s_ping_date" % (self.getRelativeUrl())) "%s_ping_date" % (self.getRelativeUrl()))
security.declareProtected(
Permissions.AccessContentsInformation,
'getSlapOSInstanceParameterSchemaURL')
def getSlapOSInstanceParameterSchemaURL(self):
"""Return the URL of the schema to use for SlapOS parameters.
"""
for test_suite_repository in self.contentValues(
portal_type='Test Suite Repository'):
git_url = test_suite_repository.getGitUrl()
if git_url:
if git_url.endswith('/'):
git_url = git_url[:-1]
if git_url.endswith('.git'):
git_url = git_url[:-4]
software_json_url = "{git_url}/raw/{branch}/{profile_path}.json".format(
git_url=git_url,
branch=test_suite_repository.getBranch(),
profile_path=test_suite_repository.getProfilePath(),
)
try:
software_json = requests.get(software_json_url, timeout=5).json()
except ValueError:
return None
for software_type in ('RootSoftwareInstance', 'default'):
if software_type in software_json['software-type']:
return urllib.parse.urljoin(
software_json_url,
software_json['software-type'][software_type]['request'])
# Compatibility Code to be removed after 06/2018, since all instances using # Compatibility Code to be removed after 06/2018, since all instances using
# test suites should be migrated at that time. Purpose here was to fix the # test suites should be migrated at that time. Purpose here was to fix the
# setting of some properties that were defined with type "lines" instead of "string". # setting of some properties that were defined with type "lines" instead of "string".
......
...@@ -2,10 +2,23 @@ ...@@ -2,10 +2,23 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<global name="TextAreaField" module="Products.Formulator.StandardFields"/> <global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>css_class</string>
<string>description</string>
<string>gadget_url</string>
<string>js_sandbox</string>
<string>renderjs_extra</string>
<string>title</string>
</list>
</value>
</item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>my_cluster_configuration</string> </value> <value> <string>my_cluster_configuration</string> </value>
...@@ -16,23 +29,7 @@ ...@@ -16,23 +29,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>external_validator_failed</string> </key> <key> <string>external_validator_failed</string> </key>
<value> <string>Please use correct JSON syntax.</string> </value> <value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>line_too_long</string> </key>
<value> <string>A line was too long.</string> </value>
</item>
<item>
<key> <string>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>You entered too many characters.</string> </value>
</item>
<item>
<key> <string>too_many_lines</string> </key>
<value> <string>You entered too many lines.</string> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
...@@ -42,75 +39,11 @@ ...@@ -42,75 +39,11 @@
<value> <value>
<dictionary> <dictionary>
<item> <item>
<key> <string>alternate_name</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>required</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -120,78 +53,36 @@ ...@@ -120,78 +53,36 @@
<key> <string>tales</string> </key> <key> <string>tales</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>enabled</string> </key> <key> <string>form_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>external_validator</string> </key> <key> <string>gadget_url</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>extra</string> </key> <key> <string>js_sandbox</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>height</string> </key> <key> <string>renderjs_extra</string> </key>
<value> <string></string> </value> <value>
</item> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<item> </value>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_lines</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -199,90 +90,39 @@ ...@@ -199,90 +90,39 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>css_class</string> </key> <key> <string>css_class</string> </key>
<value> <string></string> </value> <value> <string>page</string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string>Slapos parameters.\n
\n
Configuration structure has to look like a python dict, ex:\n
\n
{\n
"x": "xxx",\n
"y":{\n
"q": "qqq",\n
"r": "rrr"\n
},\n
"z", "zzz"\n
}</string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>height</string> </key> <key> <string>field_id</string> </key>
<value> <int>10</int> </value> <value> <string>my_view_mode_text_content</string> </value>
</item> </item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>form_id</string> </key>
<value> <int>0</int> </value> <value> <string>Base_viewFieldLibrary</string> </value>
</item> </item>
<item> <item>
<key> <string>max_length</string> </key> <key> <string>gadget_url</string> </key>
<value> <string></string> </value> <value> <string>monaco-editor.gadget.html</string> </value>
</item>
<item>
<key> <string>max_linelength</string> </key>
<value> <int>80</int> </value>
</item> </item>
<item> <item>
<key> <string>max_lines</string> </key> <key> <string>js_sandbox</string> </key>
<value> <string></string> </value> <value> <string>iframe</string> </value>
</item> </item>
<item> <item>
<key> <string>required</string> </key> <key> <string>renderjs_extra</string> </key>
<value> <int>0</int> </value> <value>
<list/>
</value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Slapos Parameters</string> </value> <value> <string>SlapOS Parameters</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>80</int> </value>
</item> </item>
</dictionary> </dictionary>
</value> </value>
...@@ -292,13 +132,13 @@ Configuration structure has to look like a python dict, ex:\n ...@@ -292,13 +132,13 @@ Configuration structure has to look like a python dict, ex:\n
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle> <pickle>
<global name="Method" module="Products.Formulator.MethodField"/> <global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item> <item>
<key> <string>method_name</string> </key> <key> <string>_text</string> </key>
<value> <string>Base_validateJSON</string> </value> <value> <string>python: [(\'content_type\', \'application/json\'), (\'json_schema_url\', context.getSlapOSInstanceParameterSchemaURL())]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -1916,3 +1916,57 @@ class TestGitlabRESTConnectorInterface(ERP5TypeTestCase): ...@@ -1916,3 +1916,57 @@ class TestGitlabRESTConnectorInterface(ERP5TypeTestCase):
) )
self.test_result.start() self.test_result.start()
self.tic() self.tic()
class TestSlapOSParameterEditor(TaskDistributionTestCase):
def afterSetUp(self):
super(TestSlapOSParameterEditor, self).afterSetUp()
self.test_suite = self.portal.test_suite_module.newContent(
portal_type='Test Suite',
title=self.id(),
)
def test_getSlapOSInstanceParameterSchemaURL_empty(self):
with responses.RequestsMock():
self.assertIsNone(
self.test_suite.getSlapOSInstanceParameterSchemaURL())
def test_getSlapOSInstanceParameterSchemaURL_ok(self):
self.test_suite.newContent(
portal_type='Test Suite Repository',
branch='master',
git_url='https://lab.example.com/nexedi/test.git',
buildout_section_id='test',
profile_path='software-release/software.cfg')
with responses.RequestsMock() as rsps:
rsps.add(
responses.GET,
'https://lab.example.com/nexedi/test/raw/master/software-release/software.cfg.json',
json={
"serialisation": "json-in-xml",
"software-type": {
"default": {
"request": "instance-input-schema.json",
}
}
})
self.assertEqual(
self.test_suite.getSlapOSInstanceParameterSchemaURL(),
'https://lab.example.com/nexedi/test/raw/master/software-release/instance-input-schema.json'
)
def test_getSlapOSInstanceParameterSchemaURL_404(self):
self.test_suite.newContent(
portal_type='Test Suite Repository',
branch='master',
git_url='https://lab.example.com/nexedi/test.git',
buildout_section_id='test',
profile_path='software-release/software.cfg')
with responses.RequestsMock() as rsps:
rsps.add(
responses.GET,
'https://lab.example.com/nexedi/test/raw/master/software-release/software.cfg.json',
'not found')
self.assertIsNone(self.test_suite.getSlapOSInstanceParameterSchemaURL())
erp5_monaco_editor
erp5_project erp5_project
erp5_web_service erp5_web_service
\ No newline at end of file
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