testUNGConfigurationWorkflow.py 15.1 KB
Newer Older
Gabriel Monnerat's avatar
Gabriel Monnerat committed
1 2 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
##############################################################################
# Copyright (c) 2011 Nexedi SA and Contributors. All Rights Reserved.
#                     Gabriel M. Monnerat <gabriel@tiolive.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.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList

class TestUNGConfiguratorWorkflow(ERP5TypeTestCase):
  """
    Test Live UNG Configuration Workflow.
  """

36 37
  standard_bt5_list = ('erp5_ingestion_mysql_innodb_catalog',
                       'erp5_simulation',
Gabriel Monnerat's avatar
Gabriel Monnerat committed
38 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
                       'erp5_dhtml_style',
                       'erp5_jquery',
                       'erp5_jquery_ui',
                       'erp5_web',
                       'erp5_ingestion',
                       'erp5_dms',
                       'erp5_crm',
                       'erp5_knowledge_pad',
                       'erp5_jquery_plugin_spinbtn',
                       'erp5_jquery_plugin_jgraduate',
                       'erp5_jquery_plugin_svgicon',
                       'erp5_jquery_plugin_hotkey',
                       'erp5_jquery_plugin_jquerybbq',
                       'erp5_jquery_plugin_svg_editor',
                       'erp5_jquery_plugin_sheet',
                       'erp5_jquery_plugin_mbmenu',
                       'erp5_jquery_plugin_jqchart',
                       'erp5_jquery_plugin_colorpicker',
                       'erp5_jquery_plugin_elastic',
                       'erp5_jquery_plugin_wdcalendar',
                       'erp5_jquery_sheet_editor',
                       'erp5_xinha_editor',
                       'erp5_svg_editor',
#                      'erp5_mail_reader',
                       'erp5_web_ung_core',
                       'erp5_web_ung_theme',
                       'erp5_web_ung_role')

  DEFAULT_SEQUENCE_LIST = """
     stepCreateBusinessConfiguration
Gabriel Monnerat's avatar
Gabriel Monnerat committed
68
     stepSetUNGWorkflow
Gabriel Monnerat's avatar
Gabriel Monnerat committed
69 70 71 72 73 74 75 76 77
     stepConfiguratorNext
     stepTic
     stepCheckBT5ConfiguratorItem
     stepCheckConfigureOrganisationForm
     stepSetupOrganisationConfiguratorItem
     stepConfiguratorNext
     stepTic
     stepCheckConfigureUserAccountNumberForm
     stepCheckOrganisationConfiguratorItem
78
     stepSetupUserAccountNumberThree
Gabriel Monnerat's avatar
Gabriel Monnerat committed
79 80 81 82 83 84 85 86 87
     stepConfiguratorNext
     stepTic
     stepCheckConfigureMultipleUserAccountForm
     stepSetupMultipleUserAccountThree
     stepConfiguratorNext
     stepTic
     stepCheckConfigurePreferenceForm
     stepSetupPreferenceConfigurationBrazil
     stepConfiguratorNext
Gabriel Monnerat's avatar
Gabriel Monnerat committed
88
     stepTic
89
     stepCheckConfigureWebSiteForm
90
     stepCheckPreferenceConfigurationBrazil
91
     stepSetupWebSiteConfiguration
92 93 94 95 96 97 98 99
     stepConfiguratorNext
     stepTic
     stepCheckConfigureInstallationForm
     stepSetupInstallConfiguration
     stepConfiguratorNext
     stepTic
     stepCheckInstallConfiguration
     stepStartConfigurationInstallation
100
     stepTic
101
     stepCheckUNGWebSiteAfterInstallation
Gabriel Monnerat's avatar
Gabriel Monnerat committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
  """

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

  def afterSetUp(self):
    self.portal.portal_templates.updateRepositoryBusinessTemplateList(
                           ['http://www.erp5.org/dists/snapshot/bt5/'])

  def stepCreateBusinessConfiguration(self,  sequence=None, sequence_list=None, **kw):
    """ Create one Business Configuration """
    module = self.portal.business_configuration_module
    business_configuration = module.newContent(
                               portal_type="Business Configuration",
                               title='Test Configurator UNG Workflow')
    next_dict = {}
    sequence.edit(business_configuration=business_configuration, 
                  next_dict=next_dict)

Gabriel Monnerat's avatar
Gabriel Monnerat committed
126 127
  def stepSetUNGWorkflow(self, sequence=None, sequence_list=None, **kw):
    """ Set UNG Workflow into Business Configuration """
Gabriel Monnerat's avatar
Gabriel Monnerat committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
    business_configuration = sequence.get("business_configuration")
    self.setBusinessConfigurationWorkflow(business_configuration,
                                   "workflow_module/ung_configuration_workflow")

  def assertCurrentStep(self, step_title, server_response):
    """ Checks the current step title. """
    self.assertTrue(
      '<h2>%s</h2>' % step_title in server_response['data'],
      'Unable to guess current step title (expected:%s) in: \n%s' %
      (step_title, server_response))

  def stepConfiguratorNext(self, sequence=None, sequence_list=None, **kw):
    """ Go Next into Configuration """
    business_configuration = sequence.get("business_configuration")
    next_dict = sequence.get("next_dict")
    response_dict = self.portal.portal_configurator._next(
                            business_configuration, next_dict)

    sequence.edit(response_dict=response_dict)

  def setBusinessConfigurationWorkflow(self, business_configuration, workflow):
    """ Set configurator workflow """
    business_configuration.setResource(workflow)

  def stepCheckBT5ConfiguratorItem(self, sequence=None, sequence_list=None, **kw):
    """ Check if the Configuration Item list is correct """
    business_configuration = sequence.get("business_configuration")
    # second one: install some standard business templates
    standard_bt5_config_save = business_configuration['1']
    self.assertEquals(len(self.standard_bt5_list),
          len(standard_bt5_config_save.contentValues(
                  portal_type='Standard BT5 Configurator Item')))
    self.assertEquals(
      set(self.standard_bt5_list),
      set([x.bt5_id for x in standard_bt5_config_save.contentValues()]))

  def stepCheckConfigureOrganisationForm(self, sequence=None, sequence_list=None, **kw):
    """ Check if Confire Configure step was showed """
    response_dict = sequence.get("response_dict")
    if 'command' in response_dict:
      self.assertEquals('show', response_dict['command'])
    self.assertEquals(None, response_dict['previous'])
    self.assertEquals('Configure Organisation', response_dict['next'])
    self.assertCurrentStep('Your Organisation', response_dict)

  def stepSetupOrganisationConfiguratorItem(self, sequence=None, sequence_list=None, **kw):
    """ Create one Organisation with Basic information """
    next_dict = dict(
        field_your_title='My Organisation',
        field_your_default_email_text='me@example.com',
        field_your_default_telephone_text='01234567890',
        field_your_default_address_street_address='.',
        field_your_default_address_zip_code='59000')
    sequence.edit(next_dict=next_dict)

  def stepCheckConfigureUserAccountNumberForm(self, sequence=None, sequence_list=None, **kw):
    """ """
    response_dict = sequence.get("response_dict")
    if 'command' in response_dict:
      self.assertEquals('show', response_dict['command'])
    self.assertEquals('Configure user accounts number', response_dict['next'])
    self.assertEquals('Previous', response_dict['previous'])
Gabriel Monnerat's avatar
Gabriel Monnerat committed
190
    self.assertCurrentStep('Number of user accounts', response_dict)
Gabriel Monnerat's avatar
Gabriel Monnerat committed
191 192 193 194 195

  def stepCheckOrganisationConfiguratorItem(self, sequence=None, sequence_list=None, **kw):
    """ Check if organisation was created fine """
    business_configuration = sequence.get("business_configuration")
    organisation_config_save = business_configuration['3']
196
    self.assertEquals(organisation_config_save.getTitle(),
Gabriel Monnerat's avatar
Gabriel Monnerat committed
197 198 199 200 201 202 203
                      "My Organisation")
    self.assertEquals(1, len(organisation_config_save.contentValues()))
    organisation_config_item = organisation_config_save['1']
    self.assertEquals(organisation_config_item.getPortalType(),
                      'Organisation Configurator Item')
    self.assertEquals(organisation_config_item.getDefaultEmailText(),
                      'me@example.com')
Gabriel Monnerat's avatar
Gabriel Monnerat committed
204

205
  def stepSetupUserAccountNumberThree(self, sequence=None, sequence_list=None, **kw):
Gabriel Monnerat's avatar
Gabriel Monnerat committed
206 207 208 209 210 211 212 213 214 215 216 217
    """ Create one more user account """
    next_dict = dict(field_your_user_number="3")
    sequence.edit(next_dict=next_dict)

  def stepCheckConfigureMultipleUserAccountForm(self, sequence=None, sequence_list=None, **kw):
    """ Check the multiple user account form """
    response_dict = sequence.get("response_dict")
    if 'command' in response_dict:
      self.assertEquals('show', response_dict['command'])
    self.assertEquals('Previous', response_dict['previous'])
    self.assertEquals('Configure user accounts', response_dict['next'])
    self.assertCurrentStep('Configuration of users', response_dict)
Gabriel Monnerat's avatar
Gabriel Monnerat committed
218
 
Gabriel Monnerat's avatar
Gabriel Monnerat committed
219 220 221 222 223 224 225 226 227
  def stepSetupMultipleUserAccountThree(self, sequence=None, sequence_list=None, **kw):
    """ Create multiple user account """
    user_list = [
      dict(
        field_your_first_name='Person',
        field_your_last_name='Creator',
        field_your_reference="person_creator",
        field_your_password='person_creator',
        field_your_password_confirm='person_creator',
Gabriel Monnerat's avatar
Gabriel Monnerat committed
228
        field_your_default_email_text='test@test.com',
Gabriel Monnerat's avatar
Gabriel Monnerat committed
229 230 231 232 233 234 235
        field_your_default_telephone_text='',
      ), dict(
        field_your_first_name='Person',
        field_your_last_name='Assignee',
        field_your_reference="person_assignee",
        field_your_password='person_assignee',
        field_your_password_confirm='person_assignee',
236
        field_your_default_email_text='test@test.com',
Gabriel Monnerat's avatar
Gabriel Monnerat committed
237 238 239 240 241 242 243
        field_your_default_telephone_text='',
      ), dict(
        field_your_first_name='Person',
        field_your_last_name='Assignor',
        field_your_reference="person_assignor",
        field_your_password='person_assignor',
        field_your_password_confirm='person_assignor',
244
        field_your_default_email_text='test@test.com',
Gabriel Monnerat's avatar
Gabriel Monnerat committed
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
        field_your_default_telephone_text='',
      ),
    ]
    next_dict = {}
    for user in user_list:
      for k, v in user.items():
        next_dict.setdefault(k, []).append(v)
    sequence.edit(next_dict=next_dict)

  def stepCheckConfigurePreferenceForm(self, sequence=None, sequence_list=None, **kw):
    """ Check the multiple user account form """
    response_dict = sequence.get("response_dict")
    if 'command' in response_dict:
      self.assertEquals('show', response_dict['command'])
    self.assertEquals('Previous', response_dict['previous'])
    self.assertEquals('Configure user accounts', response_dict['next'])
    self.assertCurrentStep('Configuration of users', response_dict)

  def stepCheckConfigurePreferenceForm(self, sequence=None, sequence_list=None, **kw):
    """ Check the multiple user account form """
    response_dict = sequence.get("response_dict")
    if 'command' in response_dict:
      self.assertEquals('show', response_dict['command'])
    self.assertEquals('Previous', response_dict['previous'])
269 270
    self.assertEquals('Configure ERP5 Preferences', response_dict['next'])
    self.assertCurrentStep('ERP5 preferences', response_dict)
Gabriel Monnerat's avatar
Gabriel Monnerat committed
271 272 273 274

  def stepSetupPreferenceConfigurationBrazil(self, sequence=None, sequence_list=None, **kw):
    """ Setup the Brazil preference configuration """
    next_dict = dict(field_your_preferred_date_order='dmy',
275 276 277
                     field_your_lang='erp5_l10n_pt-BR',
                     field_your_preferred_event_sender_email="test@test.com",
                     default_field_your_lang=1)
Gabriel Monnerat's avatar
Gabriel Monnerat committed
278 279
    sequence.edit(next_dict=next_dict)

280
  def stepCheckConfigureWebSiteForm(self, sequence=None, sequence_list=None, **kw):
Gabriel Monnerat's avatar
Gabriel Monnerat committed
281 282 283 284 285
    """ Check the installation form """
    response_dict = sequence.get("response_dict")
    # configuration is finished. We are at the Install state.
    self.assertEquals('show', response_dict['command'])
    self.assertEquals('Previous', response_dict['previous'])
286
    self.assertEquals('Configure Web Site', response_dict['next'])
Gabriel Monnerat's avatar
Gabriel Monnerat committed
287

288 289 290 291 292 293 294 295 296 297 298
  def stepCheckPreferenceConfigurationBrazil(self, sequence=None, sequence_list=None, **kw):
    """ Check if organisation was created fine """
    business_configuration = sequence.get("business_configuration")
    person_config_save = business_configuration["5"]
    person_config_item = person_config_save["1"]
    self.assertEquals(person_config_item.getReference(), "person_creator")
    person_config_item = person_config_save["2"]
    self.assertEquals(person_config_item.getReference(), "person_assignee")
    person_config_item = person_config_save["3"]
    self.assertEquals(person_config_item.getReference(), "person_assignor")

299
  def stepSetupWebSiteConfiguration(self, sequence=None, sequence_list=None, **kw):
300
    """ Setup the language of Web Site """
301 302 303 304 305 306 307 308 309 310
    next_dict = dict(your_default_available_language="pt-BR")
    sequence.edit(next_dict=next_dict)

  def stepCheckConfigureInstallationForm(self, sequence=None, sequence_list=None, **kw):
    """ Check the installation form """
    response_dict = sequence.get("response_dict")
    self.assertEquals('show', response_dict['command'])
    self.assertEquals('Previous', response_dict['previous'])
    self.assertEquals('Install', response_dict['next'])

311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
  def stepSetupInstallConfiguration(self, sequence=None, sequence_list=None, **kw):
    """ Install the Configuration """
    sequence.edit(next_dict={})

  def stepCheckInstallConfiguration(self, sequence=None, sequence_list=None, **kw):
    """ Check the installation of the configuration """
    response_dict = sequence.get("response_dict")
    self.assertEquals('install', response_dict['command'])

  def stepStartConfigurationInstallation(self, sequence=None, sequence_list=None, **kw):
    """ Starts the installation """
    business_configuration = sequence.get("business_configuration")
    self.portal.portal_configurator.startInstallation(
         business_configuration, REQUEST=self.portal.REQUEST)

  def stepCheckUNGWebSiteAfterInstallation(self, sequence=None, sequence_list=None, **kw):
    """ Check if UNG Web Site is published and your language"""
    self.assertEquals(self.portal.web_site_module.ung.getValidationState(),
                      "published")
    self.assertEquals(self.portal.web_site_module.ung.getDefaultAvailableLanguage(),
                      "pt-BR")

Gabriel Monnerat's avatar
Gabriel Monnerat committed
333 334 335 336 337
  def test_standard_workflow_brazil(self):
    """ Test the standard workflow with brazilian configuration """
    sequence_list = SequenceList()
    sequence_list.addSequenceString(self.DEFAULT_SEQUENCE_LIST)
    sequence_list.play(self)