Commit 918109bc authored by Rafael Monnerat's avatar Rafael Monnerat

Included tests for Alarm Configurator Item

parent 5368dcfc
......@@ -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.
......
......@@ -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)
......
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment