def setUp(self): self.options = { 'exporter_options': { 'log_level': 'DEBUG', 'logger_name': 'export-pipeline' } } self.filter = BaseFilter(self.options, meta())
class BaseFilterTest(unittest.TestCase): def setUp(self): self.options = { 'exporter_options': { 'log_level': 'DEBUG', 'logger_name': 'export-pipeline' } } self.filter = BaseFilter(self.options, meta()) def test_no_filter_configured_raise_notimplemented(self): with self.assertRaises(NotImplementedError): next(self.filter.filter_batch([{}])) def test_should_allow_extend_custom_filter(self): class CustomFilter(BaseFilter): def filter(self, item): return item.get('key') == 1 myfilter = CustomFilter(self.options, meta()) output = list(myfilter.filter_batch([{'key': 1}, {'key': 2}])) self.assertEqual([{'key': 1}], output)