def test__read_write_metadata(self):
        try:
            from opus_core.indicator_framework.image_types.table import Table
        except:
            raise
        else:

            table = Table(
                source_data=self.source_data,
                attribute='opus_core.test.attribute',
                dataset_name='test',
                output_type='tab',
                years=[
                    1980, 1981
                ]  # Indicators are not actually being computed, so the years don't matter here.
            )

            table.create(False)
            self.data_manager._export_indicator_to_file(
                indicator=table, source_data=self.source_data, year=None)

            metadata_file = table.get_file_name(extension='meta')
            metadata_path = os.path.join(table.get_storage_location(),
                                         metadata_file)
            self.assertEqual(os.path.exists(metadata_path), True)

            expected_path = 'test__tab__attribute.meta'
            self.assertEqual(metadata_file, expected_path)

            new_table = self.data_manager._import_indicator_from_file(
                metadata_path)
            for attr in [
                    'attributes', 'dataset_name', 'output_type',
                    'date_computed', 'years'
            ]:
                old_val = table.__getattribute__(attr)
                new_val = new_table.__getattribute__(attr)
                self.assertEqual(old_val, new_val)
            self.assertEqual(table.source_data.cache_directory,
                             new_table.source_data.cache_directory)
            self.assertEqual(
                table.source_data.dataset_pool_configuration.package_order,
                new_table.source_data.dataset_pool_configuration.package_order)
 def test__read_write_metadata(self):
     try:
         from opus_core.indicator_framework.image_types.table import Table
     except: 
         raise
     else:
         
         table = Table(
             source_data = self.source_data,
             attribute = 'opus_core.test.attribute',
             dataset_name = 'test',
             output_type = 'tab',
             years = [1980,1981] # Indicators are not actually being computed, so the years don't matter here.
         )
         
         table.create(False)
         self.data_manager._export_indicator_to_file(indicator = table,
                                                     source_data = self.source_data,
                                                     year = None)
         
         metadata_file = table.get_file_name(extension = 'meta')
         metadata_path = os.path.join(table.get_storage_location(),
                                      metadata_file)
         self.assertEqual(os.path.exists(metadata_path), True)
         
         expected_path = 'test__tab__attribute.meta'
         self.assertEqual(metadata_file,expected_path)
         
         new_table = self.data_manager._import_indicator_from_file(metadata_path)
         for attr in ['attributes','dataset_name',
                      'output_type','date_computed',
                      'years']:
             old_val = table.__getattribute__(attr)
             new_val = new_table.__getattribute__(attr)
             self.assertEqual(old_val,new_val)
         self.assertEqual(table.source_data.cache_directory,
                          new_table.source_data.cache_directory)
         self.assertEqual(table.source_data.dataset_pool_configuration.package_order,
                          new_table.source_data.dataset_pool_configuration.package_order)