예제 #1
0
 def test_text_file_io_basic_text_data_read_without_cache_with_invalid_read_processor_expect_no_changes_in_input_type(
         self):
     iop = 'Invalid Processor'
     gdc_result = {'Test': 123}
     tfio = TextFileIO(file_folder_path='.', file_name='READ_TEST')
     text_data = '*'
     with open('READ_TEST', 'w') as f:
         f.write(text_data)
     tfio.read(read_processor=iop,
               multiplier=8,
               result_generic_data_container=gdc_result)
     self.assertIsNotNone(gdc_result)
     self.assertIsInstance(gdc_result, dict)
     self.assertEqual(1, len(gdc_result))
     self.assertTrue('Test' in gdc_result)
     self.assertEqual(123, gdc_result['Test'])
예제 #2
0
 def test_text_file_io_basic_text_data_read_without_cache_with_read_processor(
         self):
     iop = TextMultiplierGenericIOProcessor()
     gdc_result = GenericDataContainer(result_set_name='Result',
                                       data_type=str)
     tfio = TextFileIO(file_folder_path='.', file_name='READ_TEST')
     text_data = '*'
     with open('READ_TEST', 'w') as f:
         f.write(text_data)
     tfio.read(read_processor=iop,
               multiplier=8,
               result_generic_data_container=gdc_result)
     self.assertIsNotNone(gdc_result)
     self.assertIsInstance(gdc_result, GenericDataContainer)
     self.assertIsNotNone(gdc_result.data)
     self.assertEqual('********', gdc_result.data)
예제 #3
0
 def test_text_file_io_empty_text_data_read_without_cache(self):
     tfio = TextFileIO(file_folder_path='.', file_name='READ_TEST')
     with open('READ_TEST', 'w') as f:
         f.write('')
     gdc = tfio.read()
     self.assertIsNotNone(gdc)
     self.assertIsInstance(gdc, GenericDataContainer)
     self.assertIsNotNone(gdc.data)
     self.assertEqual('', gdc.data)
예제 #4
0
 def test_text_file_io_basic_text_data_read_with_cache(self):
     tfio = TextFileIO(file_folder_path='.',
                       file_name='READ_TEST',
                       enable_cache=True)
     text_data = 'TEST'
     with open('READ_TEST', 'w') as f:
         f.write(text_data)
     gdc = tfio.read()
     self.assertIsNotNone(gdc)
     self.assertIsInstance(gdc, GenericDataContainer)
     self.assertIsNotNone(gdc.data)
     self.assertEqual('TEST', gdc.data)
     self.assertTrue(os.path.isfile('READ_TEST'))
     if os.path.isfile('READ_TEST'):
         os.remove('READ_TEST')
     self.assertFalse(os.path.isfile('READ_TEST'))
     gdc_cached_value = tfio.read()
     self.assertIsNotNone(gdc_cached_value)
     self.assertIsInstance(gdc_cached_value, GenericDataContainer)
     self.assertIsNotNone(gdc_cached_value.data)
     self.assertEqual('TEST', gdc_cached_value.data)
예제 #5
0
 def test_text_file_io_basic_text_data_write_with_cache(self):
     tfio = TextFileIO(file_folder_path='.',
                       file_name='WRITE_TEST',
                       enable_cache=True)
     text_data = 'TEST'
     gdp = GenericDataContainer(data_type=str)
     gdp.store(data=text_data)
     tfio.write(data=gdp)
     os.remove('WRITE_TEST')
     result = tfio.read()
     self.assertIsNotNone(result)
     self.assertIsInstance(result, GenericDataContainer)
     self.assertEqual('TEST', result.data)