Commit cc7b8d71 authored by Jérome Perrin's avatar Jérome Perrin

CodingStyleTestCase: check rebuilding tested BT to catch packaging problems

This test should catch when business templates metadata in `bt/` is different from the actual content in `*TemplateItem/` . It should not happen, but sometimes we can forgot to include one or the other in commit.

This also fixes problems in the currently tested business templates, there was three kind of problems:
 * binary files are now exported with `bin` extension, it use to be `obj`.
 * In several business templates, we export categories as `portal_categories/category/*`, while this looks convenient, it's problematic when categories are added by other business templates, every time developer export the business template they have to consider whether the new paths should be exported or not. This changed to list explicitly all the paths to include in business template.
 * some business templates were partially commited ( "erp5_dms_ui_test:  Add selenium tests" )

/reviewed-on !1049
parents 3d03d158 dab1dd86
Pipeline #7965 passed with stage
in 0 seconds
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PDF" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts68329727.44</string> </value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_content_information</string> </key>
<value>
<dictionary>
<item>
<key> <string>ArtBox</string> </key>
<value> <string>0.00 0.00 595.24 841.84</string> </value>
</item>
<item>
<key> <string>BleedBox</string> </key>
<value> <string>0.00 0.00 595.24 841.84</string> </value>
</item>
<item>
<key> <string>CreationDate</string> </key>
<value> <string>Wed Jun 11 16:56:03 2008</string> </value>
</item>
<item>
<key> <string>CropBox</string> </key>
<value> <string>0.00 0.00 595.24 841.84</string> </value>
</item>
<item>
<key> <string>Encrypted</string> </key>
<value> <string>no</string> </value>
</item>
<item>
<key> <string>File size</string> </key>
<value> <string>4001 bytes</string> </value>
</item>
<item>
<key> <string>Form</string> </key>
<value> <string>none</string> </value>
</item>
<item>
<key> <string>JavaScript</string> </key>
<value> <string>no</string> </value>
</item>
<item>
<key> <string>MediaBox</string> </key>
<value> <string>0.00 0.00 595.24 841.84</string> </value>
</item>
<item>
<key> <string>ModDate</string> </key>
<value> <string>Wed Jun 11 16:56:03 2008</string> </value>
</item>
<item>
<key> <string>Optimized</string> </key>
<value> <string>no</string> </value>
</item>
<item>
<key> <string>PDF version</string> </key>
<value> <string>1.4</string> </value>
</item>
<item>
<key> <string>Page rot</string> </key>
<value> <string>0</string> </value>
</item>
<item>
<key> <string>Page size</string> </key>
<value> <string>595.238 x 841.836 pts (A4)</string> </value>
</item>
<item>
<key> <string>Pages</string> </key>
<value> <string>1</string> </value>
</item>
<item>
<key> <string>Producer</string> </key>
<value> <string>Ibex PDF Creator 4.3.6.4/5025 [.NET 2.0]</string> </value>
</item>
<item>
<key> <string>Suspects</string> </key>
<value> <string>no</string> </value>
</item>
<item>
<key> <string>Tagged</string> </key>
<value> <string>no</string> </value>
</item>
<item>
<key> <string>TrimBox</string> </key>
<value> <string>0.00 0.00 595.24 841.84</string> </value>
</item>
<item>
<key> <string>UserProperties</string> </key>
<value> <string>no</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value> <string>47d0d61fb76a0ec08f930b017f54a238</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/pdf</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>filename</string> </key>
<value> <string>hello-world.pdf</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>-1</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_pdf</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>PDF</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value> <string>PDF to be used for selenium tests</string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>4001</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>test pdf</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>-1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test PDF JS</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test PDF JS</td></tr>
</thead><tbody>
<!-- First, try object creation using the "Action ..." menu -->
<!-- from list mode -->
<tr>
<td>open</td>
<td tal:content="string: ${here/portal_url}/document_module/view">/erp5/document_module/view</td>
<td></td>
</tr>
<tr>
<td>selectAndWait</td>
<td>select_action</td>
<td>Add PDF</td>
</tr>
<tr>
<td>assertTextNotPresent</td>
<td>No Site Error</td>
<td></td>
</tr>
<tr>
<td>verifyPortalStatusMessage</td>
<td>Object created.</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td tal:content="string: ${here/portal_url}/document_module/test_pdf">/erp5/document_module/test_pdf</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//*[@id="master"]/div/div[1]/ul/li[4]/a</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>3000</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//*[@id="master"]/div/div[1]/button</td>
<td></td>
</tr>
<tr>
<td>selectFrame</td>
<td>index=0</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//*[@id="pageContainer1"]/div[2]/div[1]</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>//*[@id="pageContainer1"]/div[2]/div[1]</td>
<td>hello world</td>
</tr>
</body>
</html>
\ No newline at end of file
document_module/test_pdf
portal_categories/classification/** portal_categories/classification/**
portal_tests/dms_zuite portal_tests/dms_zuite
portal_tests/dms_zuite/** portal_tests/dms_zuite/**
\ No newline at end of file
Functional test suites for erp5_payroll. Functional test suites for erp5_payroll.
Contributions welcomed ! Contributions welcomed !
Note: this demo was build for the current payroll BT5, which is quite french accounting-centric currently. This explain why so many specific datas (categories, persons, organisations, accounts,...) are required: to make payroll calculation process work. Note: this demo was build for the current payroll BT5, which is quite french accounting-centric currently. This explain why so many specific datas (categories, persons, organisations, accounts,...) are required: to make payroll calculation process work.
\ No newline at end of file
...@@ -35,9 +35,44 @@ organisation_module/henner ...@@ -35,9 +35,44 @@ organisation_module/henner
organisation_module/henner/** organisation_module/henner/**
organisation_module/urssaf organisation_module/urssaf
organisation_module/urssaf/** organisation_module/urssaf/**
portal_categories/financial_section/** portal_categories/financial_section/actif
portal_categories/grade/** portal_categories/financial_section/actif/actif_circulant
portal_categories/marital_status/** portal_categories/financial_section/actif/actif_circulant/avances_et_accomptes_verses_sur_commandes
portal_categories/region/** portal_categories/financial_section/actif/actif_circulant/caisse
portal_categories/financial_section/actif/actif_circulant/creances
portal_categories/financial_section/actif/actif_circulant/creances/clients_et_comptes_rattaches
portal_categories/financial_section/actif/actif_circulant/disponibilites
portal_categories/financial_section/actif/actif_circulant/marchandises
portal_categories/financial_section/actif/actif_circulant/stocks_et_en-cours
portal_categories/financial_section/actif/actif_circulant/valeurs_mobilieres_de_placement
portal_categories/financial_section/actif/actif_immobilise
portal_categories/financial_section/actif/actif_immobilise/immobilisations_corporelles
portal_categories/financial_section/actif/actif_immobilise/immobilisations_financieres
portal_categories/financial_section/actif/actif_immobilise/immobilisations_incorporelles
portal_categories/financial_section/actif/actif_immobilise/immobilisations_incorporelles/droit_au_bail
portal_categories/financial_section/actif/actif_immobilise/immobilisations_incorporelles/fonds_commercial
portal_categories/financial_section/actif/charges_constatees_d_avance
portal_categories/financial_section/charges
portal_categories/financial_section/passif
portal_categories/financial_section/passif/capitaux_propres
portal_categories/financial_section/passif/capitaux_propres/capital
portal_categories/financial_section/passif/capitaux_propres/ecart_reevalutaion
portal_categories/financial_section/passif/capitaux_propres/provisions_reglementees
portal_categories/financial_section/passif/capitaux_propres/report_a_nouveau
portal_categories/financial_section/passif/capitaux_propres/reserves
portal_categories/financial_section/passif/capitaux_propres/reserves/reserve_legale
portal_categories/financial_section/passif/capitaux_propres/reserves/reserves_reglementees
portal_categories/financial_section/passif/capitaux_propres/reserves/reserves_statutaires
portal_categories/financial_section/passif/capitaux_propres/resultat_exercice
portal_categories/financial_section/passif/dettes
portal_categories/financial_section/passif/dettes/avances_et_accomptes_recus_sur_commandes_en_cours
portal_categories/financial_section/passif/dettes/emprunts_et_dettes_assimilees
portal_categories/financial_section/passif/dettes/fournisseurs_et_comptes_rattaches
portal_categories/financial_section/passif/produits_constates_d_avance
portal_categories/financial_section/passif/provisions_risques_et_charges
portal_categories/financial_section/produits
portal_categories/grade/engineer
portal_categories/marital_status/married
portal_categories/region/europe
portal_categories/role/administration portal_categories/role/administration
portal_categories/role/client portal_categories/role/client
\ No newline at end of file
...@@ -2,13 +2,33 @@ business_process_module/tiosafe_default_bpm ...@@ -2,13 +2,33 @@ business_process_module/tiosafe_default_bpm
business_process_module/tiosafe_default_bpm/** business_process_module/tiosafe_default_bpm/**
currency_module/euro currency_module/euro
currency_module/euro/** currency_module/euro/**
portal_categories/ball_size/** portal_categories/ball_size/x4
portal_categories/base_amount/** portal_categories/ball_size/x5
portal_categories/colour/** portal_categories/ball_size/x6
portal_categories/payment_mode/** portal_categories/base_amount/trade
portal_categories/region/** portal_categories/base_amount/trade/base
portal_categories/trade_phase/** portal_categories/base_amount/trade/base/taxable
portal_categories/use/** portal_categories/base_amount/trade/base/taxable/vat
portal_categories/base_amount/trade/base/taxable/vat/vat_exempted
portal_categories/base_amount/trade/base/taxable/vat/vat_normal_rate
portal_categories/base_amount/trade/base/taxable/vat/vat_reduced_rate
portal_categories/base_amount/trade/l10n
portal_categories/base_amount/trade/l10n/fr
portal_categories/base_amount/trade/l10n/fr/vat
portal_categories/base_amount/trade/l10n/fr/vat/purchase_sale
portal_categories/base_amount/trade/l10n/fr/vat/purchase_sale/national
portal_categories/colour/black
portal_categories/colour/red
portal_categories/colour/white
portal_categories/payment_mode/cb
portal_categories/payment_mode/cheque
portal_categories/region/europe
portal_categories/region/europe/western_europe
portal_categories/region/europe/western_europe/allemagne
portal_categories/region/france
portal_categories/trade_phase/vat
portal_categories/use/sale
portal_categories/use/tax
sale_trade_condition_module/default_tiosafe** sale_trade_condition_module/default_tiosafe**
service_module/tiosafe_delivery_service service_module/tiosafe_delivery_service
service_module/tiosafe_delivery_service/** service_module/tiosafe_delivery_service/**
......
...@@ -34,7 +34,6 @@ from DateTime import DateTime ...@@ -34,7 +34,6 @@ from DateTime import DateTime
from Products.CMFCore.utils import _checkPermission from Products.CMFCore.utils import _checkPermission
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests import CodingStyleTestCase
from Products.ERP5Type.tests.utils import reindex from Products.ERP5Type.tests.utils import reindex
from Products.DCWorkflow.DCWorkflow import ValidationFailed from Products.DCWorkflow.DCWorkflow import ValidationFailed
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -5932,22 +5931,6 @@ class TestInternalInvoiceTransaction(AccountingTestCase): ...@@ -5932,22 +5931,6 @@ class TestInternalInvoiceTransaction(AccountingTestCase):
portal_type='Internal Invoice Transaction Line')]) portal_type='Internal Invoice Transaction Line')])
class TestAccountingCodingStyle(CodingStyleTestCase.CodingStyleTestCase, AccountingTestCase):
"""Runs CodingStyleTestCase checks on erp5_accounting
"""
def getBusinessTemplateList(self):
# include administration for test_PythonSourceCode
return AccountingTestCase.getBusinessTemplateList(self) + (
'erp5_administration', )
def getTestedBusinessTemplateList(self):
return ('erp5_accounting', )
def beforeTearDown(self):
# we don't want to run AccountingTestCase.tearDown
pass
class TestAccountingAlarms(AccountingTestCase): class TestAccountingAlarms(AccountingTestCase):
def test_check_payable_receivable_account_grouped(self): def test_check_payable_receivable_account_grouped(self):
invoice = self._makeOne( invoice = self._makeOne(
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
# Jean-Paul Smets <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import unittest
from Products.ERP5Type.tests.CodingStyleTestCase import CodingStyleTestCase
class ERP5WebCodingStyle(CodingStyleTestCase):
"""
Check consistency of erp5_web business template code
"""
def getTitle(self):
return "erp5_web CodingStyle"
def getTestedBusinessTemplateList(self):
return ('erp5_web', )
def getBusinessTemplateList(self):
"""
Return the list of required business templates.
"""
return ('erp5_base',
'erp5_jquery',
'erp5_web',
'erp5_ingestion_mysql_innodb_catalog',
'erp5_ingestion',
'erp5_crm',
'erp5_administration',
)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(ERP5WebCodingStyle))
return suite
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
# #
############################################################################## ##############################################################################
import tarfile
import os
import glob
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Acquisition import aq_base from Acquisition import aq_base
...@@ -97,3 +101,27 @@ class CodingStyleTestCase(ERP5TypeTestCase): ...@@ -97,3 +101,27 @@ class CodingStyleTestCase(ERP5TypeTestCase):
for business_template in self.portal.portal_templates.contentValues(): for business_template in self.portal.portal_templates.contentValues():
if business_template.getTitle() in self.getTestedBusinessTemplateList(): if business_template.getTitle() in self.getTestedBusinessTemplateList():
self.assertEqual([], business_template.BusinessTemplate_getPythonSourceCodeMessageList()) self.assertEqual([], business_template.BusinessTemplate_getPythonSourceCodeMessageList())
def test_rebuild_business_template(self):
"""Try to rebuild business template to catch packaging errors.
"""
template_tool = self.portal.portal_templates
for bt_title in self.getTestedBusinessTemplateList():
bt = template_tool.getInstalledBusinessTemplate(bt_title, strict=True)
# make sure we can rebuild
bt.build()
# check we don't add or remove members.
# first, build a set of files that were on the original business template repository
base_path, local_path = self.portal.portal_templates.getLastestBTOnRepos(bt_title)
existing_files = set([os.path.relpath(y, base_path)
for x in os.walk(os.path.join(base_path, local_path))
for y in glob.glob(os.path.join(x[0], '*')) if os.path.isfile(y)])
# then compare this with the files in the newly exported business template.
bt_file = bt.export()
bt_file.seek(0) # XXX this StringIO was already read...
new_files = set(tarfile.open(fileobj=bt_file, mode='r:gz').getnames())
self.maxDiff = None
self.assertEqual(existing_files, new_files)
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