testMaxmaDemoConfigurationWorkflow.py 9.79 KB
Newer Older
Rafael Monnerat's avatar
Rafael Monnerat committed
1
##############################################################################
Rafael Monnerat's avatar
Rafael Monnerat committed
2
# Copyright (c) 2011 Nexedi SA and Contributors. All Rights Reserved.
Rafael Monnerat's avatar
Rafael Monnerat committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#                     Rafael Monnerat <rafael@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 Products.ERP5Configurator.tests.ConfiguratorTestMixin import \
    TestLiveConfiguratorWorkflowMixin
from Products.ERP5Type.tests.Sequence import SequenceList

class TestMaxmaDemoConfiguratorWorkflow(TestLiveConfiguratorWorkflowMixin):
  """
    Configurator Mixin Class
  """
  # The list of standard business templates that the configurator should force
  # to install
Rafael Monnerat's avatar
Rafael Monnerat committed
38
  user_reference = "demo"
Rafael Monnerat's avatar
Rafael Monnerat committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
  standard_bt5_list = ('erp5_simulation',
                       'erp5_dhtml_style',
                       'erp5_jquery',
                       'erp5_jquery_ui',
                       'erp5_xhtml_jquery_style',
                       'erp5_ingestion_mysql_innodb_catalog',
                       'erp5_ingestion',
                       'erp5_web',
                       'erp5_dms',
                       'erp5_crm',
                       'erp5_pdm',
                       'erp5_trade',
                       'erp5_knowledge_pad',
                       'erp5_accounting',
                       'erp5_tax_resource',
                       'erp5_discount_resource',
                       'erp5_invoicing',
                       'erp5_configurator_standard_categories',
                       'erp5_trade_knowledge_pad',
                       'erp5_crm_knowledge_pad',
                       'erp5_simulation_test',
                       'erp5_simplified_invoicing',
                       'erp5_ods_style',
                       'erp5_odt_style',
                       'erp5_ooo_import',
                       'erp5_accounting_l10n_fr',
                       'erp5_l10n_fr',
                       'erp5_l10n_pt-BR',
                       'erp5_demo_maxma_rule')

  def getBusinessTemplateList(self):
    return ('erp5_core_proxy_field_legacy',
        'erp5_full_text_myisam_catalog',
        'erp5_base',
        'erp5_workflow',
        'erp5_configurator',
        'erp5_configurator_maxma_demo',)

Rafael Monnerat's avatar
Rafael Monnerat committed
77 78
  def stepCreateBusinessConfiguration(self, sequence=None,\
                   sequence_list=None, **kw):
Rafael Monnerat's avatar
Rafael Monnerat committed
79 80 81 82 83 84 85 86 87
    """ Create one Business Configuration """
    module = self.portal.business_configuration_module
    business_configuration = module.newContent(
                               portal_type="Business Configuration",
                               title='Test Configurator Maxma Demo Workflow')
    next_dict = {}
    sequence.edit(business_configuration=business_configuration,
                  next_dict=next_dict)

Rafael Monnerat's avatar
Rafael Monnerat committed
88 89
  def stepCheckConfigureInstallationForm(self, sequence=None,\
                    sequence_list=None, **kw):
Rafael Monnerat's avatar
Rafael Monnerat committed
90 91 92 93 94 95 96 97 98 99 100 101 102
    """ Check the installation form """
    response_dict = sequence.get("response_dict")
    # configuration is finished. We are at the Install state.
    # On maxma demo, installation is the first slide.
    self.assertEquals('show', response_dict['command'])
    self.assertEquals('Install', response_dict['next'])

  def stepSetMaxmaDemoWorkflow(self, sequence=None, sequence_list=None, **kw):
    """ Set Consulting Workflow into Business Configuration """
    self.portal.portal_templates.updateRepositoryBusinessTemplateList(
                                    ['file:///home/rafael/erp5/express/bt5'])
    business_configuration = sequence.get("business_configuration")
    self.setBusinessConfigurationWorkflow(business_configuration,
Rafael Monnerat's avatar
Rafael Monnerat committed
103 104 105
                          "workflow_module/maxma_demo_configuration_workflow")


106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
  def stepViewCreatedPersons(self, sequence=None, sequence_list=None, **kw):
    self.login(user_name='test_configurator_user')
    person_list = self.portal.person_module.searchFolder()
    self.assertNotEquals(0, len(person_list))

    for entity in person_list:
      for username in self.all_username_list:
        self.failUnlessUserCanAccessDocument(username, entity)
        self.failUnlessUserCanViewDocument(username, entity)

  def stepViewCreatedOrganisations(self, sequence=None, sequence_list=None, **kw):
    self.login(user_name='test_configurator_user')
    organisation_list = self.portal.organisation_module.searchFolder()
    self.assertNotEquals(0, len(organisation_list))

    for entity in organisation_list:
      for username in self.all_username_list:
        self.failUnlessUserCanAccessDocument(username, entity)
        self.failUnlessUserCanViewDocument(username, entity)

  def stepViewCreatedAssignemnts(self, sequence=None, sequence_list=None, **kw):
    self.login(user_name='test_configurator_user')
    person_list = self.portal_person_module.searchFolder()
    self.assertNotEquals(0, len(person_list))

    for person in person_list:
      for assignment in person.contentValues(portal_type='Assignment'):
        for username in self.all_username_list:
          self.failUnlessUserCanAccessDocument(username, assignment)
          self.failUnlessUserCanViewDocument(username, assignment)


  def stepCheckMaxmaDemoSampleObjectList(self, sequence=None, sequence_list=None, **kw):
Rafael Monnerat's avatar
Rafael Monnerat committed
139
    """ Check if objects are placed into the appropriate state """
140

Rafael Monnerat's avatar
Rafael Monnerat committed
141 142 143 144 145 146
    # Check Gadgets
    for gadget in self.portal.portal_gadgets.searchFolder():
      self.assertEquals('public', gadget.getValidationState(),
                        "%s is not public but %s" % (gadget.getRelativeUrl(), 
                                                     gadget.getValidationState()))
      gadget.Base_checkConsistency()
147

Rafael Monnerat's avatar
Rafael Monnerat committed
148 149 150 151 152 153 154 155 156 157
    # Check if demo user is working.
    user = self.portal.portal_catalog.getResultValue(portal_type="Person",
    reference=self.user_reference)

    self.assertNotEquals(user.Person_getAvailableAssignmentValueList(), [])
    self.assertEquals(user.getTitle(), "Jack Vale")
    self.assertEquals(user.getValidationState(), "validated")
    self.assertEquals(user.getSubordination(), 
                          'organisation_module/myorganisation')
    self.assertEquals(user.getSubordinationTitle(), "Maxma Co")
Rafael Monnerat's avatar
Rafael Monnerat committed
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175

  ### STEPS
  DEFAULT_SEQUENCE_LIST = """
      stepCreateBusinessConfiguration
      stepTic
      stepSetMaxmaDemoWorkflow
      stepTic
      stepConfiguratorNext
      stepTic
      stepCheckBT5ConfiguratorItem
      stepCheckConfigureInstallationForm
      stepSetupInstallConfiguration
      stepConfiguratorNext
      stepTic
      stepCheckInstallConfiguration
      stepStartConfigurationInstallation
      stepTic
      stepCheckInstanceIsConfigured%(country)s
Rafael Monnerat's avatar
Rafael Monnerat committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
      stepCheckMaxmaDemoSampleObjectList
      stepTic
      stepViewAddGadget
      stepViewEventModule
      stepAddEvent
      stepSentEventWorkflow
      stepViewAccountModule
      stepAddAccountModule
      stepViewAccount
      stepCopyPasteAccount
      stepViewEntityModules
      stepAddEntityModules
      stepCopyAndPastePerson
      stepCopyAndPasteOrganisation
      stepEntityWorkflow
      stepViewCreatedPersons
      stepViewCreatedOrganisations
      stepViewCreatedAssignemnts
      stepAddAccoutingPeriod
      stepValidatedAccountingPeriods
      stepViewBankAccount
      stepViewCreditCard
      stepValidateAndModifyBankAccount
      stepValidateAndModifyCreditCard
      stepAddPaymentNodeInPerson
      stepAddPaymentNodeInOrganisation
      stepCopyAndPasteBankAccountInPerson
      stepCopyAndPasteBankAccountInOrganisation
      stepViewAccountingTransactionModule
      stepAddAccountingTransactionModule
      stepCopyAndPasteAccountingTransactions
      stepTic
      stepAccountingTransaction
      stepTic
      stepSaleInvoiceTransaction
      stepTic
      stepPurchaseInvoiceTransaction
      stepTic
      stepPaymentTransaction
      stepTic
      stepBalanceTransaction
      stepTic
      stepAccountingTransaction_getCausalityGroupedAccountingTransactionList
      stepAddAssignments
      stepAssignmentTI
      stepEditAssignments
      stepViewAcessAddPurchaseTradeCondition
      stepViewAccessAddSaleTradeCondition
      stepViewAccessAddSaleOrder
      stepViewAccessAddSalePackingList
      stepViewAccessPurchaseOrder
      stepPurchasePackingList
Rafael Monnerat's avatar
Rafael Monnerat committed
228 229 230 231
      """

  def test_maxma_demo_workflow(self):
    """ Test the consulting workflow configuration"""
Rafael Monnerat's avatar
Rafael Monnerat committed
232
    self.all_username_list = ["demo"]
233 234 235 236 237
    self.accountant_username_list = self.all_username_list
    self.sales_and_purchase_username_list = self.all_username_list
    self.warehouse_username_list = self.all_username_list
    self.simple_username_list = self.all_username_list
    self.restricted_security = 0
Rafael Monnerat's avatar
Rafael Monnerat committed
238 239 240 241 242 243 244 245 246 247
    sequence_list = SequenceList()
    sequence_string = self.DEFAULT_SEQUENCE_LIST % dict(country='France')
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)

import unittest
def test_suite():
  suite = unittest.TestSuite()
  suite.addTest(unittest.makeSuite(TestMaxmaDemoConfiguratorWorkflow))
  return suite