def test_filter_ip(self): """Check that filter_ip filter works as expected.""" ip_one = '1.2.3.4' ip_two = '2.3.4.5' self.headers = ' {{{0}}} '.format(ip_one) raw_line = self._build_test_string() log_line = Line(raw_line) filter_func_ip_one = filters.filter_ip(ip_one) filter_func_ip_two = filters.filter_ip(ip_two) self.assertTrue(filter_func_ip_one(log_line)) self.assertFalse(filter_func_ip_two(log_line))
def test_filter_ip(http_line_factory, to_filter, to_check, result): """Check that filter_ip filter works as expected.""" current_filter = filters.filter_ip(to_filter) headers = f' {{{to_check}}}' line = http_line_factory(headers=headers) assert current_filter(line) is result