Beispiel #1
0
def check_portal_mailhost(portal, xml_policy=None):
    """Return portal properties suite."""

    defaults = {
        'smtp_host': '',
        'smtp_port': 25,
        'smtp_userid': None,
        'smtp_pass': None,
        'smtp_notls': False
    }
    suite = unittest.TestSuite()

    if ZOPETESTCASE:
        if TEST_VERBOSE_MODE:
            errprint(TEST_SEQUENCE_TITLE)
        for property in defaults.iteritems():
            suite.addTest(CheckMailHost(portal, property))
        return suite
    else:
        logging.getLogger('Test mailhost').info(TEST_SEQUENCE_TITLE)
        res = unittest.TestResult()
        for property in defaults.iteritems():
            suite.addTest(CheckMailHost(portal, property))
        suite.run(res)
        return res.errors, res.failures
Beispiel #2
0
    def runTest(self):
        """."""

        mailhost = getToolByName(self.context, 'MailHost')
        info = ''

        if self.element[0] in self.policy:
            info = 'testing %s from policy' % self.element[0]
            self.assertEquals(
                self.policy[self.element[0]], getattr(mailhost, self.element[0]),
                msg = '%s founded in policy : %r != %r"' % (
                    self.element[0],
                    self.policy[self.element[0]],
                    getattr(mailhost, self.element[0])
                )
            )
        else:
            info = 'testing %s from default' % self.element[0]
            self.assertEquals(
                self.element[1], getattr(mailhost, self.element[0]),
                msg = "%s founded in default : %r != %r" % (
                    self.element[0],
                    self.element[1],
                    getattr(mailhost, self.element[0]
                           )
                )
            )
        if ZOPETESTCASE:
            if TEST_VERBOSE_MODE:
                errprint('\n'+info+'\n')
        else:
            logging.getLogger('Test mailhost').info(info)
Beispiel #3
0
    def runTest(self):
        """."""
        info = ''

        if self.element in self.policy:
            info = 'testing "%s" from policy' % self.element
            self.assertEquals(
                self.policy[self.element], self.context.getProperty(self.element),
                msg = 'Property "%s" founded in policy %r != %r' % (
                    self.element, self.policy[self.element],
                    self.context.getProperty(self.element)
                )
            )
        elif self.element in self.plone:
            info ='testing "%s" from cmfplone' % self.element
            self.assertEquals(
                self.plone[self.element], self.context.getProperty(self.element),
                msg = 'Property "%s" founded in CMFPlone %r != %r' % (
                    self.element,
                    self.plone[self.element],
                    self.context.getProperty(self.element)
                )
            )
        elif self.element in self.default:
            info ='testing "%s" from default' % self.element
            self.assertEquals(
                self.default[self.element], self.context.getProperty(self.element),
                msg = 'Property "%s" founded in CMFDefault %r != %r' % (
                    self.element,
                    self.default[self.element],
                    self.context.getProperty(self.element)
                )
            )
        else:
            info = '*** Warning *** "%s" is not tested, not founded' \
                   ' in policy or CMFdefault' % self.element
            if ZOPETESTCASE:
                if not FAILS_ON_UNTESTED_ELEMENT:
                    errprint('\n'+info+'\n')
                    return
            self.fail(msg=info)

        if ZOPETESTCASE:
            if TEST_VERBOSE_MODE:
                errprint('\n'+info+'\n')
        else:
            logging.getLogger('Test properties').info(info)
Beispiel #4
0
def check_portal_properties(portal, xml_policy=None, xml_default=None):
    """Return portal properties suite."""
    suite = unittest.TestSuite()

    if ZOPETESTCASE:
        if TEST_VERBOSE_MODE:
            errprint(TEST_SEQUENCE_TITLE)
        for property in portal.propertyIds():
            suite.addTest(BaseCheckProperties(portal, property))
        return suite
    else:
        logging.getLogger('Test Properties').info(TEST_SEQUENCE_TITLE)
        res = unittest.TestResult()
        for property in portal.propertyIds():
            suite.addTest(BaseCheckProperties(portal, property))
        suite.run(res)
        return res.errors, res.failures