[Erp5-report] r42283 jm - in /erp5/trunk: bt5/erp5_egov/TestTemplateItem/ bt5/erp5_egov/bt/...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jan 12 19:54:36 CET 2011


Author: jm
Date: Wed Jan 12 19:54:36 2011
New Revision: 42283

URL: http://svn.erp5.org?rev=42283&view=rev
Log:
Rename test files that contain no test, to exclude from the test suite

Added:
    erp5/trunk/bt5/erp5_egov/TestTemplateItem/TestEGovMixin.py
      - copied, changed from r42282, erp5/trunk/bt5/erp5_egov/TestTemplateItem/testEGovMixin.py
    erp5/trunk/products/ERP5Legacy/tests/_testInvoiceVAT.py
      - copied, changed from r42282, erp5/trunk/products/ERP5/tests/testInvoiceVAT.py
    erp5/trunk/products/ERP5OOo/tests/TestFormPrintoutMixin.py
      - copied, changed from r42282, erp5/trunk/products/ERP5OOo/tests/testFormPrintout.py
Removed:
    erp5/trunk/bt5/erp5_egov/TestTemplateItem/testEGovMixin.py
    erp5/trunk/products/ERP5/tests/testInvoiceVAT.py
    erp5/trunk/products/ERP5OOo/tests/testFormPrintout.py
Modified:
    erp5/trunk/bt5/erp5_egov/bt/revision
    erp5/trunk/bt5/erp5_egov/bt/template_test_id_list
    erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py
    erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODT.py

Copied: erp5/trunk/bt5/erp5_egov/TestTemplateItem/TestEGovMixin.py (from r42282, erp5/trunk/bt5/erp5_egov/TestTemplateItem/testEGovMixin.py)
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_egov/TestTemplateItem/TestEGovMixin.py?p2=erp5/trunk/bt5/erp5_egov/TestTemplateItem/TestEGovMixin.py&p1=erp5/trunk/bt5/erp5_egov/TestTemplateItem/testEGovMixin.py&r1=42282&r2=42283&rev=42283&view=diff
==============================================================================
    (empty)

Removed: erp5/trunk/bt5/erp5_egov/TestTemplateItem/testEGovMixin.py
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_egov/TestTemplateItem/testEGovMixin.py?rev=42282&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_egov/TestTemplateItem/testEGovMixin.py [utf8] (original)
+++ erp5/trunk/bt5/erp5_egov/TestTemplateItem/testEGovMixin.py (removed)
@@ -1,367 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2008 Nexedi SARL and Contributors. All Rights Reserved.
-#                  Fabien Morin <fabien at nexedi.com>
-#
-# 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 Testing.ZopeTestCase.PortalTestCase import PortalTestCase
-from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
-from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
-from AccessControl.SecurityManagement import getSecurityManager
-from Products.ERP5Type.tests.utils import DummyMailHost
-from AccessControl import Unauthorized
-from Testing import ZopeTestCase
-from Products.ERP5Type.tests.Sequence import Step, Sequence, SequenceList
-from zLOG import LOG
-import transaction
-import random
-import email
-from email.Header import decode_header, make_header
-from email.Utils import parseaddr
-
-class TestEGovMixin(SecurityTestCase):
-  """Usefull methods for eGov Unit Tests."""
-  
-  # define all username corresponding to all roles used in eGov
-  assignor_login = 'chef'
-  assignee_login = 'agent'
-  assignee_login_2 = 'agent_2'
-  associate_login = 'agent_requested'
-
-  organisation_1_login = 'societe_a'
-  organisation_2_login = 'societe_b'
-
-  all_username_list = ( assignor_login,
-                        assignee_login,
-                        assignee_login_2,
-                        #associate_login,
-                        organisation_1_login,
-                        organisation_2_login)
-
-  all_role_list = ( 'Manager',
-                    'Assignor',
-                    'Assignee',
-                    'Author',
-                    'Associate',
-                    'Auditor',)
-
-  #Permissions
-  VIEW = 'View'
-  ACCESS = 'Access contents information'
-  ADD = 'Add portal content'
-  MODIFY = 'Modify portal content'
-  DELETE = 'Delete objects'
-
-
-  # use modified method to render a more verbose output
-  def play(self, context, sequence=None, sequence_number=0, quiet=0):
-    if sequence is None:
-      for idx, step in enumerate(self._step_list):
-        step.play(context, sequence=self, quiet=quiet)
-        # commit transaction after each step
-        transaction.commit()
-  Sequence.play = play
-
-  def play(self, context, sequence=None, quiet=0):
-    method_name = 'step' + self._method_name
-    method = getattr(context,method_name)
-    # We can in same cases replay many times the same step,
-    # or not playing it at all
-    nb_replay = random.randrange(0,self._max_replay+1)
-    if self._required:
-      if nb_replay==0:
-        nb_replay=1
-    for i in range(0,nb_replay):
-      if not quiet:
-        ZopeTestCase._print('\n  Playing step %s' % self._method_name)
-        ZopeTestCase._print('\n    -> %s' % method.__doc__)
-        LOG('Step.play', 0, '  Playing step %s' % self._method_name)
-        LOG('Step.play', 0, '    -> %s' % method.__doc__)
-      method(sequence=sequence)
-  Step.play = play
-
-  def playSequence(self, sequence_string, quiet=0) :
-    ZopeTestCase._print('\n\n\n---------------------------------------------------------------------')
-    ZopeTestCase._print('\nStarting New Sequence %s :' % self._TestCase__testMethodName)
-    ZopeTestCase._print('\n * %s... \n' % self._TestCase__testMethodDoc)
-    LOG('Sequence.play', 0, 'Starting New Sequence %s :' % self._TestCase__testMethodName)
-    LOG('Sequence.play', 0, ' * %s... \n' % self._TestCase__testMethodDoc)
-    sequence_list = SequenceList()
-    sequence_list.addSequenceString(sequence_string)
-    sequence_list.play(self, quiet=quiet)
-
-  def getBusinessTemplateList(self):
-    """return list of business templates to be installed. """
-    return ( 'erp5_base',)
-
-  def afterSetUp(self):
-    """
-      Method called before the launch of the test to initialize some data
-    """
-    self.createManagerAndLogin()
-
-    # add a dummy mailhost not to send real messages
-    if 'MailHost' in self.portal.objectIds():
-      self.portal.manage_delObjects(['MailHost'])
-    self.portal._setObject('MailHost', DummyMailHost('MailHost'))
-
-    # remove all message in the message_table because
-    # the previous test might have failed
-    message_list = self.getPortal().portal_activities.getMessageList()
-    for message in message_list:
-      self.getPortal().portal_activities.manageCancel(message.object_path,
-                                                      message.method_id)
-    self.createUsers()
-    self.createOrganisations()
-
-    # XXX quick hack not to have mysql database pre-fill.
-    self.portal.__class__.DeclarationTVA_zGetSIGTASInformation \
-        = lambda x,**kw: []
-
-    transaction.commit()
-    self.tic()
-    
-  def beforeTearDown(self):
-    """Clean up."""
-    for module in self.portal.objectValues(spec=('ERP5 Folder',)):
-      # we want to keep some IDs
-      module.manage_delObjects([x for x in module.objectIds()
-                                if x not in ('EUR',)])
-    transaction.commit()
-    self.tic()
-
-  def getUserFolder(self) :
-    return getattr(self.getPortal(), 'acl_users', None)
-
-  loginAsUser = PortalTestCase.login
-
-  diff_list = lambda self,x,y: [i for i in x if i not in y] 
-
-  def createManagerAndLogin(self):
-    """
-      Create a simple user in user_folder with manager rights.
-      This user will be used to initialize data in the method afterSetup
-    """
-    self.getUserFolder()._doAddUser('manager', 'manager', self.all_role_list, 
-                                    [])
-    self.login('manager')
-  
-  def createOneUser(self, username, function=None, group=None):
-     """Create one person that will be users."""
-     person_module = self.getPersonModule()
-     user = person_module.newContent(
-                              portal_type='Person',
-                              reference=username,
-                              title=username,
-                              id=username,
-                              password='secret')
-     assignment = user.newContent(portal_type='Assignment')
-     if function is not None:
-       assignment.setFunction(function)
-       self.assertNotEqual(assignment.getFunctionValue(), None)
-     if group is not None:
-       assignment.setGroup(group)
-       self.assertNotEqual(assignment.getGroupValue(), None)
-     assignment.open()
-
-  def createUsers(self):
-    """Create persons that will be users."""
-    module = self.getPersonModule()
-    if len(module.getObjectIds()) == 0:
-      # create users
-      self.createOneUser(self.assignor_login, 'function/section/chef', 
-          'group/dgid/di/cge')
-      self.createOneUser(self.assignee_login, 'function/impots/inspecteur', 
-          'group/dgid/di/cge')
-      self.createOneUser(self.assignee_login_2, 'function/impots/inspecteur', 
-          'group/dgid/di/cge')
-      self.createOneUser(self.associate_login, 'function/section/chef', 
-          'group/dgid/di/csf/bf')
-
-      # make this available to catalog
-      transaction.commit()
-      self.tic()
-
-  def createOneOrganisation(self, username, role=None, function=None, 
-                            group=None):
-    """Create one organisation that will be user."""
-    organisation_module = self.getOrganisationModule()
-    user = organisation_module.newContent(
-                             portal_type='Organisation',
-                             title=username,
-                             id=username,
-                             reference=username,
-                             password='secret')
-    user.setRole(role)
-    user.setFunction(function)
-    user.setGroup(group)
-
-    self.assertEqual(user.getRole(), role)
-    self.assertEqual(user.getFunction(), function)
-    self.assertEqual(user.getGroup(), group)
-    self.assertEqual(user.getReference(), username)
-  
-  def createOrganisations(self):
-    """Create organisations that will be users."""
-    module = self.getOrganisationModule()
-    if len(module.getObjectIds()) == 0:
-      self.createOneOrganisation(self.organisation_1_login, 
-          role='entreprise/siege')
-      self.createOneOrganisation(self.organisation_2_login, 
-          role='entreprise/siege')
-
-      # make this available to catalog
-      transaction.commit()
-      self.tic()
-
-  def checkRights(self, object_list, security_mapping, username):
-    self.loginAsUser(username)
-    user = getSecurityManager().getUser()
-    if type(object_list) != type([]):
-      object_list = [object_list,]
-    for object in object_list:
-      for permission, has in security_mapping.items():
-        if user.has_permission(permission, object) and not has:
-          self.fail('%s Permission should be Unauthorized on %s' % \
-                                                ( permission,
-                                                  object.getRelativeUrl()))
-        if not(user.has_permission(permission, object)) and has:
-          self.fail('%s Permission should be Authorized on %s' % \
-                                                ( permission,
-                                                  object.getRelativeUrl()))
-
-  def checkTransition(self, object_list, possible_transition_list, 
-                      not_possible_transition_list, username):
-    
-    if type(object_list) != type([]):
-      object_list = [object_list,]
-    for object in object_list:
-      for transition in possible_transition_list:
-        self.failUnlessUserCanPassWorkflowTransition(username, transition, 
-                                                     object)
-      for transition in not_possible_transition_list:
-        self.failIfUserCanPassWorkflowTransition(username, transition, object)
-
-  # Copied from ERP5Type/patches/CMFMailIn.py
-  def decode_email(self, file):
-    # Prepare result
-    theMail = {
-      'attachment_list': [],
-      'body': '',
-      # Place all the email header in the headers dictionary in theMail
-      'headers': {}
-    }
-    # Get Message
-    msg = email.message_from_string(file)
-    # Back up original file
-    theMail['__original__'] = file
-    # Recode headers to UTF-8 if needed
-    for key, value in msg.items():
-      decoded_value_list = decode_header(value)
-      unicode_value = make_header(decoded_value_list)
-      new_value = unicode_value.__unicode__().encode('utf-8')
-      theMail['headers'][key.lower()] = new_value
-    # Filter mail addresses
-    for header in ('resent-to', 'resent-from', 'resent-cc', 'resent-sender',
-                   'to', 'from', 'cc', 'sender', 'reply-to'):
-      header_field = theMail['headers'].get(header)
-      if header_field:
-          theMail['headers'][header] = parseaddr(header_field)[1]
-    # Get attachments
-    body_found = 0
-    for part in msg.walk():
-      content_type = part.get_content_type()
-      file_name = part.get_filename()
-      # multipart/* are just containers
-      # XXX Check if data is None ?
-      if content_type.startswith('multipart'):
-        continue
-      # message/rfc822 contains attached email message
-      # next 'part' will be the message itself
-      # so we ignore this one to avoid doubling
-      elif content_type == 'message/rfc822':
-        continue
-      elif content_type in ("text/plain", "text/html"):
-        charset = part.get_content_charset()
-        payload = part.get_payload(decode=True)
-        #LOG('CMFMailIn -> ',0,'charset: %s, payload: %s' % (charset,payload))
-        if charset:
-          payload = unicode(payload, charset).encode('utf-8')
-        if body_found:
-          # Keep the content type
-          theMail['attachment_list'].append((file_name,
-                                             content_type, payload))
-        else:
-          theMail['body'] = payload
-          body_found = 1
-      else:
-        payload = part.get_payload(decode=True)
-        # Keep the content type
-        theMail['attachment_list'].append((file_name, content_type,
-                                           payload))
-    return theMail
-
-  def _assertUserExists(self, login, password):
-    """Checks that a user with login and password exists and can log in to the
-    system.
-    """
-    from Products.PluggableAuthService.interfaces.plugins import\
-                                                      IAuthenticationPlugin
-    uf = self.getUserFolder()
-    self.assertNotEquals(uf.getUserById(login, None), None)
-    for plugin_name, plugin in uf._getOb('plugins').listPlugins(
-                                IAuthenticationPlugin ):
-      if plugin.authenticateCredentials(
-                  {'login':login, 'password':password}) is not None:
-        break
-    else:
-      self.fail("No plugin could authenticate '%s' with password '%s'" %
-              (login, password))
-
-  def checkWorklist(self, portal_type, count, validation_state, login):
-    '''
-      check that there is 'count' item in the worklist for 'portal_type' and
-      'validation_state' logged with 'login'
-    '''
-
-    # save previous user
-    previous_user = str(getSecurityManager().getUser())
-    self.loginAsUser(login)
-
-    worklist_dict = self.portal.getPortalTypeWorklistDictForWorkflow(\
-        self.portal,
-        workflow_list=['egov_universal_workflow', 'egov_anonymous_workflow'])
-    self.assertNotEquals(worklist_dict, {})
-    self.assertEquals(worklist_dict.has_key(portal_type), True)
-    portal_type_dict = worklist_dict[portal_type]
-    self.assertEquals(portal_type_dict.has_key(validation_state), True)
-    self.assertEquals(portal_type_dict[validation_state]['count'], count)
-
-    # relog with previous user
-    if previous_user in ('Anonymous User', 'ERP5TypeTestCase'):
-      self.logout()
-    else:
-      self.loginAsUser(previous_user)
- 
-

Modified: erp5/trunk/bt5/erp5_egov/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_egov/bt/revision?rev=42283&r1=42282&r2=42283&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_egov/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_egov/bt/revision [utf8] Wed Jan 12 19:54:36 2011
@@ -1 +1 @@
-746
\ No newline at end of file
+747
\ No newline at end of file

Modified: erp5/trunk/bt5/erp5_egov/bt/template_test_id_list
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_egov/bt/template_test_id_list?rev=42283&r1=42282&r2=42283&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_egov/bt/template_test_id_list [utf8] (original)
+++ erp5/trunk/bt5/erp5_egov/bt/template_test_id_list [utf8] Wed Jan 12 19:54:36 2011
@@ -1 +1 @@
-testEGovMixin
\ No newline at end of file
+TestEGovMixin
\ No newline at end of file

Removed: erp5/trunk/products/ERP5/tests/testInvoiceVAT.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testInvoiceVAT.py?rev=42282&view=auto
==============================================================================
--- erp5/trunk/products/ERP5/tests/testInvoiceVAT.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testInvoiceVAT.py (removed)
@@ -1,514 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2004 Nexedi SARL and Contributors. All Rights Reserved.
-#          Jerome Perrin <jerome at nexedi.com>
-#
-# 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.
-#
-##############################################################################
-"""
-  Tests VAT for invoices.
-  
-Warning: this tests an obsolete API; the test is disabled.
-"""
-
-import unittest
-import transaction
-
-from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
-from AccessControl.SecurityManagement import newSecurityManager
-from Testing.ZopeTestCase import _print
-from DateTime import DateTime
-
-class TestInvoiceVAT(ERP5TypeTestCase):
-  """Test VAT for invoices.
-
-  """
-  
-  RUN_ALL_TESTS = 1
-
-  default_region = "europe/west/france"
-  invoice_portal_type = 'Sale Invoice Transaction'
-  invoice_line_portal_type = 'Invoice Line'
-  invoice_cell_portal_type = 'Invoice Cell'
-  invoice_transaction_line_portal_type = 'Sale Invoice Transaction Line'
-
-  def getTitle(self):
-    return "Invoices and VAT"
-  
-  def afterSetUp(self):
-    """set up """
-    self.createCategories()
-    self.login()
-    self.validateRules()
-  
-  def _safeTic(self):
-    """Like tic, but swallowing errors, usefull for teardown"""
-    try:
-      transaction.commit()
-      self.tic()
-    except RuntimeError:
-      pass
-
-  def beforeTearDown(self):
-    """Clear everything for next test."""
-    self._safeTic()
-    for module in [ 'sale_packing_list_module',
-                    'organisation_module',
-                    'person_module',
-                    'currency_module',
-                    'product_module',
-                    'portal_simulation' ]:
-      folder = getattr(self.getPortal(), module, None)
-      if folder:
-        [x.unindexObject() for x in folder.objectValues()]
-        self._safeTic()
-        folder.manage_delObjects([x.getId() for x in folder.objectValues()])
-    accounting_module = self.getPortal().accounting_module
-    [x.cancel() for x in accounting_module.objectValues()]
-    accounting_module.manage_delObjects([x.getId() for x in
-                                         accounting_module.objectValues()])
-    self._safeTic()
-    # cancel remaining messages
-    activity_tool = self.getPortal().portal_activities
-    for message in activity_tool.getMessageList():
-      activity_tool.manageCancel(message.object_path, message.method_id)
-      _print('\nCancelling active message %s.%s()\n'
-             % (message.object_path, message.method_id) )
-    transaction.commit()
-
-  def login(self, quiet=0, run=1):
-    uf = self.getPortal().acl_users
-    uf._doAddUser('alex', '', ['Manager', 'Assignee', 'Assignor',
-                               'Associate', 'Auditor', 'Author'], [])
-    user = uf.getUserById('alex').__of__(uf)
-    newSecurityManager(None, user)
-  
-  def createCategories(self):
-    """Create the categories for our test. """
-    # create categories
-    for cat_string in self.getNeededCategoryList() :
-      base_cat = cat_string.split("/")[0]
-      path = self.getPortal().portal_categories[base_cat]
-      for cat in cat_string.split("/")[1:] :
-        if not cat in path.objectIds() :
-          path = path.newContent(
-                    portal_type='Category',
-                    id=cat,)
-        else:
-          path = path[cat]
-    # check categories have been created
-    for cat_string in self.getNeededCategoryList() :
-      self.assertNotEquals(None,
-                self.getCategoryTool().restrictedTraverse(cat_string),
-                cat_string)
-                
-  def getNeededCategoryList(self):
-    """return a list of categories that should be created."""
-    return (  'account_type/asset' 
-              'account_type/asset/cash',
-              'account_type/asset/cash/bank',
-              'account_type/asset/receivable',
-              'account_type/asset/receivable/refundable_vat',
-              'account_type/equity',
-              'account_type/expense',
-              'account_type/income',
-              'account_type/liability',
-              'account_type/liability/payable',
-              'account_type/liability/payable/collected_vat',
-              'region/%s' % self.default_region,
-            )
-  
-  def getBusinessTemplateList(self):
-    """ """
-    return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',
-            'erp5_invoicing', 'erp5_simplified_invoicing')
-  
-  def _makeAccount(self, **kw):
-    """Creates an Account."""
-    account = self.getPortal().account_module.newContent(
-          portal_type='Account',
-          **kw)
-    transaction.commit()
-    self.tic()
-    return account
-
-  def _makeOrganisation(self, **kw):
-    """Creates an organisation."""
-    org = self.getPortal().organisation_module.newContent(
-          portal_type='Organisation',
-          **kw)
-    transaction.commit()
-    self.tic()
-    return org
-
-  def _makeSalePackingList(self, **kw):
-    """Creates a sale packing list."""
-    spl = self.getPortal().sale_packing_list_module.newContent(
-          portal_type='Sale Packing List',)
-    spl.edit(**kw)
-    transaction.commit()
-    self.tic()
-    return spl
-  
-  def _makeSaleInvoice(self, created_by_builder=0, **kw):
-    """Creates a sale invoice."""
-    sit = self.getPortal().accounting_module.newContent(
-          portal_type='Sale Invoice Transaction',
-          created_by_builder=created_by_builder)
-    sit.edit(**kw)
-    transaction.commit()
-    self.tic()
-    return sit
-
-  def _makeCurrency(self, **kw):
-    """Creates a currency."""
-    currency = self.getCurrencyModule().newContent(
-            portal_type = 'Currency', **kw)
-    transaction.commit()
-    self.tic()
-    return currency
-  
-  def _makeResource(self, **kw):
-    """Creates a resource."""
-    resource = self.getPortal().product_module.newContent(
-                      portal_type='Product', **kw)
-    transaction.commit()
-    self.tic()
-    return resource
-
-  def _makeSimpleInvoiceTransactionRule(self, resource, receivable_account,
-                                        vat_account, income_account):
-    """A simple invoice transaction rule, with only one accounting cell,
-
-                          Debit        Credit
-    receivable account     1.1
-    vat account                          0.1
-    income account                        1
-
-    """
-    itr = self.getPortal().portal_rules.default_invoice_transaction_simulation_rule
-    itr.manage_delObjects([x for x in itr.objectIds()])
-    pred = itr.newContent(portal_type='Predicate')
-    pred.setStringIndex('product')
-    pred.setIntIndex(1) # XXX is it usefull ?
-    pred.setMembershipCriterionBaseCategoryList('resource')
-    pred.setMembershipCriterionCategoryList(['resource/%s' %
-                                             resource.getRelativeUrl()])
-    transaction.commit()
-    self.tic()
-    itr.updateMatrix()
-
-    cell_list = itr.getCellValueList(base_id='movement')
-    self.assertEquals(len(cell_list), 1)
-    cell = cell_list[0]
-    cell.newContent(
-              portal_type = 'Accounting Transaction Line',
-              source_value = receivable_account,
-              quantity=-1.1 )
-    cell.newContent(
-              portal_type = 'Accounting Transaction Line',
-              source_value = vat_account,
-              quantity=.1 )
-    cell.newContent(
-              portal_type = 'Accounting Transaction Line',
-              source_value = income_account,
-              quantity=1 )
-
-  def _stopPackingList(self, packing_list):
-    """Stop a packing list, this will trigger invoice generation with
-    the builder.
-    """
-    packing_list.confirm()
-    packing_list.setReady()
-    packing_list.start()
-    transaction.commit()
-    self.tic()
-    packing_list.stop()
-    self.assertEquals(packing_list.getSimulationState(), 'stopped')
-    transaction.commit()
-    self.tic()
-    
-  def _makeOnePackingList(self):
-    """Returns currency, resource, receivable_account, vat_account,
-      income_account, section, mirror_section and packing_list.
-
-      The packing list is ready to test.
-    """
-    currency = self._makeCurrency()
-    resource = self._makeResource()
-    receivable_account = self._makeAccount(
-                    account_type='asset/receivable')
-    self.assertNotEquals(receivable_account.getAccountTypeValue(), None)
-    vat_account = self._makeAccount(
-                    account_type='liability/payable/collected_vat')
-    self.assertNotEquals(vat_account.getAccountTypeValue(), None)
-    income_account = self._makeAccount(account_type='income')
-    self.assertNotEquals(income_account.getAccountTypeValue(), None)
-
-    self._makeSimpleInvoiceTransactionRule(
-                        resource=resource,
-                        receivable_account=receivable_account,
-                        vat_account=vat_account,
-                        income_account=income_account )
-
-    section = self._makeOrganisation(title='Section')
-    mirror_section = self._makeOrganisation(title='Mirror Section')
-    packing_list = self._makeSalePackingList(
-                                source_value=section,
-                                source_section_value=section,
-                                destination_value=mirror_section,
-                                destination_section_value=mirror_section,
-                                price_currency_value=currency,
-                                start_date=DateTime())
-    return (currency, resource, receivable_account, vat_account,
-            income_account, section, mirror_section, packing_list)
-  
-  def _makeOneInvoice(self):
-    """Returns currency, resource, receivable_account, vat_account,
-      income_account, section, mirror_section and invoice
-
-      The invoice is ready to test.
-    """
-    currency = self._makeCurrency()
-    resource = self._makeResource()
-    receivable_account = self._makeAccount(
-                    account_type='asset/receivable')
-    self.assertNotEquals(receivable_account.getAccountTypeValue(), None)
-    vat_account = self._makeAccount(
-                    account_type='liability/payable/collected_vat')
-    self.assertNotEquals(vat_account.getAccountTypeValue(), None)
-    income_account = self._makeAccount(account_type='income')
-    self.assertNotEquals(income_account.getAccountTypeValue(), None)
-
-    self._makeSimpleInvoiceTransactionRule(
-                        resource=resource,
-                        receivable_account=receivable_account,
-                        vat_account=vat_account,
-                        income_account=income_account )
-
-    section = self._makeOrganisation(title='Section')
-    mirror_section = self._makeOrganisation(title='Mirror Section')
-    sale_invoice = self._makeSaleInvoice(
-                                source_value=section,
-                                source_section_value=section,
-                                destination_value=mirror_section,
-                                destination_section_value=mirror_section,
-                                price_currency_value=currency,
-                                created_by_builder=1, # XXX this prevent
-                                                      # init scripts from
-                                                      # creating lines
-                                start_date=DateTime())
-    return (currency, resource, receivable_account, vat_account,
-            income_account, section, mirror_section, sale_invoice)
-  
-  def _checkInvoiceVAT(self, invoice, total_price, vat_ratio,
-                    total_vat_amount):
-    """Check the VAT for this invoice.
-    This check will first check VAT on the invoice, then confirm the
-    invoice, so that transaction lines are generated, and make sure
-    values are still correct when read on the accounting lines rather
-    than on the simulation. 
-
-      o invoice: The Invoice object
-      o total_price: The total price that this invoice is supposed to
-          have (ie. the receivable quantity)
-      o vat_ratio: The VAT ratio.
-      o total_vat_amount: The value for the VAT.
-    """
-    # check vat informations
-    vat_info = invoice.SaleInvoiceTransaction_getVAT()
-    self.assertEquals(total_price, sum([line.getTotalPrice() for line in
-                                        invoice.getMovementList()]))
-    self.assertEquals(vat_info['total'], total_vat_amount)
-    self.assertEquals(vat_info['ratio'], vat_ratio)
-    
-    # confirm the invoice, 
-    invoice.confirm()
-    transaction.commit()
-    self.tic()
-    # this will generate accounting lines
-    self.assertNotEquals(len(invoice.getMovementList(
-      portal_type=self.getPortal().getPortalAccountingMovementTypeList())), 0)
-    # and vat information will still be OK
-    vat_info = invoice.SaleInvoiceTransaction_getVAT()
-    self.assertEquals(total_price, sum([line.getTotalPrice() for line in
-                                        invoice.getMovementList()]))
-    self.assertEquals(vat_info['total'], total_vat_amount)
-    self.assertEquals(vat_info['ratio'], vat_ratio)
-
-
-  # invoice without packing list related
-
-  def test_SimpleInvoice(self, quiet=0, run=RUN_ALL_TESTS):
-    """Test VAT for a simple invoice created directly. """
-    ( currency, resource, receivable_account, vat_account,
-      income_account, section, mirror_section, invoice
-     ) = self._makeOneInvoice()
-    
-    # add lines in the invoice
-    for i in (1, 2):
-      line = invoice.newContent(
-                    portal_type='Invoice Line',)
-      line.edit(quantity=10,
-                price=100,
-                resource_value=resource )
-    invoice.plan()
-    transaction.commit();
-    self.tic()
-
-    # actual values on invoice line should be:
-    total_price = 2 * 10 * 100
-    vat_ratio = .1
-    total_vat_amount = total_price * vat_ratio
-    self._checkInvoiceVAT(invoice, total_price, vat_ratio,
-                          total_vat_amount)
-  
-  def test_SimpleInvoiceEmptyLines(self, quiet=0, run=RUN_ALL_TESTS):
-    """Test VAT for a simple invoice created directly; empty lines should not
-    be a problem."""
-    ( currency, resource, receivable_account, vat_account,
-      income_account, section, mirror_section, invoice
-     ) = self._makeOneInvoice()
-    
-    # add lines in the invoice
-    for i in (1, 2):
-      line = invoice.newContent(
-                    portal_type='Invoice Line',)
-      line.edit(quantity=10,
-                price=100,
-                resource_value=resource )
-    invoice.plan()
-    transaction.commit();
-    self.tic()
-    
-    # actual values on invoice line should be:
-    total_price = 2 * 10 * 100
-    vat_ratio = .1
-    total_vat_amount = total_price * vat_ratio
-    self._checkInvoiceVAT(invoice, total_price, vat_ratio,
-                          total_vat_amount)
-
-    # same if we add an empty invoice line
-    invoice.newContent(portal_type='Invoice Line')
-    self._checkInvoiceVAT(invoice, total_price, vat_ratio,
-                          total_vat_amount)
-    # ... or an empty accouting line
-    invoice.newContent(portal_type='Sale Invoice Transaction Line')
-    self._checkInvoiceVAT(invoice, total_price, vat_ratio,
-                          total_vat_amount)
-
-  def TODOtest_SimpleInvoiceTwoResources(self, quiet=0, run=RUN_ALL_TESTS):
-    """Test VAT, for two resources, where only one requires VAT """
-    ( currency, resource, receivable_account, vat_account,
-      income_account, section, mirror_section, invoice
-     ) = self._makeOneInvoice()
-    
-    another_resource = self._makeResource(title='Another resource')
-
-    # add lines in the invoice
-    for res in (resource, another_resource):
-      line = invoice.newContent(
-                    portal_type='Invoice Line',)
-      line.edit(quantity=10,
-                price=100,
-                resource_value=res )
-    invoice.plan()
-    transaction.commit();
-    self.tic()
-
-    # actual values on invoice line should be:
-    total_price = 2 * 10 * 100
-    vat_ratio = .1
-    total_vat_amount = 10 * 100 * vat_ratio # only one line with VAT
-    self._checkInvoiceVAT(invoice, total_price, vat_ratio,
-                          total_vat_amount)
-
-  # invoice from a packing list
-
-  def test_InvoiceTwoLinesWithSameResource(self, quiet=0,
-                                           run=RUN_ALL_TESTS):
-    """Test VAT for an invoice that cames from a packing list with two
-    lines of the same resource.
-    """
-    ( currency, resource, receivable_account, vat_account,
-      income_account, section, mirror_section, packing_list
-     ) = self._makeOnePackingList()
-    
-    # add lines in the packing list
-    for i in (1, 2):
-      line = packing_list.newContent(
-                    portal_type='Sale Packing List Line',)
-      line.edit(quantity=10,
-                price=100,
-                resource_value=resource )
-    
-    self._stopPackingList(packing_list)
-    invoice = packing_list.getCausalityRelatedValue(
-                                  portal_type='Sale Invoice Transaction')
-    self.assertNotEquals(invoice, None)
-
-    # actual values on invoice line should be:
-    total_price = 2 * 10 * 100
-    vat_ratio = .1
-    total_vat_amount = total_price * vat_ratio
-
-    self._checkInvoiceVAT(invoice, total_price, vat_ratio,
-                          total_vat_amount)
-  
-  def test_InvoiceTwoLinesWithSameResourceDifferentDate(self, quiet=0,
-                                                   run=RUN_ALL_TESTS):
-    """Test VAT for an invoice that cames from a packing list with two
-    lines of the same resource, with different dates.
-    """
-    ( currency, resource, receivable_account, vat_account,
-      income_account, section, mirror_section, packing_list
-     ) = self._makeOnePackingList()
-    
-    date = DateTime()
-    # add lines in the packing list
-    for i in (1, 2):
-      line = packing_list.newContent(
-                    portal_type='Sale Packing List Line',)
-      line.edit(quantity=10,
-                price=100,
-                date=date + i,
-                resource_value=resource )
-    
-    self._stopPackingList(packing_list)
-    invoice = packing_list.getCausalityRelatedValue(
-                                  portal_type='Sale Invoice Transaction')
-    self.assertNotEquals(invoice, None)
-
-    # actual values on invoice line should be:
-    total_price = 2 * 10 * 100
-    vat_ratio = .1
-    total_vat_amount = total_price * vat_ratio
-    
-    self._checkInvoiceVAT(invoice, total_price, vat_ratio,
-                          total_vat_amount)
-
-def test_suite():
-  suite = unittest.TestSuite()
-  #suite.addTest(unittest.makeSuite(TestInvoiceVAT))
-  return suite
-

Copied: erp5/trunk/products/ERP5Legacy/tests/_testInvoiceVAT.py (from r42282, erp5/trunk/products/ERP5/tests/testInvoiceVAT.py)
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Legacy/tests/_testInvoiceVAT.py?p2=erp5/trunk/products/ERP5Legacy/tests/_testInvoiceVAT.py&p1=erp5/trunk/products/ERP5/tests/testInvoiceVAT.py&r1=42282&r2=42283&rev=42283&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testInvoiceVAT.py [utf8] (original)
+++ erp5/trunk/products/ERP5Legacy/tests/_testInvoiceVAT.py [utf8] Wed Jan 12 19:54:36 2011
@@ -509,6 +509,6 @@ class TestInvoiceVAT(ERP5TypeTestCase):
 
 def test_suite():
   suite = unittest.TestSuite()
-  #suite.addTest(unittest.makeSuite(TestInvoiceVAT))
+  suite.addTest(unittest.makeSuite(TestInvoiceVAT))
   return suite
 

Copied: erp5/trunk/products/ERP5OOo/tests/TestFormPrintoutMixin.py (from r42282, erp5/trunk/products/ERP5OOo/tests/testFormPrintout.py)
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/TestFormPrintoutMixin.py?p2=erp5/trunk/products/ERP5OOo/tests/TestFormPrintoutMixin.py&p1=erp5/trunk/products/ERP5OOo/tests/testFormPrintout.py&r1=42282&r2=42283&rev=42283&view=diff
==============================================================================
    (empty)

Removed: erp5/trunk/products/ERP5OOo/tests/testFormPrintout.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testFormPrintout.py?rev=42282&view=auto
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testFormPrintout.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testFormPrintout.py (removed)
@@ -1,70 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# Copyright (c) 2009 Nexedi KK and Contributors. All Rights Reserved.
-#                    Tatuya Kamada <tatuya at nexedi.com>
-#                    Fabien Morin <fabien at 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
-# USA.
-#
-##############################################################################
-
-
-from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
-from AccessControl.SecurityManagement import newSecurityManager
-from StringIO import StringIO
-
-class TestFormPrintoutMixin(ERP5TypeTestCase):
-  run_all_test = 1
-
-  def getBusinessTemplateList(self):
-    return ('erp5_base', 'erp5_ui_test', 'erp5_odt_style')
-
-  def login(self):
-    uf = self.getPortal().acl_users
-    uf._doAddUser('zope', '', ['Manager'], [])
-    user = uf.getUserById('zope').__of__(uf)
-    newSecurityManager(None, user)
-
-  def setSystemPreference(self):
-    default_pref = self.portal.portal_preferences.default_site_preference
-    default_pref.setPreferredOoodocServerAddress('127.0.0.1')
-    default_pref.setPreferredOoodocServerPortNumber('8008')
-    #default_pref.setPreferredConversionCacheFactory('document_cache_factory')
-    if default_pref.getPreferenceState() != 'global':
-      default_pref.enable()
-
-  def _validate(self, odf_file_data):
-    error_list = self.validator.validate(odf_file_data)
-    if error_list:
-      self.fail(''.join(error_list))
-
-  def getODFDocumentFromPrintout(self, printout_form):
-    '''return odf document from the printout
-    '''
-    document_file = getattr(self.portal, printout_form.template, None)
-    document_file = StringIO(document_file).read()
-    if document_file is not None:
-      return document_file
-    raise ValueError ('%s template not found' % printout_form.template)
-

Modified: erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py?rev=42283&r1=42282&r2=42283&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODG.py [utf8] Wed Jan 12 19:54:36 2011
@@ -30,7 +30,7 @@
 import unittest
 import transaction
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
-from Products.ERP5OOo.tests.testFormPrintout import TestFormPrintoutMixin
+from Products.ERP5OOo.tests.TestFormPrintoutMixin import TestFormPrintoutMixin
 from Products.ERP5OOo.OOoUtils import OOoBuilder
 from Products.ERP5OOo.tests.utils import Validator
 from Products.ERP5Type.tests.utils import FileUpload

Modified: erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODT.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODT.py?rev=42283&r1=42282&r2=42283&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODT.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testFormPrintoutAsODT.py [utf8] Wed Jan 12 19:54:36 2011
@@ -33,7 +33,7 @@ import unittest
 import transaction
 from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
 from Products.ERP5Type.tests.backportUnittest import skip
-from Products.ERP5OOo.tests.testFormPrintout import TestFormPrintoutMixin
+from Products.ERP5OOo.tests.TestFormPrintoutMixin import TestFormPrintoutMixin
 from Products.ERP5Type.tests.utils import createZODBPythonScript
 from Products.MimetypesRegistry.mime_types.magic import guessMime
 from Products.ERP5OOo.OOoUtils import OOoBuilder



More information about the Erp5-report mailing list