示例#1
0
 def setUp(self):
     self.options = {
         'exporter_options': {
             'log_level': 'DEBUG',
             'logger_name': 'export-pipeline'
         }
     }
     self.filter = BaseFilter(self.options, meta())
示例#2
0
 def setUp(self):
     self.options = {
         'exporter_options': {
             'log_level': 'DEBUG',
             'logger_name': 'export-pipeline'
         }
     }
     self.filter = BaseFilter(self.options, meta())
示例#3
0
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)
示例#4
0
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)