def test_valid_empty_dates(self):
     ''' Both empty dates are considered valid as those fields
         are not required
     '''
     data = MockProgram()
     try:
         IProgram.validateInvariants(data)
     except Invalid:
         self.fail()
    def test_valid_dates(self):
        ''' Same day, different days
        '''
        # Same Day
        data = MockProgram()
        data.start_date = DateTime('2012/04/18')
        data.end_date = DateTime('2012/04/18')
        try:
            IProgram.validateInvariants(data)
        except Invalid:
            self.fail()

        # Different day
        data = MockProgram()
        data.start_date = DateTime('2012/04/18')
        data.end_date = DateTime('2012/04/19')
        try:
            IProgram.validateInvariants(data)
        except Invalid:
            self.fail()
 def test_adding(self):
     self.portal.invokeFactory('conference.program', 'program')
     program = self.portal['program']
     self.assertTrue(IProgram.providedBy(program))
 def test_factory(self):
     fti = queryUtility(IDexterityFTI, name='conference.program')
     factory = fti.factory
     new_object = createObject(factory)
     self.assertTrue(IProgram.providedBy(new_object))
def get_enclosing_program(context):
    """ Given a context, find the enclosing program """
    context = aq_inner(context)
    while not (IProgram.providedBy(context) or IPloneSiteRoot.providedBy(context)):
        context = aq_parent(context)
    return IProgram.providedBy(context) and context or None