• Łukasz Nowak's avatar
    [erp5_test_result]: Periodical Test Suite · 72aa9dd4
    Łukasz Nowak authored
    By extending TestSuite class with Periodicity mixin it is possible to
    enable and configure periodicity.
    
    TestSuite.isRestartAllowed used by
    ERP5ProjectUnitTestDistributor.createTestResult in order to create new
    Test Result for configured periodicity if finished one already exists.
    
     - [x] remove method isRestartAllowed
     - [x] use method getAlarmDate
     - [x] in ERP5ProjectUnitTestDistributor.py, I would use "alarm_date = test_suite.getAlarmDate()" and then "if alarm_date and alarm_date <= now: ..."
     - [x] set next alarm date
    
    /reviewed-on nexedi/erp5!479
    72aa9dd4
document.erp5.TestSuite.py 1.13 KB
from Products.ERP5Type.XMLObject import XMLObject
from DateTime import DateTime
from zLOG import LOG,INFO,ERROR
from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions
from Products.ERP5.mixin.periodicity import PeriodicityMixin

class TestSuite(XMLObject, PeriodicityMixin):

  security = ClassSecurityInfo()
  security.declareObjectProtected(Permissions.AccessContentsInformation)
  
  security.declareProtected(Permissions.ModifyPortalContent, 'setPingDate')
  def setPingDate(self):
    """
    Set a new date to now when the node was last alive
    """
    portal = self.getPortalObject()
    portal.portal_task_distribution.getMemcachedDict().set(
       "%s_ping_date" % (self.getRelativeUrl()), DateTime())
    if self.getValidationState() == "invalidated":
      self.validate()

  security.declareProtected(Permissions.AccessContentsInformation, 'getPingDate')
  def getPingDate(self):
    """
    Set a new date to now when the node was last alive
    """
    portal = self.getPortalObject()
    return portal.portal_task_distribution.getMemcachedDict().get(
       "%s_ping_date" % (self.getRelativeUrl()))