Exemplo n.º 1
0
 def testEjection(self):
     """ Ejecting all newer duplicates should leave just 1. """
     manager = RecognizerManager([YesRecognizer()])
     reader = NullReader(10)
     scanner = LogScanner(reader, manager, NewerDuplicates)
     yeses, maybes = scanner.matches(datetime.datetime.now, [])
     self.assertEqual(len(yeses), 1)
     self.assertEqual(len(maybes), 0)
Exemplo n.º 2
0
    def testCurrentScanner(self):
        """ Show that passing in process scanners builds on previous. """
        manager = RecognizerManager([ManyRecognizer(11)])
        reader = NullReader(10)
        scanner = LogScanner(reader, manager, NoneEjector)
        yeses, maybes = scanner.matches(datetime.datetime.now, [])
        self.assertEqual(len(yeses), 0)
        self.assertEqual(len(maybes), 10)

        # take all undecided scanners from previous run and reuse
        many_recognizers = maybes
        manager = RecognizerManager([])
        reader = NullReader(5)
        scanner = LogScanner(reader, manager, NoneEjector)
        yeses, maybes = scanner.matches(datetime.datetime.now, many_recognizers)
        self.assertEqual(len(yeses), 5)
        self.assertEqual(len(maybes), 5)
Exemplo n.º 3
0
 def testMaybeNo(self):
     """ Many recognizers says no if it does not get enough entries. """
     manager = RecognizerManager([ManyRecognizer(11)])
     reader = NullReader(10)
     scanner = LogScanner(reader, manager, NoneEjector)
     yeses, maybes = scanner.matches(datetime.datetime.now, [])
     self.assertEqual(len(yeses), 0)
     self.assertEqual(len(maybes), 10)
Exemplo n.º 4
0
 def testMaybeYes(self):
     """ Lazy recognizers do not say yes until log is read. """
     manager = RecognizerManager([LazyRecognizer()])
     reader = NullReader(10)
     scanner = LogScanner(reader, manager, NoneEjector)
     yeses, maybes = scanner.matches(datetime.datetime.now, [])
     self.assertEqual(len(yeses), 10)
     self.assertEqual(len(maybes), 10)
Exemplo n.º 5
0
 def testYes(self):
     """ The manager always says yes, and never filters. """
     manager = RecognizerManager([YesRecognizer()])
     reader = NullReader(10)
     scanner = LogScanner(reader, manager, NoneEjector)
     yeses, maybes = scanner.matches(datetime.datetime.now, [])
     self.assertEqual(len(yeses), 10)
     self.assertEqual(len(maybes), 0)
Exemplo n.º 6
0
 def testEmpty(self):
     """ The manager does not recognize, so no results. """
     manager = RecognizerManager([])
     reader = NullReader(10)
     scanner = LogScanner(reader, manager, NoneEjector)
     yeses, maybes = scanner.matches(datetime.datetime.now, [])
     self.assertEqual(len(yeses), 0)
     self.assertEqual(len(maybes), 0)