def checkConversionToolAvailability(self): """ Check conversion tool (oood) is available for erp5. This script convert an odt document into HTML and try to read the returned string and find out expected string """ portal = self.getPortalObject() document_id = 'P-ERP5-TEST.Conversion.Tool.Availability-001-en.odt' document_path = 'portal_skins/erp5_administration/%s' % (document_id,) document_file = portal.restrictedTraverse(document_path) message = None severity = 0 try: temp_document = newTempOOoDocument(self, document_id, data=document_file.data, source_reference=document_id) temp_document.convertToBaseFormat() _, html_result = temp_document.convert(format='html') except ConflictError: raise except: #Which Errors should we catch ? #Transformation failed message = 'Conversion tool got unexpected error:\n%s' % ''.join(ExceptionFormatter.format_exception(*sys.exc_info())) else: #Everything goes fine, Check that expected string is present in HTML conversion if 'AZERTYUIOPMQ' not in html_result: message = 'Conversion to HTML Failed:\n%s' % (html_result,) active_process = self.newActiveProcess() result = ActiveResult() if message: severity = 1 result.edit(detail=message) result.edit(severity=severity) active_process.activateResult(result)
def _checkExpand(self): """Check that expand() would not fail nor do major changes to the subobjects Transaction is aborted after 'expand' is called. See also SimulationTool._checkExpandAll """ property_dict = {'Applied Rule': ('specialise',), 'Simulation Movement': ('delivery', 'quantity')} def fillRuleDict(): rule_dict = {} object_list = deque((self,)) while object_list: document = object_list.popleft() portal_type = document.getPortalType() document_dict = {'portal_type': portal_type} for property in property_dict[portal_type]: document_dict[property] = document.getProperty(property) rule_dict[document.getRelativeUrl()] = document_dict object_list += document.objectValues() return rule_dict initial_rule_dict = fillRuleDict() try: self.expand("immediate") except ConflictError: raise except Exception: msg = ''.join(ExceptionFormatter.format_exception(*sys.exc_info())[1:]) else: final_rule_dict = fillRuleDict() msg = "%r != %r" % (initial_rule_dict, final_rule_dict) \ if initial_rule_dict != final_rule_dict else None transaction.abort() return msg
def checkConversionToolAvailability(self): """ Check conversion tool (oood) is available for erp5. This script convert an odt document into HTML and try to read the returned string and find out expected string """ portal = self.getPortalObject() document_id = 'P-ERP5-TEST.Conversion.Tool.Availability-001-en.odt' document_path = 'portal_skins/erp5_administration/%s' % (document_id,) document_file = portal.restrictedTraverse(document_path) message = None severity = 0 try: temp_document = newTempOOoDocument(self, document_id, data=document_file.data, source_reference=document_id) temp_document.convertToBaseFormat() _, html_result = temp_document.convert(format='html') except ConflictError: raise except: #Which Errors should we catch ? #Transformation failed message = 'Conversion tool got unexpected error:\n%s' % ''.join(ExceptionFormatter.format_exception(*sys.exc_info())) else: #Everything goes fine, Check that expected string is present in HTML conversion if 'AZERTYUIOPMQ' not in html_result: message = 'Conversion to HTML Failed:\n%s' % (html_result,) active_process = self.newActiveProcess() result = ActiveResult() if message: severity = 1 result.edit(detail=message) result.edit(severity=severity) active_process.postResult(result)