def setUp(cls):
     fiveconfigure.debug_mode = True
     import eduintelligent.zipcontent
     zcml.load_config('configure.zcml',
                      eduintelligent.zipcontent)
     ztc.installPackage('eduintelligent.zipcontent')
     fiveconfigure.debug_mode = False
Exemple #2
0
def setup_product():
    """Set up the package and its dependencies.

    The @onsetup decorator causes the execution of this body to be
    deferred until the setup of the Plone site testing layer. We could
    have created our own layer, but this is the easiest way for Plone
    integration tests.
    """

    # Load the ZCML configuration for the example.tests package.
    # This can of course use <include /> to include other packages.

    fiveconfigure.debug_mode = True
    import pp.demo
    import zopyx.authoring
    zcml.load_config('configure.zcml', zopyx.authoring)
    zcml.load_config('configure.zcml', pp.demo)
    fiveconfigure.debug_mode = False

    # We need to tell the testing framework that these products
    # should be available. This can't happen until after we have loaded
    # the ZCML. Thus, we do it here. Note the use of installPackage()
    # instead of installProduct().
    # This is *only* necessary for packages outside the Products.*
    # namespace which are also declared as Zope 2 products, using
    # <five:registerPackage /> in ZCML.

    # We may also need to load dependencies, e.g.:
    #   ztc.installPackage('borg.localrole')

    ztc.installPackage('zopyx.authoring')
    ztc.installPackage('pp.demo')
Exemple #3
0
 def test_01_CheckOpenCounterDateTwiceFail(self, quiet=QUIET, run=RUN_ALL_TEST):
     """
   Test that opening a counter date when there is a counter date opened fails.
 """
     if not run:
         return
     if not quiet:
         message = "Check open CounterDate twice fails"
         ZopeTestCase._print("\n%s " % message)
         LOG("Testing... ", 0, message)
     self.openCounterDate(site=self.paris, id="counter_date_1")
     self.tic()
     self.openCounterDate(site=self.paris, id="counter_date_2", open=0)
     # open counter date and counter
     self.assertRaises(
         ValidationFailed,
         self.workflow_tool.doActionFor,
         self.counter_date_2,
         "open_action",
         wf_id="counter_date_workflow",
     )
     # get workflow history
     workflow_history = self.workflow_tool.getInfoFor(
         ob=self.counter_date_2, name="history", wf_id="counter_date_workflow"
     )
     # check its len is 2
     msg = workflow_history[-1]["error_message"]
     self.assertTrue("there is already a counter date opened" in "%s" % (msg,))
Exemple #4
0
 def tearDown(self):
   '''Tears down the fixture. Do not override,
      use the hooks instead.
   '''
   if not int(os.environ.get('erp5_save_data_fs', 0)):
     # Drop remaining activities if some of them failed.
     # However, we should not do more activity cleaning, because properly
     # written unit tests should not leave unprocessed activity messages.
     # And the user may want to analyse the result of a failed unit test,
     # so we do nothing in persistent mode (--save).
     try:
       portal_activities = self.portal.portal_activities
       message_list = portal_activities.getMessageList()
     except StandardError: # AttributeError, TransactionFailedError ...
       pass
     else:
       for m in message_list:
         if m.processing_node < -1:
           self.abort()
           count = portal_activities.countMessage()
           portal_activities.manageClearActivities()
           self.commit()
           ZopeTestCase._print(' (dropped %d left-over activity messages) '
                               % count)
           break
   PortalTestCase.tearDown(self)
 def setUp(cls):
     fiveconfigure.debug_mode = True
     zcml.load_config('configure.zcml',
                      collective.collection.yearview)
     fiveconfigure.debug_mode = False
     
     ztc.installPackage('collective.collection.yearview')    
Exemple #6
0
 def test_12_Every5Minutes(self, quiet=0, run=run_all_test):
   if not run: return
   if not quiet:
     message = 'Test Every 5 Minutes'
     ZopeTestCase._print('\n%s ' % message)
     LOG('Testing... ',0,message)
   alarm = self.newAlarm(enabled=True)
   now = DateTime()
   minute_to_remove = now.minute() % 5
   now = addToDate(now,minute=-minute_to_remove)
   date = addToDate(now,day=2)
   alarm.setPeriodicityStartDate(date)
   alarm.setPeriodicityMinuteFrequency(5)
   self.tic()
   alarm.setNextAlarmDate(current_date=now)
   self.assertEqual(alarm.getAlarmDate(),date)
   LOG(message + ' now :',0,now)
   now = addToDate(now,day=2)
   LOG(message + ' now :',0,now)
   alarm.setNextAlarmDate(current_date=now)
   next_date = addToDate(date,minute=5)
   self.assertEqual(alarm.getAlarmDate(),next_date)
   now = addToDate(now,minute=5,second=14)
   alarm.setNextAlarmDate(current_date=now)
   next_date = addToDate(next_date,minute=5)
   self.assertEqual(alarm.getAlarmDate(),next_date)
Exemple #7
0
  def test_16_uncatalog(self, quiet=0, run=run_all_test):
    """
    Check that deleting an alarm uncatalogs it.
    """
    if not run: return
    if not quiet:
      message = 'Test Uncatalog'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    alarm = self.newAlarm(enabled=True)
    self.tic()

    now = DateTime()
    date = addToDate(now, day=1)
    alarm.setPeriodicityStartDate(date)
    self.tic()
    self.assertEqual(alarm.getAlarmDate(), date)

    # This should not do change the alarm date
    alarm.setNextAlarmDate(current_date=now)
    self.tic()
    self.assertEqual(alarm.getAlarmDate(), date)

    # Delete the alarm
    a_tool = self.getAlarmTool()
    alarm_uid = alarm.getUid()
    a_tool.manage_delObjects(uids=[alarm_uid])
    self.tic()
    # Check that related entry was removed
    sql_connection = self.getSQLConnection()
    sql = 'select * from alarm where uid=%s' % alarm_uid
    result = sql_connection.manage_test(sql)
    self.assertEqual(0, len(result))
Exemple #8
0
 def test_04_Every3Hours(self, quiet=0, run=run_all_test):
   if not run: return
   if not quiet:
     message = 'Test Every 3 Hours'
     ZopeTestCase._print('\n%s ' % message)
     LOG('Testing... ',0,message)
   alarm = self.newAlarm(enabled=True)
   now = DateTime().toZone('UTC')
   hour_to_remove = now.hour() % 3
   now = addToDate(now,hour=-hour_to_remove)
   date = addToDate(now,day=2)
   alarm.setPeriodicityStartDate(date)
   alarm.setPeriodicityHourFrequency(3)
   self.tic()
   alarm.setNextAlarmDate(current_date=now)
   self.assertEqual(alarm.getAlarmDate(),date)
   LOG(message + ' now :',0,now)
   now = addToDate(now,day=2)
   LOG(message + ' now :',0,now)
   alarm.setNextAlarmDate(current_date=now)
   next_date = addToDate(date,hour=3)
   self.assertEqual(alarm.getAlarmDate(),next_date)
   now = addToDate(now,hour=3,minute=7,second=4)
   alarm.setNextAlarmDate(current_date=now)
   next_date = addToDate(next_date,hour=3)
   self.assertEqual(alarm.getAlarmDate(),next_date)
Exemple #9
0
  def test_07a_Every4DaysSomeHours(self, quiet=0, run=run_all_test):
    """- every 4 days at 14 and 15 and 17"""
    if not run: return
    if not quiet:
      message = 'Every 4 Days Some Hours'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ',0,message)

    right_first_date = DateTime(self.date_format % (2006,10,7,13,00,00))
    right_second_date = DateTime(self.date_format  % (2006,10,8,14,00,00))
    right_third_date = DateTime(self.date_format  % (2006,10,8,15,00,00))
    right_fourth_date = DateTime(self.date_format  % (2006,10,8,17,00,00))
    right_fifth_date = DateTime(self.date_format  % (2006,10,12,14,00,00))
    alarm = self.newAlarm(enabled=True)
    alarm.setPeriodicityStartDate(right_first_date)
    alarm.setPeriodicityDayFrequency(4)
    alarm.setPeriodicityHourList((14,15,17))
    self.tic()
    self.assertEqual(alarm.getAlarmDate(),right_first_date)
    alarm.setNextAlarmDate(current_date=right_first_date)
    self.assertEqual(alarm.getAlarmDate(),right_second_date)
    alarm.setNextAlarmDate(current_date=right_second_date)
    self.assertEqual(alarm.getAlarmDate(),right_third_date)
    alarm.setNextAlarmDate(current_date=right_third_date)
    self.assertEqual(alarm.getAlarmDate(),right_fourth_date)
    alarm.setNextAlarmDate(current_date=right_fourth_date)
    self.assertEqual(alarm.getAlarmDate(),right_fifth_date)
Exemple #10
0
 def test_listActionInListbox(self):
   # check all list_action in listboxes
   skins_tool = self.portal.portal_skins
   error_list = []
   for form_path, form in skins_tool.ZopeFind(
             skins_tool, obj_metatypes=['ERP5 Form'], search_sub=1):
     for field in self.getFieldList(form, form_path):
       if field.getRecursiveTemplateField().meta_type == 'ListBox':
         list_action = field.get_value("list_action")
         if list_action and list_action != 'list': # We assume that 'list'
                                                   # list_action exists
           if isinstance(list_action, str):
             # list_action can be a fully qualified URL, we care for last part of it
             list_action = list_action.split('/')[-1].split('?')[0]
             try:
               method = self.portal.restrictedTraverse(list_action)
             except KeyError:
               method = None
             if method is None:
               # list_action can actually exists but not in current skin, check if it can be found in portal_skins
               found_list_action_list = skins_tool.ZopeFind(skins_tool, obj_ids=[list_action], search_sub=1)
               if found_list_action_list:
                 method = found_list_action_list[0][1]
                 ZopeTestCase._print("List action %s for %s is not part of current skin but do exists in another skin folder.\n" % (list_action, form_path))
           else:
             method = list_action
           if not callable(method):
             error_list.append('Form %s/%s : list_action "%s" is not callable.'\
                 % (form_path, field.id, list_action))
   self.assert_(not len(error_list), '\n'.join(error_list))
Exemple #11
0
 def test_03_EveryHour(self, quiet=0, run=run_all_test):
   if not run: return
   if not quiet:
     message = 'Test Every Hour'
     ZopeTestCase._print('\n%s ' % message)
     LOG('Testing... ',0,message)
   alarm = self.newAlarm(enabled=True)
   now = DateTime()
   date = addToDate(now, day=2)
   alarm.setPeriodicityStartDate(date)
   alarm.setPeriodicityHourFrequency(1)
   self.tic()
   alarm.setNextAlarmDate(current_date=now)
   self.assertEqual(alarm.getAlarmDate(), date)
   LOG(message + ' now :',0,now)
   now = addToDate(now,day=2)
   LOG(message + ' now :',0,now)
   alarm.setNextAlarmDate(current_date=now)
   next_date = addToDate(date,hour=1)
   self.assertEqual(alarm.getAlarmDate(),next_date)
   now = addToDate(now,hour=1,minute=5)
   alarm.setNextAlarmDate(current_date=now)
   next_date = addToDate(next_date,hour=1)
   self.assertEqual(alarm.getAlarmDate(),next_date)
   # check if manual invoking does not break getAlarmDate() result.
   alarm.activeSense()
   self.assertEqual(alarm.getAlarmDate(),next_date)
 def setUp(cls):
     """ Setup
     """
     fiveconfigure.debug_mode = True
     ztc.installPackage(eea.design)
     ztc.installPackage(eea.versions)
     fiveconfigure.debug_mode = False
Exemple #13
0
 def test_05_checkBackupWithTrashSubObjects(self, quiet=quiet, run=run_all_test):
   """
   Test we can backup a tree like this :
   base_category/trash_folder/category
   """
   if not run: return
   if not quiet:
     message = 'Test Check Backup With Trash Sub Object'
     ZopeTestCase._print('\n%s ' % message)
     LOG('Testing... ', 0, message)
   sequence_list = SequenceList()
   sequence_string = '\
                      CheckTrashToolExists  \
                      CreateTrashBin \
                      CheckTrashBinIndexable \
                      AddBaseCategory \
                      AddCategories \
                      AddSubCategories \
                      Tic \
                      BackupObjectsWithSave \
                      Tic \
                      CheckObjectBackupWithoutSubObjects \
                      BackupSubCategories \
                      '
   sequence_list.addSequenceString(sequence_string)
   sequence_list.play(self, quiet=quiet)
Exemple #14
0
 def setUp(cls):
     fiveconfigure.debug_mode = True
     import quintagroup.pfg.captcha
     zcml.load_config('configure.zcml', quintagroup.pfg.captcha)
     fiveconfigure.debug_mode = False
     ztc.installPackage('quintagroup.pfg.captcha')
     ztc.installPackage('quintagroup.captcha.core')
Exemple #15
0
def setup():
    import pmr2.app.annotation
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', pmr2.app.annotation)
    zcml.load_config(join('tests', 'test.zcml'), pmr2.app.annotation)
    fiveconfigure.debug_mode = False
    ztc.installPackage('pmr2.app')
 def test_02_CheckOpenCounterDateWithOtherDateFail(self, quiet=QUIET, run=RUN_ALL_TEST):
   """
     Test that opening a counter date on a non-current date fails.
   """
   if not run:
     return
   if not quiet:
     message = 'Check open CounterDate on non-current date fails'
     ZopeTestCase._print('\n%s ' % message)
     LOG('Testing... ', 0, message)
   def openAndTest(id, date):
     self.openCounterDate(site=self.paris, id=id, date=date, open=0)
     # open counter date and counter
     counter_date = getattr(self, id)
     self.assertRaises(ValidationFailed,
                      self.workflow_tool.doActionFor,
                      counter_date, 'open_action',
                      wf_id='counter_date_workflow')
     # get workflow history
     workflow_history = self.workflow_tool.getInfoFor(
            ob=counter_date, name='history', wf_id='counter_date_workflow')
     # check its len is 2
     msg = workflow_history[-1]['error_message']
     self.assertTrue('the date is not today' in "%s" %(msg, ))
   now = DateTime()
   # Future
   openAndTest('1', now + 2) # Just in case midnight passes between "now" calculation and validation, add 2 instead of 1
   # Past
   openAndTest('2', now - 1)
 def install_product(self):
     fiveconfigure.debug_mode = True
     zcml.load_config('configure.zcml',
                      collective.autosaveform)
     ztc.installPackage(collective.autosaveform)
     self.addProfile('collective.autosaveform:default')
     self.addProduct('collective.autosaveform')
  def test_01_relationFieldToInaccessibleObject(self, quiet=quiet, run=run_all_test):
    """
      This test checks if a form can be viewed when it contains a RelationStringField which
      links to an object the user is not authorized to view.

      This fails for now. A proposed patch solving this problem is here:
      http://svn.erp5.org/experimental/FSPatch/Products/ERP5Form/ERP5Form_safeRelationField.diff?view=markup

      This problem can happen for example in the following situation:
      - a user is a member of a project P team, so he can view P
      - the user creates a project-related document and leaves it in "draft" state
      - the user quits the project P team
      Then the user can not view the project, but still can view his document as he is the owner.
      An attempt to view the document form would raise Unauthorized.
    """
    self.login()
    if not run: return
    if not quiet:
      message = 'test_01_relationFieldToInaccessibleObject'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = '\
                       CreateObjects \
                       CreateTestFoo \
                       Tic \
                       AccessFoo \
                       ChangeCategorySecurity \
                       AccessFoo \
                       ResetCategorySecurity \
                       AccessFoo \
                       '
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)
 def test_01_CheckOpenCounterDateTwiceFail(self, quiet=QUIET, run=RUN_ALL_TEST):
   """
     Test that opening a counter date when there is a counter date opened fails.
   """
   if not run:
     return
   if not quiet:
     message = 'Check open CounterDate twice fails'
     ZopeTestCase._print('\n%s ' % message)
     LOG('Testing... ', 0, message)
   self.openCounterDate(site=self.paris, id='counter_date_1')
   transaction.commit()
   self.tic()
   self.openCounterDate(site=self.paris, id='counter_date_2', open=0)
   # open counter date and counter
   self.assertRaises(ValidationFailed,
                    self.workflow_tool.doActionFor,
                    self.counter_date_2, 'open_action',
                    wf_id='counter_date_workflow')
   # get workflow history
   workflow_history = self.workflow_tool.getInfoFor(
          ob=self.counter_date_2, name='history', wf_id='counter_date_workflow')
   # check its len is 2
   msg = workflow_history[-1]['error_message']
   self.assertTrue('there is already a counter date opened' in "%s" %(msg, ))
 def tearDown(cls):
     testing.tearDown()
     app = ZopeTestCase.app()
     schema.metadata.drop_all()
     app.manage_delObjects( SANDBOX_ID )
     transaction.commit()
     ZopeTestCase.close(app)
Exemple #21
0
def setup_product():
    fiveconfigure.debug_mode = True
    import quintagroup.captcha.core
    import quintagroup.formlib.captcha
    zcml.load_config('configure.zcml', quintagroup.formlib.captcha)
    fiveconfigure.debug_mode = False
    ztc.installPackage('quintagroup.captcha.core')
 def setUpZope(self, app, configurationContext):
     # Load ZCML for this package
     import misitio.policy
     xmlconfig.file('configure.zcml',
                    misitio.policy,
                    context=configurationContext)
     ztc.installProduct('Products.CMFPlacefulWorkflow')
Exemple #23
0
 def tearDown(cls):
     app = ZopeTestCase.app()
     plone = app.plone
     reg = BasePloneWickedRegistration(plone)
     reg.handle(unregister=True)
     txn.commit()
     ZopeTestCase.close(app)
Exemple #24
0
def setup():
    import pmr2.annotation.curation

    fiveconfigure.debug_mode = True
    zcml.load_config("configure.zcml", pmr2.annotation.curation)
    fiveconfigure.debug_mode = False
    ztc.installPackage("pmr2.annotation.curation")
Exemple #25
0
    def setUp(cls):
        testing.setUp()
        zcml.load_config('meta.zcml', Products.Five)
        zcml.load_config('encrypt.zcml', Products.SQLPASPlugin)

        app = ZopeTestCase.app()

        # Create our sandbox
        app.manage_addFolder(SANDBOX_ID)
        sandbox = app[SANDBOX_ID]

        # Add a cache manager
        factory = sandbox.manage_addProduct['StandardCacheManagers']
        factory.manage_addRAMCacheManager(CACHE_MANAGER_ID)

        # Setup the DB connection and PAS instances
        cls.conn = cls.setupConnection(sandbox)
        cls.pas = cls.setupPAS(sandbox)

        # Update PAS to use test tables
        users = cls.pas[USERMANAGER_ID]
        users.manage_changeProperties(users_table=TESTING_USERS_TABLE)
        roles = cls.pas[ROLEMANAGER_ID]
        roles.manage_changeProperties(roles_table=TESTING_ROLES_TABLE)
        props = cls.pas[PROPERTYPROVIDER_ID]
        props.manage_changeProperties(users_table=TESTING_USERS_TABLE)

        # Create the tables tests
        cls.execute(cls.createTable(TESTING_USERS_TABLE,
                                    TESTING_USERS_COLUMNS))
        cls.execute(cls.createTable(TESTING_ROLES_TABLE,
                                    TESTING_ROLES_COLUMNS))

        transaction.commit()
        ZopeTestCase.close(app)
def setup_product():
    fiveconfigure.debug_mode = True
    import collective.borgerdk

    zcml.load_config("configure.zcml", collective.borgerdk)
    fiveconfigure.debug_mode = False
    ztc.installPackage("collective.borgerdk")
Exemple #27
0
def setup_uwoshsuccess():
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', Products.ATVocabularyManager)
    zcml.load_config('configure.zcml', Products.UWOshSuccess)
    fiveconfigure.debug_mode = False
    ztc.installProduct('ATVocabularyManager')
    ztc.installProduct('UWOshSuccess')
  def test_01_checkPasswordTool(self, quiet=quiet, run=run_all_test):
    if not run: return
    if not quiet:
      message = 'Test Password Tool'
      ZopeTestCase._print('\n%s ' % message)
      LOG('Testing... ', 0, message)
    sequence_list = SequenceList()
    sequence_string = 'CheckPasswordToolExists '  \
                      'AddUser Tic ' \
                      'Logout ' \
                      'CheckUserLogin CheckUserNotLoginWithBadPassword ' \
                      'TryLostPasswordWithBadUser Tic ' \
                      'CheckNoMailSent ' \
                      'GoToBadRandomAddress Tic ' \
                      'CheckUserLogin CheckUserNotLoginWithBadPassword ' \
                      'LostPassword Tic ' \
                      'CheckMailSent GoToRandomAddress Tic '  \
                      'CheckUserLoginWithNewPassword ' \
                      'CheckUserNotLoginWithFormerPassword ' \
                      'GoToRandomAddressTwice Tic ' \
                      'CheckUserLoginWithNewPassword ' \
                      'CheckUserNotLoginWithFormerPassword ' \

    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self, quiet=quiet)
Exemple #29
0
def fortify():
  '''Add some extra checks that we don't have at runtime, not to slow down the
  system.
  '''
  # check that we don't store persistent objects in cache
  from Products.ERP5Type.CachePlugins.BaseCache import CacheEntry
  CacheEntry.__original_init__ = CacheEntry.__init__
  def __init__(self, value, *args, **kw):
    # this will raise TypeError if you try to cache a persistent object
    dumps(value)
    return self.__original_init__(value, *args, **kw)
  CacheEntry.__init__ = __init__

  # randomize priorities of activities in a deterministic way
  seed = os.environ.get("random_activity_priority")
  if seed is not None:
    ZopeTestCase._print("RNG seed for priorities of activities is %r\n" % seed)
    rng = random.Random(seed)
    from Products.CMFActivity.ActivityTool import Message
    Message__init__ = Message.__init__
    def __init__(self, url, oid, active_process, active_process_uid,
                 activity_kw, *args, **kw):
      activity_kw['priority'] = rng.randint(-128, 127)
      Message__init__(self, url, oid, active_process, active_process_uid,
                      activity_kw, *args, **kw)
    Message.__init__ = __init__
Exemple #30
0
    def setUp(cls):
        from pas.plugins.sqlalchemy.model import Base

        testing.setUp()
        # zcml.load_config('meta.zcml', Products.Five)
        # zcml.load_config('configure.zcml', pas.plugins.sqlalchemy)

        app = ZopeTestCase.app()

        # Create our sandbox
        app.manage_addFolder(SANDBOX_ID)
        sandbox = app[SANDBOX_ID]

        # Add a cache manager
        factory = sandbox.manage_addProduct['StandardCacheManagers']
        factory.manage_addRAMCacheManager(CACHE_MANAGER_ID)

        # Setup the DB connection and PAS instances
        factory = EngineFactory('sqlite:///:memory:')
        engine = factory()
        Base.metadata.bind = engine
        Base.metadata.create_all(engine)
        cls.pas = cls.setupPAS(sandbox)

        utility = GloballyScopedSession(
            bind=engine,
            twophase=TEST_TWOPHASE)

        component.provideUtility(utility, provides=IScopedSession,
                                 name="pas.plugins.sqlalchemy")

        transaction.commit()
        ZopeTestCase.close(app)
Exemple #31
0
 def tearDown(self):
     transaction.abort()
     ZopeTestCase.close(self.app)
 def tearDown(cls):
     app = ZopeTestCase.app()
     delattr(app, 'LAYER_EXTRACTED')
     transaction.commit()
     ZopeTestCase.close(app)
 def setUp(cls):
     app = ZopeTestCase.app()
     app.LAYER_EXTRACTED = True
     transaction.commit()
     ZopeTestCase.close(app)
Exemple #34
0
from Testing import ZopeTestCase

# Make the boring stuff load quietly
ZopeTestCase.installProduct('SimpleAttachment')
ZopeTestCase.installProduct('CMFPlacefulWorkflow')
ZopeTestCase.installProduct('Ploneboard')
ZopeTestCase.installProduct('collective.MockMailHost')
ZopeTestCase.installProduct('PloneboardSubscription')

from Products.PloneTestCase import PloneTestCase

PloneTestCase.setupPloneSite(products=(
    'SimpleAttachment',
    'CMFPlacefulWorkflow',
    'Ploneboard',
    'collective.MockMailHost',
    'PloneboardSubscription',
))

from Products.Five.testbrowser import Browser


class FunctionalTestCase(PloneTestCase.FunctionalTestCase):
    class Session(dict):
        def set(self, key, value):
            self[key] = value

    def _setup(self):
        PloneTestCase.FunctionalTestCase._setup(self)
        self.app.REQUEST['SESSION'] = self.Session()
        self.browser = Browser()
Exemple #35
0
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Catalog tool setup handler unit tests.

$Id$
"""

import unittest
from Testing import ZopeTestCase
ZopeTestCase.installProduct('ZCTextIndex', 1)

from OFS.Folder import Folder
from Products.ZCTextIndex.Lexicon import CaseNormalizer
from Products.ZCTextIndex.Lexicon import Splitter
from Products.ZCTextIndex.Lexicon import StopWordRemover
from Products.ZCTextIndex.ZCTextIndex import PLexicon

from Products.GenericSetup.tests.common import BaseRegistryTests
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext

from Products.CMFCore.CatalogTool import CatalogTool
from Products.CMFCore.testing import ExportImportZCMLLayer

_EMPTY_EXPORT = """\
Exemple #36
0
 def setUp(cls):
     fiveconfigure.debug_mode = True
     ztc.installPackage(cs.commenteditor)
     fiveconfigure.debug_mode = False
Exemple #37
0
from warnings import simplefilter
simplefilter('ignore', DeprecationWarning)

from AccessControl.SecurityManagement import newSecurityManager
from transaction import commit
from Products.Five import zcml
from Testing import ZopeTestCase
from Testing.ZopeTestCase.utils import setupCoreSessions
from Products.PloneTestCase import PloneTestCase
from Products.PloneTestCase.layer import PloneSite

import easyshop.carts
from plone.app import relations

setupCoreSessions()
ZopeTestCase.installProduct('SiteAccess')

ZopeTestCase.installProduct("EasyShop", "plone.app.relations")
PloneTestCase.setupPloneSite(products=['EasyShop', "plone.app.relations"])


class EasyShopCartsSite(PloneSite):
    @classmethod
    def setUp(cls):
        app = ZopeTestCase.app()
        portal = app.plone
        # login as admin (copied from `loginAsPortalOwner`)
        uf = app.acl_users
        user = uf.getUserById(PloneTestCase.portal_owner).__of__(uf)
        newSecurityManager(None, user)
        zcml.load_config('configure.zcml', easyshop.carts)
Exemple #38
0
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################

import os, sys

# Load fixture
from Testing import ZopeTestCase

# Install our product
ZopeTestCase.installProduct('ExternalEditor')

from OFS.SimpleItem import SimpleItem
class SideEffects(SimpleItem):
    meta_type = 'Side Effects'
    def __init__(self, id, content):
        self.id = id
        self.content = content
    def manage_FTPget(self, REQUEST, RESPONSE):
        RESPONSE.setHeader('Content-Type', 'text/plain')
        return self.content

def test_suite():
    import unittest
    suite = unittest.TestSuite()
    from Testing.ZopeTestCase import doctest
Exemple #39
0
 def setUp(cls):
     fiveconfigure.debug_mode = True
     ztc.installPackage(plonetheme.gobierno)
     fiveconfigure.debug_mode = False
Exemple #40
0
 def setUp(self):
     transaction.begin()
     self.app = self.root = ZopeTestCase.app()
     self.REQUEST = self.app.REQUEST
     self.RESPONSE = self.app.REQUEST.RESPONSE
Exemple #41
0
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Unit tests for FSZSQLMethod module.
"""

import unittest
from Testing import ZopeTestCase
try:
    import Products.ZSQLMethods
    ZopeTestCase.installProduct('ZSQLMethods', 1)
    HAVE_ZSQL = True
except ImportError:
    HAVE_ZSQL = False

from os.path import join

from Acquisition import aq_base
from zope.testing.cleanup import cleanUp

from Products.CMFCore.FSMetadata import FSMetadata
from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import SecurityTest


class FSZSQLMaker(FSDVTest):
 def setUp(cls):
     fiveconfigure.debug_mode = True
     ztc.installPackage(uwosh.externalsite)
     fiveconfigure.debug_mode = False
 def setUp(cls):
     fiveconfigure.debug_mode = True
     zcml.load_config('configure.zcml', Products.RhaptosCollection)
     #zcml.load_config('overrides.zcml', Products.RhaptosCollection)
     ztc.installPackage('Products.RhaptosCollection')
     fiveconfigure.debug_mode = False
import os
import difflib
from Products.RhaptosTest import config
import Products.CNXMLTransforms
config.products_to_load_zcml = [
    ('configure.zcml', Products.CNXMLTransforms),
]
config.products_to_install = ['CNXMLTransforms']

from Products.RhaptosTest import base

from Products.CNXMLTransforms.helpers import doTransform

from Testing import ZopeTestCase
ZopeTestCase.installProduct('RhaptosSword')
ZopeTestCase.installProduct('CNXML')
ZopeTestCase.installProduct('UniFile')

DIRNAME = os.path.dirname(__file__)


def diff(a, b):
    return '\n'.join(difflib.unified_diff(a.splitlines(), b.splitlines()))


class TestCNXMLTransforms(base.RhaptosTestCase):
    def afterSetUp(self):
        pass

    def beforeTearDown(self):
 def setUp(cls):
     fiveconfigure.debug_mode = True
     ztc.installPackage(collective.loremipsum)
     fiveconfigure.debug_mode = False
Exemple #46
0
 def tearDown(cls):
     app = ZopeTestCase.app()
     app._delObject('site')
     transaction.commit()
     ZopeTestCase.close(app)
Exemple #47
0
# -*- coding: utf-8 -*-
#
# Setup tests
#

from Testing import ZopeTestCase

ZopeTestCase.installProduct("MemcachedManager")


class TestSetup(ZopeTestCase.ZopeTestCase):
    def afterSetUp(self):
        pass

    def testAddCacheManager(self):
        factory = self.folder.manage_addProduct["MemcachedManager"]
        factory.manage_addMemcachedManager(id="memcache")
        self.assertTrue("memcache" in self.folder.objectIds())


def test_suite():
    from unittest import makeSuite
    from unittest import TestSuite

    suite = TestSuite()
    suite.addTest(makeSuite(TestSetup))
    return suite
Exemple #48
0
def setup_product():
    fiveconfigure.debug_mode = True
    zcml.load_config('configure.zcml', plone4bio.base)
    fiveconfigure.debug_mode = False
    ztc.installPackage('plone4bio.base')
 def setUp(cls):
     fiveconfigure.debug_mode = True
     ztc.installPackage(plonetheme.foundationforplone)
     fiveconfigure.debug_mode = False
Exemple #50
0
import os, sys

if __name__ == '__main__':
    execfile(os.path.join(sys.path[0], 'framework.py'))

import unittest
from Testing import ZopeTestCase

ZopeTestCase.installProduct('Five')

from zope.configuration import xmlconfig
from zope.component import getView
from zope.testing.cleanup import CleanUp
from Products.Five import zcml
from Products.Five.traversable import FakeRequest
from Products.Five.security import clearSecurityInfo
from Products.Five.tests.dummy import Dummy1, Dummy2
from Globals import InitializeClass

class PageSecurityTestCase(CleanUp, ZopeTestCase.ZopeTestCase):

    def setUp(self):
        super(PageSecurityTestCase, self).setUp()
        zcml.reset()
        zcml.load_site()
        self.dummy1 = Dummy1

    def tearDown(self):
        super(PageSecurityTestCase, self).tearDown()
        zcml.reset()
        clearSecurityInfo(self.dummy1)
Exemple #51
0
# -*- coding: utf-8 -*-
import unittest

from Products.Formulator.Form import ZMIForm
from Products.Formulator.XMLToForm import XMLToForm
from Products.Formulator.FormToXML import formToXML
from DateTime import DateTime
from Products.Formulator.Errors import ValidationError, FormValidationError
from Testing import ZopeTestCase
ZopeTestCase.installProduct('Formulator')


class FakeRequest:
    """ a fake request for testing.
    Actually we need this only for item acces,
    and for evaluating to false always, for
    the manage_XXX methods to not try to render
    a response.
    """
    def __init__(self):
        self.dict = {}

    def __getitem__(self, key):
        return self.dict[key]

    def __setitem__(self, key, value):
        self.dict[key] = value

    def get(self, key, default_value=None):
        return self.dict.get(key, default_value)
Exemple #52
0
</dtml-if>
</dtml-if>
from Products.<dtml-var "klass.getPackage().getProductName()">.config import HAS_PLONE21
from Products.<dtml-var "klass.getPackage().getProductName()">.config import PRODUCT_DEPENDENCIES
from Products.<dtml-var "klass.getPackage().getProductName()">.config import DEPENDENCIES

# Add common dependencies
if not HAS_PLONE21:
    DEPENDENCIES.append('Archetypes')
    PRODUCT_DEPENDENCIES.append('MimetypesRegistry')
    PRODUCT_DEPENDENCIES.append('PortalTransforms')
PRODUCT_DEPENDENCIES.append('<dtml-var "klass.getPackage().getProductName()">')

# Install all (product-) dependencies, install them too
for dependency in PRODUCT_DEPENDENCIES + DEPENDENCIES:
    ZopeTestCase.installProduct(dependency)

ZopeTestCase.installProduct('<dtml-var "klass.getPackage().getProductName()">')

PRODUCTS = list()
<dtml-if "klass.getTaggedValue('quickinstall_dependencies', '1') == '1'">
PRODUCTS += DEPENDENCIES
</dtml-if>
<dtml-if "klass.getTaggedValue('quickinstall_self', '1') == '1'">
PRODUCTS.append('<dtml-var "klass.getPackage().getProductName()">')
</dtml-if>

testcase = <dtml-if "parent is not None"><dtml-var "parent.getCleanName()"><dtml-else>PloneTestCase.PloneTestCase</dtml-if>


<dtml-var "generator.getProtectedSection(parsed_class,'module-before-plone-site-setup')">
Exemple #53
0
#
# MemberDataTool tests
#

import os, sys
if __name__ == '__main__':
    execfile(os.path.join(sys.path[0], 'framework.py'))

from Testing import ZopeTestCase

ZopeTestCase.installProduct('CatalogMemberDataTool')
ZopeTestCase.installProduct('ZCatalog')

from Products.CMFPlone.tests import PloneTestCase
from Products.CMFPlone.tests import dummy

from OFS.Image import Image
default_user = PloneTestCase.default_user

from Products.CatalogMemberDataTool.MemberDataTool import MemberData


class TestMemberDataTool(PloneTestCase.PloneTestCase):
    def afterSetUp(self):
        self.portal.portal_quickinstaller.installProduct(
            'CatalogMemberDataTool')
        self.memberdata = self.portal.portal_memberdata

    def testInterface(self):
        """MemberDataTool must implement IMemberDataTool"""
        from Products.CMFCore.interfaces.portal_memberdata import portal_memberdata as IMemberDataTool
Exemple #54
0
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Test Products.CMFDefault.browser.document
"""

import unittest
from Testing import ZopeTestCase

from Products.CMFDefault.browser.content.tests.utils import clearVocabulary
from Products.CMFDefault.browser.content.tests.utils import setupVocabulary
from Products.CMFDefault.testing import FunctionalLayer


ftest_suite = ZopeTestCase.FunctionalDocFileSuite(
                'document.txt',
                setUp=setupVocabulary,
                tearDown=clearVocabulary,
               )
ftest_suite.layer = FunctionalLayer

def test_suite():
    return unittest.TestSuite((
        ftest_suite,
    ))
Exemple #55
0
 def setUp(cls):
     fiveconfigure.debug_mode = True
     ztc.installPackage(rhaptos.eip)
     fiveconfigure.debug_mode = False
Exemple #56
0
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Skins tool xml adapter and setup handler unit tests.

$Id$
"""

import unittest
from Testing import ZopeTestCase
ZopeTestCase.installProduct('CMFCore', 1)

import os

from OFS.Folder import Folder

from zope.component import getSiteManager
from zope.interface import implements

from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.testing import NodeAdapterTestCase
from Products.GenericSetup.tests.common import BaseRegistryTests
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext

from Products.CMFCore.interfaces import ISkinsTool
Exemple #57
0
 def setUp(cls):
     fiveconfigure.debug_mode = True
     zcml.load_config('configure.zcml', Products.CNXMLDocument)
     ztc.installPackage('Products.CNXMLDocument')
     fiveconfigure.debug_mode = False
Exemple #58
0
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Unit tests for FSPythonScript module.

$Id$
"""

import unittest
from Testing import ZopeTestCase
ZopeTestCase.installProduct('PythonScripts', 1)

from os.path import join
from sys import exc_info
from thread import start_new_thread
from time import sleep

from OFS.Folder import Folder
from OFS.SimpleItem import SimpleItem
from Products.StandardCacheManagers import RAMCacheManager

from zope.component import getSiteManager

from Products.CMFCore.FSMetadata import FSMetadata
from Products.CMFCore.FSPythonScript import FSPythonScript
from Products.CMFCore.interfaces import ISkinsTool
Exemple #59
0
from Products.Five import zcml
from Products.Five import fiveconfigure

from Testing import ZopeTestCase as ztc

from Products.PloneTestCase import PloneTestCase as ptc
from Products.PloneTestCase.layer import onsetup

# When ZopeTestCase configures Zope, it will *not* auto-load products
# in Products/. Instead, we have to use a statement such as:
#   ztc.installProduct('SimpleAttachment')
# This does *not* apply to products in eggs and Python packages (i.e.
# not in the Products.*) namespace. For that, see below.
# All of Plone's products are already set up by PloneTestCase.

ztc.installProduct('Carousel')


@onsetup
def setup_product():
    """Set up the package and its dependencies.

    The @onsetup decorator causes the execution of this body to be
    deferred until the setup of the Plone site testing layer. We could
    have created our own layer, but this is the easiest way for Plone
    integration tests.
    """

    # Load the ZCML configuration for the example.tests package.
    # This can of course use <include /> to include other packages.
Exemple #60
0
 def setUp(cls):
     fiveconfigure.debug_mode = True
     ztc.installPackage(zbw.ejClickdates)
     fiveconfigure.debug_mode = False