Esempio n. 1
0
    def test_invalid_notification(self):
        options = valid_config_with_updates({
            'exporter_options': {
                "notifications": [{}]
            }
        })
        with self.assertRaisesRegexp(ValueError, 'Module name is missing'):
            ExporterConfig(options)

        options = valid_config_with_updates({
            'exporter_options': {
                "notifications": [{
                    "name": "invalid.module.name"
                }]
            }
        })
        with self.assertRaisesRegexp(ValueError, 'No module named'):
            ExporterConfig(options)

        options = valid_config_with_updates({
            'exporter_options': {
                "notifications": [{
                    "name": "exporters.export_formatter.json_export_formatter.JsonExportFormatter",
                    "options": {
                        "unsuported_option": True
                    }
                }]
            }
        })
        with self.assertRaisesRegexp(ValueError, 'unsupported_options'):
            ExporterConfig(options)
Esempio n. 2
0
    def test_stream_only_sections(self):
        config = valid_config_with_updates({
            "decompressor": {
                "name": "exporters.decompressors.ZLibDecompressor",
            },
            "deserializer": {
                "name": "exporters.deserializers.CSVDeserializer",
            },
        })
        with self.assertRaises(ConfigurationError) as cm:
            check_for_errors(config)

        expected_errors = {
            'decompressor': "The 'decompressor' section can only be used with a stream reader.",
            'deserializer': "The 'deserializer' section can only be used with a stream reader.",
        }
        assert expected_errors == cm.exception.errors

        config = valid_config_with_updates({
            "reader": {
                "name": "exporters.readers.fs_reader.FSReader",
                "options": {
                    "input": "."
                }
            },
            "decompressor": {
                "name": "exporters.decompressors.ZLibDecompressor",
            },
            "deserializer": {
                "name": "exporters.deserializers.CSVDeserializer",
            },
        })
        check_for_errors(config)  # should not raise
Esempio n. 3
0
    def test_invalid_formatter(self):
        options = valid_config_with_updates({
            'exporter_options': {
                "formatter": {}
            }
        })
        with self.assertRaisesRegexp(ValueError, 'Module name is missing'):
            ExporterConfig(options)

        options = valid_config_with_updates({
            'exporter_options': {
                "formatter": {
                    "name": "invalid.module.name"
                }
            }
        })
        with self.assertRaisesRegexp(ValueError, 'No module named'):
            ExporterConfig(options)
Esempio n. 4
0
 def test_valid_notification(self):
     options = valid_config_with_updates({
         'exporter_options': {
             "notifications": [{
                 "name": "exporters.notifications.ses_mail_notifier.SESMailNotifier",
             }]
         }
     })
     ExporterConfig(options)  # should not raise
Esempio n. 5
0
 def test_valid_formatter(self):
     options = valid_config_with_updates({
         'exporter_options': {
             "formatter": {
                 "name": "exporters.export_formatter.json_export_formatter.JsonExportFormatter"
             }
         }
     })
     ExporterConfig(options)  # should not raise
Esempio n. 6
0
 def test_invalid_homogeneus_list(self):
     options = valid_config_with_updates({
         'filter': {
             'name': 'exporters.filters.key_value_filters.KeyValueFilter',
             'options': {
                 "keys": ['This', 'should', 'be', 'dicts']
             }
         }
     })
     with self.assertRaisesRegexp(ValueError, 'Wrong type'):
         ExporterConfig(options)
Esempio n. 7
0
 def test_long_values(self):
     options = valid_config_with_updates({
         "reader": {
             "name": "exporters.readers.hubstorage_reader.HubstorageReader",
             "options": {
                 "collection_name": "asd",
                 "project_id": 2**70,  # long in PY2, int in PY3
             }
         }
     })
     ExporterConfig(options)  # should not raise
Esempio n. 8
0
    def test_supported_and_not_supported_options(self):
        options = valid_config_with_updates({
            'writer': {
                'name': 'exporters.writers.console_writer.ConsoleWriter',
                'options': {
                    'items_limit': 1234,
                    'not_a_supported_option': 'foo'
                }
            },
        })

        with self.assertRaisesRegexp(ValueError, 'unsupported_options'):
            ExporterConfig(options)
Esempio n. 9
0
    def test_supported_and_not_supported_options_for_subclass(self):
        mod_name = __name__ + '.SampleSubclassWriter'

        options = valid_config_with_updates({
            'writer': {
                'name': mod_name,
                'options': {
                    'filebase': 'blah',
                    'someoption': 'blah',
                    'not_supported_option': 'foo',
                }
            }
        })
        with self.assertRaisesRegexp(ValueError, 'unsupported_options'):
            ExporterConfig(options)