Commit 00fab753 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Periodically test coverage with a CodingStyle test

    Check if all python scripts and ZSQL Method is present on at least a Test Component.

    This is far from perfect, but at least it gives an overview on what is untested.

    This tests replaces the python script for the same purpose ERP5Site_testPythonScriptTestCoverage
parent a225fb6c
portal = context.getPortalObject()
content_dict = {}
for test_component in portal.portal_components.searchFolder(portal_type='Test Component'):
if "Slap" not in test_component.getId():
continue
content_dict[test_component.getId()] = test_component.getTextContent()
print len(content_dict)
for skin_folder in portal.portal_skins.objectValues('Folder'):
if not skin_folder.getId().startswith("slapos"):
continue
for skin in skin_folder.objectValues():
if skin.getId().startswith("Alarm_"):
continue
if skin.meta_type in ('Script (Python)', 'Z SQL Method', ):
found = 0
for _, content in content_dict.iteritems():
if skin.getId() in content:
found = 1
break
if not found:
print "%s/%s" % (skin_folder.getId(), skin.getId())
container.REQUEST.RESPONSE.setHeader('content-type', 'text/plain')
return '\n'.join(sorted(printed.splitlines()))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_testPythonScriptTestCoverage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -67,6 +67,47 @@ def makeTestSlapOSCodingStyleTestCase(tested_business_template):
# we define it for CodingStyleTestCase.test_PythonSourceCode
return ('erp5_administration', )
def test_PythonScriptTestCoverage(self):
content_dict = {}
for test_component in self.portal.portal_components.searchFolder(
portal_type='Test Component'):
if "Slap" not in test_component.getId() or \
"testSlapOSCodingStyle" in test_component.getId():
continue
content_dict[test_component.getId()] = test_component.getTextContent()
self.assertNotEqual(len(content_dict), 0)
skin_id_set = set()
for business_template in self._getTestedBusinessTemplateValueList():
skin_id_set.update(business_template.getTemplateSkinIdList())
# Init message list
message_list = []
# Test skins
portal_skins = self.portal.portal_skins
for skin_id in skin_id_set:
skin = portal_skins[skin_id]
for _, document in skin.ZopeFind(
skin,
obj_metatypes=('Script (Python)', 'Z SQL Method', ),
search_sub=True):
if document.getId().startswith("Alarm_"):
# Alarms are tested directly, so we can safely skip
continue
found = 0
for _, content in content_dict.iteritems():
if document.getId() in content:
found = 1
break
if not found:
message_list.append("%s/%s" % (skin.getId(), document.getId()))
self.maxDiff = None
self.assertEqual(message_list, [])
return type("TestSlapOSCodingStyle.%s" % tested_business_template,
(TestSlapOSCodingStyle,),
{"getTestedBusinessTemplateList": lambda self: (tested_business_template, )})
......
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSCodingStyle</string> </value>
......@@ -55,28 +49,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -89,7 +68,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
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