Esempio n. 1
0
    def run(self, config, interp=constants.ABORTONERROR, debug=False):
        """
        The singularize method calls the implemented check. It initializes all 
        nessessary values and returns the check result as a C{ProtocolEntry}.
        
        :param config: The check configuration that has to be used.
        :type config: C{Section}
        
        :param interp: Defines how the check result has to be interpreted.
        :type interp: - C{constants.WARNING}
                      - C{constants.DELAYONERROR}
                      - C{constants.ABORTONERROR}
                      
        :param debug: Returns an exception instead of translation in a log msg.
        :type debug: C{boolean}
                      
        :return: Returns the result of the check as a C{ProtocolEntry}.
        :rtype: C{ProtocolEntry}
        """

        name = self.__class__.__name__
        config = self.__config__.from_config(config)
        entry = ProtocolEntry(name, config)
        try:
            entry.start()
            entry.result, entry.msg = self._run(config)
            entry.end()
        except Exception, exc:
            if debug:
                raise exc

            entry.result = constants.EXCEPTION
            entry.msg = "Exception in check '%s': %s" % (name, str(exc))
            self.logger.exception(entry.msg)
Esempio n. 2
0
 def test_properties(self):
     assert self._protocol.success == True
     assert self._protocol.result == constants.SUCCESS
     
     entry = ProtocolEntry("dummy", dict(), constants.ERROR,"dummy")
     self._protocol.append(entry)
     assert self._protocol.success == False
     
     entry = ProtocolEntry("dummy", dict(), constants.SUCCESS,"dummy")
     self._protocol.append(entry)
     assert self._protocol.success == False
     
     assert self._protocol.errors == 1
     assert self._protocol.successors == 2
     assert self._protocol.warnings == 0
     assert self._protocol.exceptions == 0
     assert self._protocol.result == constants.ERROR
     assert str(self._protocol) != None
Esempio n. 3
0
 def setup_method(self, _):
     self._entry = ProtocolEntry("dummy", dict(), constants.ERROR,"dummy")
Esempio n. 4
0
 def setup_method(self, _):
     self._protocol = Protocol("test")
     self._entry = ProtocolEntry("dummy", dict(), constants.SUCCESS, "dummy")
     self._protocol.append(self._entry)