Commit b6ccfc26 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_accounting: Migrate Unit Tests.

parent 719b21e3
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAccounting</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAccounting</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAccounting</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAccountingReports</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAccountingReports</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAccountingReports</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
##############################################################################
# Copyright (c) 2016 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability 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
# garantees 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.
#
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
class PortalTypeOfPortalTypeTestCase(ERP5TypeTestCase):
"""
Base class to test Portal Types of other Portal Types
"""
def getBusinessTemplateList(self):
return ('erp5_core', 'erp5_base', 'erp5_simulation', 'erp5_accounting')
def setUpPropertyOnPortalType(self, portal_type_id, property_name, property_value):
portal_type = self.portal.portal_types.get(portal_type_id, None)
portal_type.setProperty(property_name, property_value)
def cleanPropertyOnPortalType(self, portal_type_id, property_name):
portal_type = self.portal.portal_types.get(portal_type_id, None)
portal_type.setProperty(property_name, None)
class TestDeliveryTypeInformation(PortalTypeOfPortalTypeTestCase):
"""
Delivery Type is a Base Type on which a list of allowed ledgers is defined.
This suite checks that its custom features are correctly implemented.
"""
def afterSetUp(self):
self.createLedgerCategory()
@UnrestrictedMethod
def createLedgerCategory(self):
portal_categories = self.portal.portal_categories
ledger = self.portal.portal_categories.get('ledger', None)
if ledger is None:
ledger = portal_categories.newContent(portal_type='Base Category',
id='ledger')
accounting_ledger = ledger.get('accounting', None)
if accounting_ledger is None:
accounting_ledger = ledger.newContent(portal_type='Category',
id='accounting')
if accounting_ledger.get('general', None) is None:
accounting_ledger.newContent(portal_type='Category', id='general')
if accounting_ledger.get('detailed', None) is None:
accounting_ledger.newContent(portal_type='Category', id='detailed')
def testDefaultLedgerIsSetOnObjectIfSetOnPortalType(self):
"""
Sets up a list of ledger on the Accounting Transaction portal type,
which is a DeliveryTypeInformation, and checks that new Accounting Transactions
have a default ledger set at their creation
"""
portal_type = "Accounting Transaction"
self.setUpPropertyOnPortalType(
portal_type,
"ledger_list",
['accounting/general', 'accounting/detailed'])
self.assertEqual(self.portal.portal_types.get(portal_type).getDefaultLedger(),
'accounting/general')
module = self.portal.getDefaultModule(portal_type)
accounting_transaction = module.newContent(portal_type=portal_type)
self.assertEqual(accounting_transaction.hasLedger(), True)
self.assertEqual(accounting_transaction.getLedgerList(),
['accounting/general'])
def testDefaultLedgerIsNotSetOnObjectIfNotSetOnPortalType(self):
"""
If no ledger is defined on the portal type, then it means the
"allowed ledger list" feature is not in use in this instance
"""
portal_type = "Accounting Transaction"
portal_type_object = self.portal.portal_types.get(portal_type)
self.cleanPropertyOnPortalType(portal_type, 'ledger')
# No ledger should be set on the portal type
self.assertEqual(portal_type_object.getLedgerList(), [])
module = self.portal.getDefaultModule(portal_type)
accounting_transaction = module.newContent(portal_type=portal_type)
self.assertEqual(accounting_transaction.getLedgerList(), [])
def testDefaultLedgerIsOverwrittenByNewContentParameter(self):
"""
If a Delivery is created with a given ledger, then it should overwrite
the default ledger
"""
portal_type = "Accounting Transaction"
self.setUpPropertyOnPortalType(
portal_type,
"ledger_list",
['accounting/general', 'accounting/detailed'])
self.assertEqual(self.portal.portal_types.get(portal_type).getDefaultLedger(),
'accounting/general')
module = self.portal.getDefaultModule(portal_type)
accounting_transaction = module.newContent(portal_type=portal_type,
ledger='accounting/detailed')
self.assertEqual(accounting_transaction.hasLedger(), True)
self.assertEqual(accounting_transaction.getLedgerList(),
['accounting/detailed'])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testTypeDefinition</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5Type.tests.testTypeDefinition</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testTypeDefinition</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testAccounting
test.erp5.testAccountingReports
test.erp5.testTypeDefinition
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_pdm
erp5_simulation
erp5_trade
erp5_project
erp5_ods_style
erp5_configurator_standard_trade_template
erp5_invoicing
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
erp5_simulation_test
erp5_accounting_ui_test
erp5_simplified_invoicing
\ No newline at end of file
...@@ -40,7 +40,7 @@ from DateTime import DateTime ...@@ -40,7 +40,7 @@ from DateTime import DateTime
from lxml import etree from lxml import etree
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5.tests.testAccounting import AccountingTestCase from erp5.component.test.testAccounting import AccountingTestCase
class TestAccounting_l10n_fr(AccountingTestCase): class TestAccounting_l10n_fr(AccountingTestCase):
"""Test Accounting L10N FR """Test Accounting L10N FR
...@@ -92,7 +92,7 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -92,7 +92,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
def test_FEC(self): def test_FEC(self):
account_module = self.portal.account_module account_module = self.portal.account_module
first = self._makeOne( self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
title='Première Écriture', title='Première Écriture',
simulation_state='delivered', simulation_state='delivered',
...@@ -106,7 +106,7 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -106,7 +106,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
dict(destination_value=account_module.goods_purchase, dict(destination_value=account_module.goods_purchase,
destination_credit=110.00))) destination_credit=110.00)))
second = self._makeOne( self._makeOne(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
title='Seconde Écriture', title='Seconde Écriture',
simulation_state='delivered', simulation_state='delivered',
...@@ -130,7 +130,7 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -130,7 +130,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
fec_xml = '' fec_xml = ''
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message _, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text)
for part in mail_message.walk(): for part in mail_message.walk():
...@@ -146,8 +146,9 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -146,8 +146,9 @@ class TestAccounting_l10n_fr(AccountingTestCase):
self.fail("Attachment not found") self.fail("Attachment not found")
# validate against official schema # validate against official schema
import Products.ERP5.tests
schema = etree.XMLSchema(etree.XML(open(os.path.join( schema = etree.XMLSchema(etree.XML(open(os.path.join(
os.path.dirname(__file__), 'test_data', os.path.dirname(Products.ERP5.tests.__file__), 'test_data',
'formatA47A-I-VII-1.xsd')).read())) 'formatA47A-I-VII-1.xsd')).read()))
# this raise if invalid # this raise if invalid
...@@ -164,7 +165,7 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -164,7 +165,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
def _FECWithLedger(self, ledger_list=None, group_by=None): def _FECWithLedger(self, ledger_list=None, group_by=None):
self.setUpLedger() self.setUpLedger()
account_module = self.portal.account_module account_module = self.portal.account_module
first = self._makeOne( self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
title='Première Écriture', title='Première Écriture',
simulation_state='delivered', simulation_state='delivered',
...@@ -179,7 +180,7 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -179,7 +180,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
dict(destination_value=account_module.goods_purchase, dict(destination_value=account_module.goods_purchase,
destination_credit=110.00))) destination_credit=110.00)))
second = self._makeOne( self._makeOne(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
title='Seconde Écriture', title='Seconde Écriture',
simulation_state='delivered', simulation_state='delivered',
...@@ -194,7 +195,7 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -194,7 +195,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
dict(source_value=account_module.goods_sales, dict(source_value=account_module.goods_sales,
source_credit=200.00))) source_credit=200.00)))
third = self._makeOne( self._makeOne(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
title='Troisième Écriture', title='Troisième Écriture',
simulation_state='delivered', simulation_state='delivered',
...@@ -222,7 +223,7 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -222,7 +223,7 @@ class TestAccounting_l10n_fr(AccountingTestCase):
fec_xml = '' fec_xml = ''
last_message = self.portal.MailHost._last_message last_message = self.portal.MailHost._last_message
self.assertNotEquals((), last_message) self.assertNotEquals((), last_message)
mfrom, mto, message_text = last_message _, mto, message_text = last_message
self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0]) self.assertEqual('"%s" <%s>' % (self.first_name, self.recipient_email_address), mto[0])
mail_message = email.message_from_string(message_text) mail_message = email.message_from_string(message_text)
for part in mail_message.walk(): for part in mail_message.walk():
...@@ -238,8 +239,9 @@ class TestAccounting_l10n_fr(AccountingTestCase): ...@@ -238,8 +239,9 @@ class TestAccounting_l10n_fr(AccountingTestCase):
self.fail("Attachment not found") self.fail("Attachment not found")
# validate against official schema # validate against official schema
import Products.ERP5.tests
schema = etree.XMLSchema(etree.XML(open(os.path.join( schema = etree.XMLSchema(etree.XML(open(os.path.join(
os.path.dirname(__file__), 'test_data', os.path.dirname(Products.ERP5.tests.__file__), 'test_data',
'formatA47A-I-VII-1.xsd')).read())) 'formatA47A-I-VII-1.xsd')).read()))
# this raise if invalid # this raise if invalid
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testAccounting_l10n_fr</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testAccounting_l10n_fr</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testAccounting_l10n_fr</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testAccounting_l10n_fr
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_pdm
erp5_simulation
erp5_trade
erp5_project
erp5_ods_style
erp5_configurator_standard_trade_template
erp5_invoicing
erp5_configurator_standard_accounting_template
erp5_configurator_standard_invoicing_template
erp5_simulation_test
erp5_accounting_ui_test
erp5_deferred_style
\ No newline at end of file
...@@ -31,7 +31,7 @@ import unittest ...@@ -31,7 +31,7 @@ import unittest
from DateTime import DateTime from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Products.ERP5.tests.testAccounting import AccountingTestCase from erp5.component.test.testAccounting import AccountingTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
QUIET = False QUIET = False
run_all_test = True run_all_test = True
...@@ -80,11 +80,11 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -80,11 +80,11 @@ class TestConversionInSimulation(AccountingTestCase):
def createCategoriesInCategory(self, category, category_id_list): def createCategoriesInCategory(self, category, category_id_list):
for category_id in category_id_list: for category_id in category_id_list:
child = category child = category
for id in category_id.split('/'): for id_ in category_id.split('/'):
try: try:
child = child[id] child = child[id_]
except KeyError: except KeyError:
child = child.newContent(id) child = child.newContent(id_)
def createCategories(self): def createCategories(self):
"""Create the categories for our test. """ """Create the categories for our test. """
...@@ -101,16 +101,16 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -101,16 +101,16 @@ class TestConversionInSimulation(AccountingTestCase):
['accounting', 'delivery', 'invoicing', 'discount', 'tax', 'payment']) ['accounting', 'delivery', 'invoicing', 'discount', 'tax', 'payment'])
_(category_tool.product_line, ['apparel']) _(category_tool.product_line, ['apparel'])
def _solveDivergence(self, obj, property, decision, group='line'): def _solveDivergence(self, obj, prop, decision, group='line'):
""" """
Check if simulation movement are disconnected Check if simulation movement are disconnected
""" """
kw = {'%s_group_listbox' % group:{}} kw = {'%s_group_listbox' % group:{}}
for divergence in obj.getDivergenceList(): for divergence in obj.getDivergenceList():
if divergence.getProperty('tested_property') != property: if divergence.getProperty('tested_property') != prop:
continue continue
sm_url = divergence.getProperty('simulation_movement').getRelativeUrl() sm_url = divergence.getProperty('simulation_movement').getRelativeUrl()
kw['line_group_listbox']['%s&%s' % (sm_url, property)] = { kw['line_group_listbox']['%s&%s' % (sm_url, prop)] = {
'choice':decision} 'choice':decision}
self.portal.portal_workflow.doActionFor( self.portal.portal_workflow.doActionFor(
obj, obj,
...@@ -144,7 +144,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -144,7 +144,7 @@ class TestConversionInSimulation(AccountingTestCase):
self.tic() self.tic()
super(TestConversionInSimulation, self).beforeTearDown() super(TestConversionInSimulation, self).beforeTearDown()
def login(self,name=username, quiet=0, run=run_all_test): def login(self, *args, **kw):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser(self.username, '', ['Assignee', 'Assignor', uf._doAddUser(self.username, '', ['Assignee', 'Assignor',
'Author'], []) 'Author'], [])
...@@ -247,7 +247,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -247,7 +247,7 @@ class TestConversionInSimulation(AccountingTestCase):
""" """
if not run: return if not run: return
if not quiet: if not quiet:
printAndLog('test_01_simulation_movement_destination_asset_price') printAndLog('test_01_simulation_movement_destination_asset_price')
resource = self.portal.product_module.newContent( resource = self.portal.product_module.newContent(
portal_type='Product', portal_type='Product',
title='Resource', title='Resource',
...@@ -291,10 +291,10 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -291,10 +291,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency, price_currency_value=currency,
specialise_value=self.business_process, specialise_value=self.business_process,
title='Order') title='Order')
order_line = order.newContent(portal_type='Sale Order Line', order.newContent(portal_type='Sale Order Line',
resource_value=resource, resource_value=resource,
quantity=1, quantity=1,
price=2) price=2)
order.confirm() order.confirm()
self.tic() self.tic()
...@@ -339,7 +339,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -339,7 +339,7 @@ class TestConversionInSimulation(AccountingTestCase):
""" """
if not run: return if not run: return
if not quiet: if not quiet:
printAndLog('test_01_simulation_movement_source_asset_price') printAndLog('test_01_simulation_movement_source_asset_price')
resource = self.portal.product_module.newContent( resource = self.portal.product_module.newContent(
portal_type='Product', portal_type='Product',
title='Resource', title='Resource',
...@@ -383,10 +383,10 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -383,10 +383,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency, price_currency_value=currency,
specialise_value=self.business_process, specialise_value=self.business_process,
title='Order') title='Order')
order_line = order.newContent(portal_type='Sale Order Line', order.newContent(portal_type='Sale Order Line',
resource_value=resource, resource_value=resource,
quantity=1, quantity=1,
price=2) price=2)
order.confirm() order.confirm()
self.tic() self.tic()
...@@ -421,7 +421,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -421,7 +421,7 @@ class TestConversionInSimulation(AccountingTestCase):
""" """
if not run: return if not run: return
if not quiet: if not quiet:
printAndLog( printAndLog(
'test_01_destination_total_asset_price_on_accounting_lines') 'test_01_destination_total_asset_price_on_accounting_lines')
resource = self.portal.product_module.newContent( resource = self.portal.product_module.newContent(
...@@ -467,10 +467,10 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -467,10 +467,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency, price_currency_value=currency,
specialise_value=self.business_process, specialise_value=self.business_process,
title='Order') title='Order')
order_line = order.newContent(portal_type='Sale Order Line', order.newContent(portal_type='Sale Order Line',
resource_value=resource, resource_value=resource,
quantity=1, quantity=1,
price=2) price=2)
order.confirm() order.confirm()
self.tic() self.tic()
self.buildPackingLists() self.buildPackingLists()
...@@ -495,7 +495,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -495,7 +495,7 @@ class TestConversionInSimulation(AccountingTestCase):
portal_type=self.portal.getPortalAccountingMovementTypeList()) portal_type=self.portal.getPortalAccountingMovementTypeList())
self.assertNotEquals(line_list, None) self.assertNotEquals(line_list, None)
for line in line_list: for line in line_list:
self.assertEqual(line.getDestinationTotalAssetPrice(), self.assertEqual(line.getDestinationTotalAssetPrice(),
round(655.957*delivery_movement.getTotalPrice())) round(655.957*delivery_movement.getTotalPrice()))
def test_01_diverged_sale_packing_list_destination_total_asset_price( def test_01_diverged_sale_packing_list_destination_total_asset_price(
...@@ -509,7 +509,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -509,7 +509,7 @@ class TestConversionInSimulation(AccountingTestCase):
""" """
if not run: return if not run: return
if not quiet: if not quiet:
printAndLog( printAndLog(
'test_01_diverged_sale_packing_list_destination_total_asset_price') 'test_01_diverged_sale_packing_list_destination_total_asset_price')
resource = self.portal.product_module.newContent( resource = self.portal.product_module.newContent(
...@@ -555,10 +555,10 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -555,10 +555,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency, price_currency_value=currency,
specialise_value=self.business_process, specialise_value=self.business_process,
title='Order') title='Order')
order_line = order.newContent(portal_type='Sale Order Line', order.newContent(portal_type='Sale Order Line',
resource_value=resource, resource_value=resource,
quantity=5, quantity=5,
price=2) price=2)
order.confirm() order.confirm()
self.tic() self.tic()
self.buildPackingLists() self.buildPackingLists()
...@@ -608,7 +608,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -608,7 +608,7 @@ class TestConversionInSimulation(AccountingTestCase):
""" """
if not run: return if not run: return
if not quiet: if not quiet:
printAndLog( printAndLog(
'test_01_diverged_purchase_packing_list_source_total_asset_price') 'test_01_diverged_purchase_packing_list_source_total_asset_price')
resource = self.portal.product_module.newContent( resource = self.portal.product_module.newContent(
...@@ -654,10 +654,10 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -654,10 +654,10 @@ class TestConversionInSimulation(AccountingTestCase):
price_currency_value=currency, price_currency_value=currency,
specialise_value=self.business_process, specialise_value=self.business_process,
title='Order') title='Order')
order_line = order.newContent(portal_type='Purchase Order Line', order.newContent(portal_type='Purchase Order Line',
resource_value=resource, resource_value=resource,
quantity=5, quantity=5,
price=2) price=2)
order.confirm() order.confirm()
self.tic() self.tic()
self.buildPackingLists() self.buildPackingLists()
...@@ -707,7 +707,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -707,7 +707,7 @@ class TestConversionInSimulation(AccountingTestCase):
""" """
if not run: return if not run: return
if not quiet: if not quiet:
printAndLog( printAndLog(
'test_01_delivery_mode_on_sale_packing_list_and_invoice') 'test_01_delivery_mode_on_sale_packing_list_and_invoice')
resource = self.portal.product_module.newContent( resource = self.portal.product_module.newContent(
...@@ -755,10 +755,10 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -755,10 +755,10 @@ class TestConversionInSimulation(AccountingTestCase):
incoterm=self.cpt_incoterm, incoterm=self.cpt_incoterm,
specialise_value=self.business_process, specialise_value=self.business_process,
title='Order') title='Order')
order_line = order.newContent(portal_type='Sale Order Line', order.newContent(portal_type='Sale Order Line',
resource_value=resource, resource_value=resource,
quantity=5, quantity=5,
price=2) price=2)
order.confirm() order.confirm()
self.tic() self.tic()
self.buildPackingLists() self.buildPackingLists()
...@@ -788,7 +788,7 @@ class TestConversionInSimulation(AccountingTestCase): ...@@ -788,7 +788,7 @@ class TestConversionInSimulation(AccountingTestCase):
""" """
if not run: return if not run: return
if not quiet: if not quiet:
printAndLog( printAndLog(
'test_01_quantity_unit_on_sale_packing_list') 'test_01_quantity_unit_on_sale_packing_list')
resource = self.portal.product_module.newContent( resource = self.portal.product_module.newContent(
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testConversionInSimulation</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testConversionInSimulation</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testConversionInSimulation</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
import unittest import unittest
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5.tests.testAccounting import AccountingTestCase from erp5.component.test.testAccounting import AccountingTestCase
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
class CurrencyExchangeTestCase(AccountingTestCase): class CurrencyExchangeTestCase(AccountingTestCase):
...@@ -56,7 +56,7 @@ class CurrencyExchangeTestCase(AccountingTestCase): ...@@ -56,7 +56,7 @@ class CurrencyExchangeTestCase(AccountingTestCase):
self.tic() self.tic()
def login(self, name=username): def login(self, *args, **kw):
uf = self.getPortal().acl_users uf = self.getPortal().acl_users
uf._doAddUser(self.username, '', ['Assignee', 'Assignor', uf._doAddUser(self.username, '', ['Assignee', 'Assignor',
'Author','Manager'], []) 'Author','Manager'], [])
...@@ -146,7 +146,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase): ...@@ -146,7 +146,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
x_curr_ex_line.validate() x_curr_ex_line.validate()
self.assertEqual(x_curr_ex_line.getValidationState(), self.assertEqual(x_curr_ex_line.getValidationState(),
'validated') 'validated')
accounting_module = self.portal.accounting_module
invoice = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
...@@ -195,21 +194,16 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase): ...@@ -195,21 +194,16 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
self.assertEqual(x_curr_ex_line.getValidationState(), self.assertEqual(x_curr_ex_line.getValidationState(),
'validated') 'validated')
yen = self.portal.currency_module.yen yen = self.portal.currency_module.yen
yen_line1 = yen.newContent( yen.newContent(portal_type='Currency Exchange Line')
portal_type='Currency Exchange Line') yen.newContent(portal_type='Currency Exchange Line')
yen_line2 = yen.newContent(
portal_type='Currency Exchange Line')
usd = self.portal.currency_module.usd usd = self.portal.currency_module.usd
usd_line1 = usd.newContent( usd.newContent(portal_type='Currency Exchange Line')
portal_type='Currency Exchange Line') usd.newContent(portal_type='Currency Exchange Line')
usd_line2 = usd.newContent(
portal_type='Currency Exchange Line')
euro_line = euro.newContent( euro_line = euro.newContent(
portal_type='Currency Exchange Line') portal_type='Currency Exchange Line')
euro_line.validate() euro_line.validate()
accounting_module = self.portal.accounting_module
invoice = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
...@@ -256,7 +250,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase): ...@@ -256,7 +250,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
x_curr_ex_line.validate() x_curr_ex_line.validate()
self.assertEqual(x_curr_ex_line.getValidationState(), self.assertEqual(x_curr_ex_line.getValidationState(),
'validated') 'validated')
accounting_module = self.portal.accounting_module
invoice = self._makeOne( invoice = self._makeOne(
portal_type='Sale Invoice Transaction', portal_type='Sale Invoice Transaction',
start_date=DateTime('2008/09/08'), start_date=DateTime('2008/09/08'),
...@@ -294,8 +287,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase): ...@@ -294,8 +287,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
self.tic() self.tic()
self.organisation1.edit( self.organisation1.edit(
price_currency=new_currency.getRelativeUrl()) price_currency=new_currency.getRelativeUrl())
euro = self.portal.currency_module.euro
accounting_module = self.portal.accounting_module
invoice = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
...@@ -345,7 +336,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase): ...@@ -345,7 +336,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
x_curr_ex_line.validate() x_curr_ex_line.validate()
self.assertEqual(x_curr_ex_line.getValidationState(), self.assertEqual(x_curr_ex_line.getValidationState(),
'validated') 'validated')
accounting_module = self.portal.accounting_module
transaction1 = self._makeOne( transaction1 = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
...@@ -413,7 +403,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase): ...@@ -413,7 +403,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
self.assertEqual(x_curr_ex_line.getValidationState(), self.assertEqual(x_curr_ex_line.getValidationState(),
'validated') 'validated')
accounting_module = self.portal.accounting_module
invoice = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
...@@ -429,8 +418,7 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase): ...@@ -429,8 +418,7 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
line_list = invoice.contentValues( line_list = invoice.contentValues(
portal_type=self.portal.getPortalAccountingMovementTypeList()) portal_type=self.portal.getPortalAccountingMovementTypeList())
for line in line_list: for line in line_list:
self.assertEqual(line.getDestinationTotalAssetPrice(), self.assertEqual(line.getDestinationTotalAssetPrice(), None)
None)
def test_CreateCELWithNoBasePrice(self): def test_CreateCELWithNoBasePrice(self):
...@@ -476,7 +464,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase): ...@@ -476,7 +464,6 @@ class TestCurrencyExchangeLine(CurrencyExchangeTestCase):
self.assertEqual(euro_line2.getValidationState(), self.assertEqual(euro_line2.getValidationState(),
'validated') 'validated')
accounting_module = self.portal.accounting_module
invoice = self._makeOne( invoice = self._makeOne(
portal_type='Purchase Invoice Transaction', portal_type='Purchase Invoice Transaction',
stop_date=DateTime('2008/09/08'), stop_date=DateTime('2008/09/08'),
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testERP5CurrencyExchangeLine</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testERP5CurrencyExchangeLine</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testERP5CurrencyExchangeLine</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<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>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testConversionInSimulation
test.erp5.testERP5CurrencyExchangeLine
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_base
erp5_core_proxy_field_legacy
erp5_pdm
erp5_simulation
erp5_trade
erp5_simulation_test erp5_simulation_test
erp5_simplified_invoicing erp5_simplified_invoicing
erp5_configurator_standard_accounting_template erp5_configurator_standard_solver
\ No newline at end of file erp5_configurator_standard_trade_template
erp5_configurator_standard_invoicing_template
\ No newline at end of file
...@@ -35,7 +35,7 @@ from DateTime import DateTime ...@@ -35,7 +35,7 @@ from DateTime import DateTime
from Products.DCWorkflow.DCWorkflow import ValidationFailed from Products.DCWorkflow.DCWorkflow import ValidationFailed
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase
from Products.ERP5.tests.testAccounting import AccountingTestCase from erp5.component.test.testAccounting import AccountingTestCase
class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase): class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
"""Test Bank Reconciliation """Test Bank Reconciliation
......
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