class WebhookNotifierTest(unittest.TestCase):

    def setUp(self):
        self.options = {
            'exporter_options': {
                'LOG_LEVEL': 'DEBUG',
                'LOGGER_NAME': 'export-pipeline',
                'notifications': [
                    {
                        'name': 'exporters.notifications.webhook_notifier.WebhookNotifier',
                        'options':
                            {
                                'endpoints': ['http://test.com']
                            }
                    }
                ]
            },
            'writer': {
                'name': 'somewriter',
                'options': {
                    'some_option': 'some_value'
                }
            }

        }
        self.meta = {
            'configuration': self.options,
            'items_count': 0,
            'start_time': datetime.datetime.now(),
            'script_name': 'basic_export_manager'
        }
        self.notifier = WebhookNotifier(
            self.options['exporter_options']['notifications'][0], self.meta)

    @mock.patch('requests.post')
    def test_start_dump(self, mock_request):
        # TODO: make this test actually test something
        self.notifier.notify_start_dump([])

    @mock.patch('requests.post')
    def test_completed_dump(self, mock_request):
        # TODO: make this test actually test something
        self.notifier.notify_complete_dump([])

    @mock.patch('requests.post')
    def test_failed_dump(self, mock_request):
        # TODO: make this test actually test something
        self.notifier.notify_failed_job('', '')
示例#2
0
class WebhookNotifierTest(unittest.TestCase):
    def setUp(self):
        self.options = {
            'exporter_options': {
                'LOG_LEVEL':
                'DEBUG',
                'LOGGER_NAME':
                'export-pipeline',
                'notifications': [{
                    'name':
                    'exporters.notifications.webhook_notifier.WebhookNotifier',
                    'options': {
                        'endpoints': ['http://test.com']
                    }
                }]
            },
            'writer': {
                'name': 'somewriter',
                'options': {
                    'some_option': 'some_value'
                }
            }
        }
        self.meta = {
            'configuration': self.options,
            'items_count': 0,
            'start_time': datetime.datetime.now(),
            'script_name': 'basic_export_manager'
        }
        self.notifier = WebhookNotifier(
            self.options['exporter_options']['notifications'][0], self.meta)

    @mock.patch('requests.post')
    def test_start_dump(self, mock_request):
        # TODO: make this test actually test something
        self.notifier.notify_start_dump([])

    @mock.patch('requests.post')
    def test_completed_dump(self, mock_request):
        # TODO: make this test actually test something
        self.notifier.notify_complete_dump([])

    @mock.patch('requests.post')
    def test_failed_dump(self, mock_request):
        # TODO: make this test actually test something
        self.notifier.notify_failed_job('', '')