diff --git a/bt5/erp5_configurator_standard/TestTemplateItem/testStandardConfigurationWorkflow.py b/bt5/erp5_configurator_standard/TestTemplateItem/testStandardConfigurationWorkflow.py index d14d4a367a5ac5b937533dd9c90a29fc9ac9d32c..a0bddccd8a3941f9fd1b35f81240c99dbf388f31 100644 --- a/bt5/erp5_configurator_standard/TestTemplateItem/testStandardConfigurationWorkflow.py +++ b/bt5/erp5_configurator_standard/TestTemplateItem/testStandardConfigurationWorkflow.py @@ -50,6 +50,7 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin): stepCheckPersonInformationList stepCheckValidOrganisationList stepCheckValidCurrencyList + stepCheckAlarmList stepCheckPublicGadgetList stepCheckPreferenceList stepCheckModulesBusinessApplication @@ -285,6 +286,20 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin): # self.assertEquals('validated', currency.getValidationState()) currency.Base_checkConsistency() + def stepCheckAlarmList(self, sequence=None, sequence_list=None, **kw): + """ + Check if after configuration the Alarms objects are enabled. + """ + business_configuration = sequence.get("business_configuration") + alarm_list = self.getBusinessConfigurationObjectList(business_configuration, 'Alarm') + self.assertEquals(len(alarm_list), 2) + for alarm in alarm_list: + self.failUnless(alarm.getPeriodicityStartDate() < DateTime()) + self.assertNotEquals(alarm.getPeriodicityStartDate(), None) + self.assertEquals(alarm.getPeriodicityMinuteFrequency(), 5) + self.assertEquals(alarm.getEnabled(), True) + self.assertNotEquals(alarm.getActiveSenseMethodId(), None) + def stepCheckPublicGadgetList(self, sequence=None, sequence_list=None, **kw): """ Assert all gadgets are publics. diff --git a/product/ERP5Configurator/Document/AlarmConfiguratorItem.py b/product/ERP5Configurator/Document/AlarmConfiguratorItem.py index 73051e90291bac0dc18268b1debad2edf152b690..2352133bfa06da738988c14594b32212be5917b5 100644 --- a/product/ERP5Configurator/Document/AlarmConfiguratorItem.py +++ b/product/ERP5Configurator/Document/AlarmConfiguratorItem.py @@ -62,15 +62,14 @@ class AlarmConfiguratorItem(ConfiguratorItemMixin, XMLObject): portal_alarms = self.getPortalObject().portal_alarms property_dict = { "active_sense_method_id" : self.getActiveSenseMethodId(), - "periodicity_minute_frequency" : self.getPeriodicityMinuteFrequency(), - "periodicity_hour" : self.getPeriodicityHour(), - "periodicity_minute": self.getPeriodicityMinute(), + "periodicity_hour_list" : self.getPeriodicityHourList(), + "periodicity_minute_list": self.getPeriodicityMinuteList(), "periodicity_minute_frequency": self.getPeriodicityMinuteFrequency(), - "periodicity_month": self.getPeriodicityMonth(), - "periodicity_month_day": self.getPeriodicityMonthDay(), + "periodicity_month_list": self.getPeriodicityMonthList(), + "periodicity_month_day_list": self.getPeriodicityMonthDayList(), "periodicity_start_date": DateTime() - 1, #"periodicity_stop_date": self.getPeriodicityStopDate(), - "periodicity_week": self.getPeriodicityWeek(), + "periodicity_week_list": self.getPeriodicityWeekList(), } alarm = getattr(portal_alarms, self.getId(), None) diff --git a/product/ERP5Configurator/tests/testConfiguratorItem.py b/product/ERP5Configurator/tests/testConfiguratorItem.py index 27ac80e366d341bf8b01d9c21349112ae1b86cd4..41b70f6e94bd650afe5092ba5028869d932a12ef 100644 --- a/product/ERP5Configurator/tests/testConfiguratorItem.py +++ b/product/ERP5Configurator/tests/testConfiguratorItem.py @@ -29,6 +29,8 @@ from AccessControl import Unauthorized from zLOG import LOG, INFO import uuid +from DateTime import DateTime +from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Configurator.tests.ConfiguratorTestMixin import \ TestLiveConfiguratorWorkflowMixin @@ -247,6 +249,57 @@ class TestConfiguratorItem(TestLiveConfiguratorWorkflowMixin): self.assertNotEquals(None, security_script) self.assertEquals(security_script(), expect_script_outcome) + def testAlarmConfiguratorItem(self): + """ Test Alarm Configurator Item """ + configuration_save = self.createConfigurationSave() + bc = configuration_save.getParentValue() + + property_map = { + "active_sense_method_id" : "Base_setDummy", + "periodicity_hour_list" : [5, 6], + "periodicity_minute_list": [30, 31], + "periodicity_minute_frequency": 5, + "periodicity_month_list": [1, 2], + "periodicity_month_day_list": [3, 4], + "periodicity_week_list": [6, 7], + } + + item = configuration_save.addConfigurationItem( + "Alarm Configurator Item", + id="my_test_alarm", + title="My Test Alarm", + **property_map) + + createZODBPythonScript(self.getPortal().portal_skins.custom, + property_map["active_sense_method_id"], + "", "context.setEnabled(0)") + self.stepTic() + item._build(bc) + self.stepTic() + + alarm = getattr(self.portal.portal_alarms, "my_test_alarm", None) + self.assertNotEquals(None, alarm) + + self.assertEquals(alarm.getEnabled(), True) + self.assertEquals(alarm.getTitle(), "My Test Alarm") + self.assertEquals(alarm.getPeriodicityMinuteFrequency(), + property_map["periodicity_minute_frequency"]) + self.assertEquals(alarm.getPeriodicityMonthList(), + property_map["periodicity_month_list"]) + self.assertEquals(alarm.getPeriodicityMonthDayList(), + property_map["periodicity_month_day_list"]) + self.assertEquals(alarm.getPeriodicityHourList(), + property_map["periodicity_hour_list"]) + self.assertEquals(alarm.getPeriodicityHourList(), + property_map["periodicity_hour_list"]) + self.assertEquals(alarm.getActiveSenseMethodId(), + property_map["active_sense_method_id"]) + self.assertNotEquals(alarm.getPeriodicityStartDate(), None) + self.failUnless(alarm.getPeriodicityStartDate() < DateTime()) + alarm.activeSense() + self.stepTic() + self.assertEquals(alarm.getEnabled(), 0) + def testPortalTypeRolesSpreadsheetConfiguratorItem(self): """ Test Portal Type Roles Configurator Item """ configuration_save = self.createConfigurationSave()