Пример #1
0
def test_suite():
    suite = unittest.TestSuite()
    tested_business_template = os.environ['TESTED_BUSINESS_TEMPLATE']

    testclass = type(
        'CodingStyleTest %s' % tested_business_template,
        (CodingStyleTest, ),
        {
            'tested_business_template': tested_business_template,
            # currently, jsl based test_javascript_lint report too many false positives.
            'test_javascript_lint': None,
        },
    )

    testXHTML.addTestMethodDynamically(
        testclass,
        testXHTML.validator,
        (tested_business_template, ),
        expected_failure_list=(
            # this view only works when solver decision has a relation to a solver.
            # One way to fix this would be to allow a custom "init script" to be called
            # on a portal type.
            'test_erp5_simulation_Solver_Decision_SolverDecision_viewConfiguration',
        ),
    )

    # required to create content in portal_components
    addUserToDeveloperRole('ERP5TypeTestCase')

    suite.addTest(unittest.makeSuite(testclass))
    return suite
Пример #2
0
def test_suite():
    suite = unittest.TestSuite()
    tested_business_template = os.environ['TESTED_BUSINESS_TEMPLATE']

    testclass = type(
        'CodingStyleTest %s' % tested_business_template,
        (CodingStyleTest, ),
        {
            'tested_business_template': tested_business_template,
            # currently, jsl based test_javascript_lint report too many false positives.
            'test_javascript_lint': None,
        },
    )

    testXHTML.addTestMethodDynamically(
        testclass,
        testXHTML.validator,
        (tested_business_template, ),
    )

    # required to create content in portal_components
    addUserToDeveloperRole('ERP5TypeTestCase')

    suite.addTest(unittest.makeSuite(testclass))
    return suite
Пример #3
0
 def afterSetUp(self):
     """Initialize a node that will only process activities"""
     self.startZServer()
     # Make sure to still have possibilities to edit components
     addUserToDeveloperRole('ERP5TypeTestCase')
     from Zope2.custom_zodb import cluster
     self._registerNode(distributing=not cluster, processing=1)
     self.commit()
Пример #4
0
 def afterSetUp(self):
   """Initialize a node that will only process activities"""
   self.startZServer()
   # Make sure to still have possibilities to edit components
   addUserToDeveloperRole('ERP5TypeTestCase')
   from Zope2.custom_zodb import cluster
   self._registerNode(distributing=not cluster, processing=1)
   self.commit()
Пример #5
0
    def afterSetUp(self):
        self.portal = self.getPortal()

        uf = self.getPortal().acl_users
        uf._doAddUser('seb', '', ['Manager'], [])

        self.loginByUserName('seb')
        addUserToDeveloperRole(
            'seb')  # required to create content in portal_components
        self.enableDefaultSitePreference()
  def afterSetUp(self):
    """
    Ran to set the environment
    """
    self.notebook_module = self.portal.getDefaultModule(portal_type='Data Notebook')
    self.assertTrue(self.notebook_module is not None)

    # Create user to be used in tests
    user_folder = self.getPortal().acl_users
    user_folder._doAddUser('dev_user', '', ['Manager',], [])
    user_folder._doAddUser('member_user', '', ['Member','Authenticated',], [])
    # Assign developer role to user
    addUserToDeveloperRole('dev_user')
    self.tic()
Пример #7
0
  def afterSetUp(self):
    """
    Ran to set the environment
    """
    self.notebook_module = self.portal.getDefaultModule(portal_type='Data Notebook')
    self.assertTrue(self.notebook_module is not None)

    # Create user to be used in tests
    user_folder = self.getPortal().acl_users
    user_folder._doAddUser('dev_user', '', ['Manager',], [])
    user_folder._doAddUser('member_user', '', ['Member','Authenticated',], [])
    # Assign developer role to user
    addUserToDeveloperRole('dev_user')
    self.tic()
  def afterSetUp(self):
    """
    Ran to set the environment
    """
    self.notebook_module = self.portal.getDefaultModule(portal_type='Data Notebook')
    self.assertTrue(self.notebook_module is not None)

    # Create user to be used in tests
    user_folder = self.getPortal().acl_users
    user_folder._doAddUser('dev_user', '', ['Manager',], [])
    user_folder._doAddUser('member_user', '', ['Member','Authenticated',], [])
    # Assign developer role to user
    addUserToDeveloperRole('dev_user')
    # Create script to mock execution
    createZODBPythonScript(self.getPortal().portal_skins.custom, "ERP5Site_isDataNotebookEnabled", '', "return True")

    self.tic()
Пример #9
0
def test_suite():
  suite = unittest.TestSuite()
  tested_business_template = os.environ['TESTED_BUSINESS_TEMPLATE']

  if tested_business_template == 'erp5_invoicing':
    from Testing import ZopeTestCase
    ZopeTestCase._print(
      '\nDo nothing: Invoice Line container is defined in '
      'erp5_{simplified,advanced}_invoicing so you should run those instead\n')
    return suite
  tested_business_template_list = [tested_business_template]
  if tested_business_template in ('erp5_simplified_invoicing',
                                    'erp5_advanced_invoicing'):
    tested_business_template_list.append('erp5_invoicing')

  testclass = type(
      'CodingStyleTest %s' % tested_business_template,
      (CodingStyleTest,),
      {
          'tested_business_template': tested_business_template,
          # currently, jsl based test_javascript_lint report too many false positives.
          'test_javascript_lint': None,
      },
  )

  testXHTML.addTestMethodDynamically(
      testclass,
      testXHTML.validator,
      tested_business_template_list,
      expected_failure_list=(
          # this view needs VCS preference set (this test suite does not support
          # setting preferences, but this might be a way to fix this).
          'test_erp5_forge_Business_Template_BusinessTemplate_viewVcsStatus',
          # this view only works when solver decision has a relation to a solver.
          # One way to fix this would be to allow a custom "init script" to be called
          # on a portal type.
          'test_erp5_simulation_Solver_Decision_SolverDecision_viewConfiguration',
      ),
  )

  # required to create content in portal_components
  addUserToDeveloperRole('ERP5TypeTestCase')

  suite.addTest(unittest.makeSuite(testclass))
  return suite
Пример #10
0
def test_suite():
    suite = unittest.TestSuite()
    tested_business_template = os.environ['TESTED_BUSINESS_TEMPLATE']

    if tested_business_template == 'erp5_invoicing':
        from Testing import ZopeTestCase
        ZopeTestCase._print(
            '\nDo nothing: Invoice Line container is defined in '
            'erp5_{simplified,advanced}_invoicing so you should run those instead\n'
        )
        return suite
    tested_business_template_list = [tested_business_template]
    if tested_business_template in ('erp5_simplified_invoicing',
                                    'erp5_advanced_invoicing'):
        tested_business_template_list.append('erp5_invoicing')

    testclass = type(
        'CodingStyleTest %s' % tested_business_template,
        (CodingStyleTest, ),
        {
            'tested_business_template': tested_business_template,
            # currently, jsl based test_javascript_lint report too many false positives.
            'test_javascript_lint': None,
        },
    )

    testXHTML.addTestMethodDynamically(
        testclass,
        testXHTML.validator,
        tested_business_template_list,
        expected_failure_list=testXHTML.expected_failure_list,
    )

    # required to create content in portal_components
    addUserToDeveloperRole('ERP5TypeTestCase')

    suite.addTest(unittest.makeSuite(testclass))
    return suite
Пример #11
0
    def setUpERP5Site(self,
                     business_template_list=(),
                     quiet=0,
                     light_install=1,
                     create_activities=1,
                     hot_reindexing=1,
                     erp5_catalog_storage='erp5_mysql_innodb_catalog'):
      '''
        Creates an ERP5 site.
        business_template_list must be specified correctly
        (e.g. '("erp5_base", )').
      '''
      portal_name = self.getPortalName()
      title = self.getTitle()
      if portal_name in failed_portal_installation:
        raise SetupSiteError(
            'Installation of %s already failed, giving up' % portal_name)
      try:
        self.app = app = self._app()
        app.test_portal_name = portal_name

        global setup_done
        setup_key = (portal_name,) + tuple(business_template_list)
        if setup_key not in setup_done:
          setup_done.add(setup_key)
          business_template_list = \
            self._getBTPathAndIdList(business_template_list)
          try:
            _start = time.time()
            # Add user and log in
            if not quiet:
              ZopeTestCase._print('Adding ERP5TypeTestCase user ...\n')
            uf = app.acl_users
            uf._doAddUser('ERP5TypeTestCase', '', ['Manager', 'Member', 'Assignee',
                          'Assignor', 'Author', 'Auditor', 'Associate'], [])
            user = uf.getUserById('ERP5TypeTestCase').__of__(uf)
            newSecurityManager(None, user)

            # bt5s contain ZODB Components which can be only installed if the
            # user has Developer Role
            addUserToDeveloperRole('ERP5TypeTestCase')

            # Add ERP5 Site
            reindex = 1
            if hot_reindexing:
              setattr(app, 'isIndexable', 0)
              reindex = 0

            if app._getOb(portal_name, None) is None:
              if not quiet:
                ZopeTestCase._print('Adding %s ERP5 Site ... ' % portal_name)

              extra_constructor_kw = _getConnectionStringDict()
              # manage_addERP5Site does not accept the following 2 arguments
              for k in ('erp5_sql_deferred_connection_string',
                        'erp5_sql_transactionless_connection_string'):
                extra_constructor_kw.pop(k, None)
              email_from_address = os.environ.get('email_from_address')
              if email_from_address is not None:
                extra_constructor_kw['email_from_address'] = email_from_address

              factory = app.manage_addProduct['ERP5']
              factory.manage_addERP5Site(portal_name,
                                       erp5_catalog_storage=erp5_catalog_storage,
                                       light_install=light_install,
                                       reindex=reindex,
                                       create_activities=create_activities,
                                       **extra_constructor_kw )
              sql = extra_constructor_kw.get('erp5_sql_connection_string')
              if sql:
                app[portal_name]._setProperty('erp5_site_global_id',
                                              base64.standard_b64encode(sql))
              if not quiet:
                ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start))
              # Release locks
              self.commit()
            self.portal = portal = self.getPortal()

            if len(setup_done) == 1: # make sure it is run only once
              self._setUpDummyMailHost()
              self.startZServer(verbose=True)
              self._registerNode(distributing=1, processing=1)
              self.loadPromise()

            self._updateConnectionStrings()
            self._recreateCatalog()
            self._installBusinessTemplateList(business_template_list,
                                              light_install=light_install,
                                              quiet=quiet)
            self._updateConversionServerConfiguration()
            self._updateMemcachedConfiguration()
            # Create a Manager user at the Portal level
            uf = self.getPortal().acl_users
            uf._doAddUser('ERP5TypeTestCase', '', ['Manager', 'Member', 'Assignee',
                            'Assignor', 'Author', 'Auditor', 'Associate'], [])
            user = uf.getUserById('ERP5TypeTestCase').__of__(uf)

            self._callSetUpOnce()

            # Enable reindexing
            # Do hot reindexing # Does not work
            if hot_reindexing:
              setattr(app,'isIndexable', 1)
              portal.portal_catalog.manage_hotReindexAll()

            portal.portal_types.resetDynamicDocumentsOnceAtTransactionBoundary()
            self.tic(not quiet)

            # Log out
            if not quiet:
              ZopeTestCase._print('Logout ... \n')
            noSecurityManager()
            if not quiet:
              ZopeTestCase._print('done (%.3fs)\n' % (time.time()-_start,))
              ZopeTestCase._print('Running Unit tests of %s\n' % title)
          except:
            self.abort()
            raise
          else:
            self.commit()
            del self.portal, self.app
            ZopeTestCase.close(app)
      except:
        ZopeTestCase._print(traceback.format_exc())
        failed_portal_installation[portal_name] = 1
        ZopeTestCase._print('Ran Unit test of %s (installation failed)\n'
                            % title) # run_unit_test depends on this string.
        raise