Ejemplo n.º 1
0
    def test_remove_filter_removes_a_registered_filter(self):
        filter = Filter()
        filterer = Filterer()

        filterer.add_filter(filter)
        filterer.remove_filter(filter)

        self.assertEqual(filterer.filters, [])
Ejemplo n.º 2
0
    def test_remove_filter_doesnt_raises_an_error_if_filter_not_in_filters(
            self):
        filter = Filter()
        filterer = Filterer()

        try:
            filterer.remove_filter(filter)
        except Exception as e:
            self.fail(f"Shouldn't raise an error. Error: {e}")
Ejemplo n.º 3
0
    def test_add_filter_adds_filter_only_once(self):
        filter = Filter()
        filterer = Filterer()

        filterer.add_filter(filter)
        self.assertEqual(filterer.filters, [filter])

        filterer.add_filter(filter)
        self.assertEqual(filterer.filters, [filter])
Ejemplo n.º 4
0
    def test_filter_allows_any_records_if_filter_name_isnt_provided(self):
        filter = Filter()

        log_record = make_log_record(name="name doesn't matter")
        self.assertTrue(filter(log_record))

        log_record = make_log_record(name="A.B")
        self.assertTrue(filter(log_record))

        log_record = make_log_record(name="A.B.C.D")
        self.assertTrue(filter(log_record))
Ejemplo n.º 5
0
 def test_filter_allows_records_with_name_equal_to_filter_name(self):
     filter = Filter("A.B.C")
     log_record = make_log_record(name="A.B.C")
     self.assertTrue(filter(log_record))
Ejemplo n.º 6
0
 def test_it_disallows_records_with_name_not_starting_with_filter_name(
         self):
     filter = Filter("A.B")
     log_record = make_log_record(name="B.A")
     self.assertFalse(filter(log_record))
Ejemplo n.º 7
0
 def test_filter_disallows_records_with_name_starting_with_filter_name_that_isnt_a_prefix(
         self):
     filter = Filter("A.B")
     log_record = make_log_record(name="A.BC")
     self.assertFalse(filter(log_record))