'Events are filtered based on log level/namespace.'

def test_filtering(self):

    predicate = LogLevelFilterPredicate()
    predicate.setLogLevelForNamespace(None, LogLevel.error)
    predicate.setLogLevelForNamespace('twext.web2', LogLevel.debug)
    predicate.setLogLevelForNamespace('twext.web2.dav', LogLevel.warn)
    def checkPredicate(namespace, level, expectedResult):
        event = dict(log_namespace=namespace, log_level=level)
        self.assertEqual(expectedResult, predicate(event))
    checkPredicate('', LogLevel.debug, PredicateResult.no)
    checkPredicate('', LogLevel.error, PredicateResult.maybe)
    checkPredicate('twext.web2', LogLevel.debug, PredicateResult.maybe)
    checkPredicate('twext.web2', LogLevel.error, PredicateResult.maybe)
    checkPredicate('twext.web2.dav', LogLevel.debug, PredicateResult.no)
    checkPredicate('twext.web2.dav', LogLevel.error, PredicateResult.maybe)
    checkPredicate(None, LogLevel.critical, PredicateResult.no)
    checkPredicate('twext.web2', None, PredicateResult.no)
