def test_bluelabs_with_compression(self): records_format = DelimitedRecordsFormat(variant='bluelabs', hints={'compression': 'GZIP'}) unhandled_hints = set(records_format.hints) processing_instructions = ProcessingInstructions() load_plan = RecordsLoadPlan(processing_instructions, records_format) with self.assertRaises(NotImplementedError): postgres_copy_from_options(unhandled_hints, load_plan)
def test_new_compression_hint(self): records_format = DelimitedRecordsFormat(variant='bluelabs', hints={'compression': None}) records_format.hints['encoding'] = 'NEWNEWENCODING' unhandled_hints = set(records_format.hints) processing_instructions = ProcessingInstructions() load_plan = RecordsLoadPlan(processing_instructions, records_format) with self.assertRaises(NotImplementedError): postgres_copy_from_options(unhandled_hints, load_plan)
def test_vertica(self): records_format = DelimitedRecordsFormat(variant='vertica', hints={'compression': None}) records_format.hints['escape'] = '\\' unhandled_hints = set(records_format.hints) processing_instructions = ProcessingInstructions() load_plan = RecordsLoadPlan(processing_instructions, records_format) with self.assertRaises(NotImplementedError): postgres_copy_from_options(unhandled_hints, load_plan)
def test_csv_quote_all(self): records_format = DelimitedRecordsFormat(variant='csv', hints={ 'compression': None, 'quoting': 'all' }) unhandled_hints = set(records_format.hints) processing_instructions = ProcessingInstructions() load_plan = RecordsLoadPlan(processing_instructions, records_format) with self.assertRaises(NotImplementedError): postgres_copy_from_options(unhandled_hints, load_plan)
def test_load_known_formats(self): mock_url_resolver = Mock(name='url_resolver') mock_meta = Mock(name='meta') mock_db = Mock(name='db') loader = PostgresLoader(url_resolver=mock_url_resolver, meta=mock_meta, db=mock_db) known_load_formats = loader.known_supported_records_formats_for_load() for records_format in known_load_formats: unhandled_hints = set(records_format.hints) processing_instructions = ProcessingInstructions() load_plan = RecordsLoadPlan(processing_instructions, records_format) # ensure no exception thrown postgres_copy_from_options(unhandled_hints, load_plan) self.assertFalse(unhandled_hints)
def test_bluelabs_uncompressed(self): records_format = DelimitedRecordsFormat(variant='bluelabs', hints={'compression': None}) unhandled_hints = set(records_format.hints) processing_instructions = ProcessingInstructions() load_plan = RecordsLoadPlan(processing_instructions, records_format) date_input_style, copy_options = postgres_copy_from_options( unhandled_hints, load_plan) self.assertEqual(date_input_style, None) self.assertEqual( copy_options, { 'format': 'text', 'encoding': 'UTF8', 'header': False, 'delimiter': ',' })